Is it possible to set data source in Infographic Widget from other widgets output?

1177
8
Jump to solution
11-07-2017 11:47 AM
James_001
Occasional Contributor II

Hi all,

I am trying to configured Infographic widget in WAB Dev 2.5. It takes data from other widget out put such as Query widget. I have configured Robert's Enhanced Search Widget Version 2.5 to replace the Query widget for my app requirements. I wonder is it possible Infographic widget can take data from Robert's Enhanced Search Widget?

Thanks,

Irfan 

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Irfan,

  In the Widget.js update the _drawResults function (lines 79 - 85):

      _drawResults: function (layerIndex, results, currentLayer, closeOnComplete) {
        var layerConfig = this.config.layers[layerIndex];
        if (this.graphicsLayerBuffer instanceof FeatureLayer) {
          this._addOperationalLayer(this.graphicsLayerBuffer);
        }
        if (currentLayer instanceof FeatureLayer) {
          this._addOperationalLayer(currentLayer);
        }

        var type, centerpoint;
        for (var i = 0, len = this.currentFeatures.length; i < len; i++) {
          var feature = this.currentFeatures[i];
          var listItem = this.list.items[this._returnListIndexFromOID(feature.attributes[layerConfig.objectIdField])];
          type = feature.geometry.type;
          switch (type) {
          case "multipoint":
          case "point":
            centerpoint = feature.geometry;
            break;
          case "polyline":
            centerpoint = feature.geometry.getPoint(0, 0);
            break;
          case "extent":
          case "polygon":
            centerpoint = feature.geometry.getExtent().getCenter();
            break;
          default:
            break;
          }
          listItem.centerpoint = centerpoint;
          var lyrDisablePopupsAndTrue = (layerConfig.hasOwnProperty("disablePopups") && layerConfig.disablePopups)?true:false;
          if((!this.config.disablePopups && !lyrDisablePopupsAndTrue) && !currentLayer._hasInfoTemplate){
            feature.setInfoTemplate(this._configurePopupTemplate(listItem));
          }
          feature.setSymbol(listItem.sym);
          if (feature.geometry) {
            currentLayer.add(feature);
            listItem.graphic = feature;
          }
        }
        this.zoomAttempt = 0;
        if (layerConfig.shareResult && layerConfig.addToAttrib) {
          if (this.wManager) {
            var widgetCfg = this._getWidgetConfig('AttributeTable');
            if(widgetCfg){
              var attWidget = this.wManager.getWidgetByLabel(widgetCfg.label);
              if(attWidget){
                this.attTableOpenedbySearch = !attWidget.showing;
                this.wManager.openWidget(attWidget);
                attWidget._openTable().then(lang.hitch(this, this._openResultInAttributeTable, currentLayer));
              }else{
                /*Attribute Table Widget is not loaded*/
                this.wManager.loadWidget(widgetCfg).then(lang.hitch(this, function(widget){
                  if(widget){
                    this.attTableOpenedbySearch = true;
                    widget.setPosition(this.getOffPanelWidgetPosition(widget));
                    this.wManager.openWidget(widget);
                    widget._openTable().then(lang.hitch(this, this._openResultInAttributeTable, currentLayer));
                  }
                }));
              }
            }else{
              console.warn('The Attribute Table Widget is not configured in this app.');
              this._zoomAndClose(closeOnComplete);
            }
          }
          if (closeOnComplete) {
            setTimeout(lang.hitch(this, function () {
              this.pManager.closePanel(this.id + '_panel');
            }), 500);
          }
        } else {
          this._zoomAndClose(closeOnComplete);
        }

        if (this.mouseovergraphics) {
          on(currentLayer, 'mouse-over', lang.hitch(this, this.onMouseOverGraphic));
        }
        try{
          this.updateDataSourceData(layerIndex, {
            features: currentLayer.graphics
          });
        }catch(e){
          console.error(e);
        }
        this.currentLayerAdded = currentLayer;
      },

View solution in original post

0 Kudos
8 Replies
RobertScheitlin__GISP
MVP Emeritus

Ifran,

  I have an updated file for you to use for this. I am not using InfoGraphics so I have not done much testing. In your app replace the Setting.js file in the

[install dir]\server\apps\[app#]\widgets\eSearch\setting\Setting.js. Once you have replaced that file restart WAB and then open the eSearch widget setting dialog in your app and just click OK button This should update the apps main config.json file with the new datasource info and now the InfoGraphic Widget should list the eSearch widget search layers.

0 Kudos
James_001
Occasional Contributor II

Robert, 

I really appreciate your help, where is the updated Setting.js file located I want to try in my app.

Irfan

0 Kudos
James_001
Occasional Contributor II

Sorry, I got it. It was a confusion. I was looking in different thread. I am trying now and let you know.

0 Kudos
James_001
Occasional Contributor II

Robert,

I replaced the Setting.js file successfully in  eSearch setting. I can see the widget output in infographic widget where I can add data from eSearch.  I can see all the eSearch attributes in Infographic widget too. So for everything is ok, except the data is not displaying in infographic widget.  I have tested with new esearch widget with different app but still It is not displaying the results in infographic widget.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Irfan,

  In the Widget.js update the _drawResults function (lines 79 - 85):

      _drawResults: function (layerIndex, results, currentLayer, closeOnComplete) {
        var layerConfig = this.config.layers[layerIndex];
        if (this.graphicsLayerBuffer instanceof FeatureLayer) {
          this._addOperationalLayer(this.graphicsLayerBuffer);
        }
        if (currentLayer instanceof FeatureLayer) {
          this._addOperationalLayer(currentLayer);
        }

        var type, centerpoint;
        for (var i = 0, len = this.currentFeatures.length; i < len; i++) {
          var feature = this.currentFeatures[i];
          var listItem = this.list.items[this._returnListIndexFromOID(feature.attributes[layerConfig.objectIdField])];
          type = feature.geometry.type;
          switch (type) {
          case "multipoint":
          case "point":
            centerpoint = feature.geometry;
            break;
          case "polyline":
            centerpoint = feature.geometry.getPoint(0, 0);
            break;
          case "extent":
          case "polygon":
            centerpoint = feature.geometry.getExtent().getCenter();
            break;
          default:
            break;
          }
          listItem.centerpoint = centerpoint;
          var lyrDisablePopupsAndTrue = (layerConfig.hasOwnProperty("disablePopups") && layerConfig.disablePopups)?true:false;
          if((!this.config.disablePopups && !lyrDisablePopupsAndTrue) && !currentLayer._hasInfoTemplate){
            feature.setInfoTemplate(this._configurePopupTemplate(listItem));
          }
          feature.setSymbol(listItem.sym);
          if (feature.geometry) {
            currentLayer.add(feature);
            listItem.graphic = feature;
          }
        }
        this.zoomAttempt = 0;
        if (layerConfig.shareResult && layerConfig.addToAttrib) {
          if (this.wManager) {
            var widgetCfg = this._getWidgetConfig('AttributeTable');
            if(widgetCfg){
              var attWidget = this.wManager.getWidgetByLabel(widgetCfg.label);
              if(attWidget){
                this.attTableOpenedbySearch = !attWidget.showing;
                this.wManager.openWidget(attWidget);
                attWidget._openTable().then(lang.hitch(this, this._openResultInAttributeTable, currentLayer));
              }else{
                /*Attribute Table Widget is not loaded*/
                this.wManager.loadWidget(widgetCfg).then(lang.hitch(this, function(widget){
                  if(widget){
                    this.attTableOpenedbySearch = true;
                    widget.setPosition(this.getOffPanelWidgetPosition(widget));
                    this.wManager.openWidget(widget);
                    widget._openTable().then(lang.hitch(this, this._openResultInAttributeTable, currentLayer));
                  }
                }));
              }
            }else{
              console.warn('The Attribute Table Widget is not configured in this app.');
              this._zoomAndClose(closeOnComplete);
            }
          }
          if (closeOnComplete) {
            setTimeout(lang.hitch(this, function () {
              this.pManager.closePanel(this.id + '_panel');
            }), 500);
          }
        } else {
          this._zoomAndClose(closeOnComplete);
        }

        if (this.mouseovergraphics) {
          on(currentLayer, 'mouse-over', lang.hitch(this, this.onMouseOverGraphic));
        }
        try{
          this.updateDataSourceData(layerIndex, {
            features: currentLayer.graphics
          });
        }catch(e){
          console.error(e);
        }
        this.currentLayerAdded = currentLayer;
      },
0 Kudos
James_001
Occasional Contributor II

Thanks Robert,

It is working now. I really appreciate your help!  Thanks again!

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Irfan,

   I will make this a part of the 2.6 release.

0 Kudos
AlexWhitesell
New Contributor II

If I want to do something similar, but with the Near Me Widget, would I make the above changes to the Near Me Widget or the Infographic Widget? Thanks!

0 Kudos