Chart widget customization

2388
2
Jump to solution
02-02-2016 09:29 PM
SibghatUllah1
Occasional Contributor

I am using chart widget to generate charts and graph.It  is running fine,But my client wants to be simple.if he clicks on the chart icon the results should be displayed without selecting layer and apply button.Please suggest me how can i do.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Sibghat Ullah,

  There is no option or configuration for that. But you can make these code changes in the Widget.js to make that happen (lines 5 - 36):

      onOpen: function(){
        if(this.tempResultLayer){
          this.tempResultLayer.show();
        }
        //Show the first chart
        this.showFirstChart();
      },

      showFirstChart: function() {
        this._resetCurrentAttrs();
        this.currentAttrs.chartTr = {};
        this.currentAttrs.config = lang.clone(this.config.charts[0]);
        this.currentAttrs.layerInfo = this.currentAttrs.chartTr.layerInfo;//may be null
        var layerUrl = this.currentAttrs.config.url;
        this.shelter.show();
        var callback = lang.hitch(this, function() {
          this.currentAttrs.layerInfo = this.currentAttrs.chartTr.layerInfo;
          this._onBtnApplyClicked();
        });
        esriRequest({
          url: layerUrl,
          content: {
            f: 'json'
          },
          handleAs: 'json',
          callbackParamName: 'callback'
        }).then(lang.hitch(this, function(response){
          if (!this.domNode) {
            return;
          }
          this.shelter.hide();
          this.currentAttrs.chartTr.layerInfo = response;
          this.currentAttrs.layerInfo = this.currentAttrs.chartTr.layerInfo;
          callback();
        }));
      },

View solution in original post

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

Sibghat Ullah,

  There is no option or configuration for that. But you can make these code changes in the Widget.js to make that happen (lines 5 - 36):

      onOpen: function(){
        if(this.tempResultLayer){
          this.tempResultLayer.show();
        }
        //Show the first chart
        this.showFirstChart();
      },

      showFirstChart: function() {
        this._resetCurrentAttrs();
        this.currentAttrs.chartTr = {};
        this.currentAttrs.config = lang.clone(this.config.charts[0]);
        this.currentAttrs.layerInfo = this.currentAttrs.chartTr.layerInfo;//may be null
        var layerUrl = this.currentAttrs.config.url;
        this.shelter.show();
        var callback = lang.hitch(this, function() {
          this.currentAttrs.layerInfo = this.currentAttrs.chartTr.layerInfo;
          this._onBtnApplyClicked();
        });
        esriRequest({
          url: layerUrl,
          content: {
            f: 'json'
          },
          handleAs: 'json',
          callbackParamName: 'callback'
        }).then(lang.hitch(this, function(response){
          if (!this.domNode) {
            return;
          }
          this.shelter.hide();
          this.currentAttrs.chartTr.layerInfo = response;
          this.currentAttrs.layerInfo = this.currentAttrs.chartTr.layerInfo;
          callback();
        }));
      },
0 Kudos
SibghatUllah1
Occasional Contributor

Thank you very much Mr.Robert.

0 Kudos