Select to view content in your preferred language

JSAPI 4.2: SimpleRenderer mixing up colors. What's up with that?

1234
1
01-19-2017 08:37 AM
DirkVandervoort
Frequent Contributor

I create a simple renderer with an extrusion and assign it to a feature layer:

var symbol = new PolygonSymbol3D({
   symbolLayers: [new ExtrudeSymbol3DLayer({
      size: 50000, // meters in height extruded
   })]
});

var renderer = new SimpleRenderer({
   symbol: symbol,
   label: "Tract by ROW Acquisition Status",
   visualVariables: [{
      type: "color",
      field: "Acquisition_Status",
      stops: [
         {
            value: 'Not Acquired',
            color: "green", // DISPLAYS AS ***RED*** IN THE WEB SCENE
            label: "Not Acquired"
         },{
            value: 'Acquired',
            color: "red", // DISPLAYS AS ***GREEN*** IN THE WEB SCENE
            label: "Acquired"
         }
      ]}
   ]
});

 

Then when I view the results in a scene the colors are reversed; i.e., "Acquired" is green and "Not Acquired" is red, even though the code told the renderer to have "Acquired" to be red and "Not Acquired" to be green. WUWT?

red is green and green is red

0 Kudos
1 Reply
RalucaNicola1
Esri Contributor

Hi Dirk,

Don't use SimpleRenderer with visualVariables in this case. Visual variables are meant to map continuous numeric data. Instead what you need is a UniqueValueRenderer. This works well when you have categories. 

Here is a sample that is quite similar to your case: Extrude building footprints based on real world heights | ArcGIS API for JavaScript 4.2 

0 Kudos