Select to view content in your preferred language

How to use setVisualVariables instead of setColorInfo in a SimpleRenderer

886
2
Jump to solution
08-29-2017 01:37 PM
KenBuja
MVP Esteemed Contributor

The setColorInfo method for the SimpleRenderer was deprecated at as v3.13. However, I can't seem to get the setVisualVariable method to create a color ramp.

Using this sample, I've tried two different ways:

renderer.setVisualVariables({
  type: "colorInfo",
  field: "M086_07",
  minDataValue: 0,
  maxDataValue: 100,
  colors: [
    new Color([255, 255, 255]),
    new Color([127, 127, 0])
  ]
});

and

renderer.setVisualVariables({
  type: "colorInfo",
  field: "M086_07",
  stops: [
    {
      value: 0,
      color: new Color([255, 255, 255]),
      label: "0"
    },
    {
      value: 100,
      color: new Color([127, 127, 0]),
      label: "100"
    }
  ]
});

but neither of them work. I want to set the stops so that 0 is empty, but values 1-10 use a color ramp.

What is the correct way to use setVisualVariables?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Ken,

   setVisualVariables is expecting an array.

renderer.setVisualVariables([{
  type: "colorInfo",
  field: "M086_07",
  minDataValue: 0,
  maxDataValue: 100,
  colors: [
    new Color([255, 255, 255]),
    new Color([127, 127, 0])
  ]
}]);

View solution in original post

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

Ken,

   setVisualVariables is expecting an array.

renderer.setVisualVariables([{
  type: "colorInfo",
  field: "M086_07",
  minDataValue: 0,
  maxDataValue: 100,
  colors: [
    new Color([255, 255, 255]),
    new Color([127, 127, 0])
  ]
}]);
0 Kudos
KenBuja
MVP Esteemed Contributor

Thanks Robert,

I overlooked that extra set of brackets.

0 Kudos