new ColorFormatter()
Creates a new style Formatter that returns a proper color for
any given data value.
The options parameter is a JSON object containing several optional
properties, such as:
- scale the scale used to format or classify data values. If not specified the default logarithm scale is used.
- numClasses the number of classes or buckets to use; if not specified then is is the same as the number of colors in the colors array.
- colors an array of colors to be used as base color stops or ramps. The lowest possible data value is mapped to the first color in the array, while the highest possible data value is mapped to the last color in the array.
- defaultColor the default color to use when the data value is null or a proper color cannot be determined. This color is typically used to render shapes with no data.
- style the color style which this formatter will be applied to. This is optional.
Methods
-
getBaseColors()
-
Returns the list of base colors used as color stops.
-
getBaseSources()
-
Returns the list of base sources used as color stops.
-
getDefaultColor()
-
returns the default
-
getDefaultSource()
-
returns the default
-
setColors(colors)
-
Sets the list of base colors to be used as color stops.
Parameters:
Name Type Description colors
array an array of colors
-
setDefaultColor()
-
sets the default color
-
setDefaultSource()
-
sets the default color
-
setSources(colors)
-
Sets the list of base colors to be used as color stops.
Parameters:
Name Type Description colors
array an array of colors