AnsweredAssumed Answered

Legend title based on variable needs to refresh too

Question asked by schlot on Aug 26, 2014
Latest reply on Aug 27, 2014 by schlot

I have a project that let's the user change which attribute field is used in the display.  It's based on the sample https://developers.arcgis.com/javascript/jssamples/renderer_dynamic_layer_change_attribute.html  For the legend, I'm creating it if it doesn't exist, but if it does, then I just want it to refresh.  My problem is that the title is based on a variable, defined based on the change event of the FilteringSelect list of fields.  When I change the field, the legend itself updates, but it still has the title from its initial creation.

 

Can I change just the title?  It doesn't seem to be honoring my title definition when I specify legend.refresh().  In this example, fields is the array of attributes from my layer and fieldChoice is the selected item from the FilteringSelect. 

 

  domConstruct.empty("legendDiv");
        if (!legend){       
         legend = new Legend({
            map: map,
            layerInfos: [{ "layer": featureLayer, "title": fields[fieldChoice] }]
          },"legendDiv");
          legend.startup();
          }else{
            legend.refresh();
            
          }

Outcomes