<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Change Field being used in renderer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-field-being-used-in-renderer/m-p/1063179#M73344</link>
    <description>&lt;P&gt;I figured it out.....doing some more testing and will reply with my solution&lt;/P&gt;</description>
    <pubDate>Sun, 30 May 2021 21:28:34 GMT</pubDate>
    <dc:creator>jaykapalczynski</dc:creator>
    <dc:date>2021-05-30T21:28:34Z</dc:date>
    <item>
      <title>Change Field being used in renderer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-field-being-used-in-renderer/m-p/1063174#M73343</link>
      <description>&lt;P&gt;I am trying to control the field being used in a ClassBreaksRenderer...no luck so far&lt;/P&gt;&lt;P&gt;I tried to write a value to a variable and then set the FIELD: &lt;EM&gt;someVariable&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;As you see below I am hardcoding the field name...but I want this to be dynamic based on a value that I choose from a drop down....&lt;/P&gt;&lt;P&gt;On the event listener of the drop down I want to update the Field that is being referenced by the ClassBreaksRenderer....&lt;/P&gt;&lt;P&gt;Anyone have any thoughts or examples?&amp;nbsp; Thank you in Advanced.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var rendererPolygon = new ClassBreaksRenderer({
  type: "class-breaks",
  // attribute of interest
  field: "Field4"
});
// All features with magnitude between 0 - 4.0
rendererPolygon.addClassBreakInfo({
  minValue: 0,
  maxValue: 1,
  symbol: {
    type: "simple-fill",  
    color: [65,105,225,.5],    // Light Blue
	style: "solid",
    outline: {
       width: 0.1,
       color: "gray"
    }
  }
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 30 May 2021 20:46:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-field-being-used-in-renderer/m-p/1063174#M73343</guid>
      <dc:creator>jaykapalczynski</dc:creator>
      <dc:date>2021-05-30T20:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: Change Field being used in renderer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-field-being-used-in-renderer/m-p/1063179#M73344</link>
      <description>&lt;P&gt;I figured it out.....doing some more testing and will reply with my solution&lt;/P&gt;</description>
      <pubDate>Sun, 30 May 2021 21:28:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-field-being-used-in-renderer/m-p/1063179#M73344</guid>
      <dc:creator>jaykapalczynski</dc:creator>
      <dc:date>2021-05-30T21:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Change Field being used in renderer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-field-being-used-in-renderer/m-p/1063680#M73356</link>
      <description>&lt;OL&gt;&lt;LI&gt;Declare Variable&lt;/LI&gt;&lt;LI&gt;Set variable to the field property in Renderer&lt;/LI&gt;&lt;LI&gt;In my case I had to get the real field name...passed the value from the dropdown box to a function and RETURN the real field name&lt;/LI&gt;&lt;LI&gt;I did #3 above with a listener on change of the Dropdown box&lt;/LI&gt;&lt;LI&gt;I set that to the renderer... rendererPolygon.field = &lt;EM&gt;returned&amp;nbsp;real name&lt;/EM&gt;&lt;/LI&gt;&lt;LI&gt;Then add the layer to the map&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Any questions hit me up....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var speciesChoosen2, originalSpecies;
var fieldChoosen = "";  // varaible holding field value to render on

var rendererPolygon = new ClassBreaksRenderer({
  type: "class-breaks",
  field: fieldChoosen
});
const monumentLayer = new FeatureLayer({
     title: "National Monuments",
     fields: [
       {
         name: "OBJECTID",
         alias: "ObjectID",
         type: "oid"
       }
     ],
     objectIdField: "OBJECTID",
     geometryType: "polygon",
     source: resultsPolygonLayer2.graphics, 
     renderer: rendererPolygon,
     popupTemplate: {
         title: '"{' + fieldChoosen + '}"'
     }
});

// SNIP

Function getFieldName(typeName){
if (typeName == "some value") {
	fieldChoosen = "field1";
	return "field1";
} 
else if (typeName == "typeName") {
	fieldChoosen = "field2";
	return "field2";
}
else {
	fieldChoosen = "";
	return "nothing found";
}
};

// SNIP

dropdownSelect.addEventListener("change", function() {
     var type = event.target.value;			
     var e = document.getElementById("well-type");
     originalSpecies = e.value;
     var fieldValue2 = getFieldName(originalSpecies);
     speciesChoosen2 = fieldValue2;
     fieldChoosen = speciesChoosen2;
     rendererPolygon.field = speciesChoosen2;


// SNIP
// Noting that this is all done before adding the layer to the map. Its all about timing.
function addFeatureLayer(){
    map.add(monumentLayer);
    monumentLayer.refresh();
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jun 2021 16:16:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/change-field-being-used-in-renderer/m-p/1063680#M73356</guid>
      <dc:creator>jaykapalczynski</dc:creator>
      <dc:date>2021-06-01T16:16:15Z</dc:date>
    </item>
  </channel>
</rss>

