The Color Mixin is an abstract chart functional class providing universal coloring support as a mix-in for any concrete chart implementation.
Set the domain by determining the min and max values as retrieved by .colorAccessor over the chart's dataset.
Set or the get color accessor function. This function will be used to map a data point in a crossfilter group to a color value on the color scale. The default function uses the key accessor.
Parameters: Name Type Argument DescriptioncolorAccessor
function <optional>
// default index based color accessor .colorAccessor(function (d, i){return i;}) // color accessor for a multi-value crossfilter reduction .colorAccessor(function (d){return d.value.absGain;})
Overrides the color selection algorithm, replacing it with a simple function.
Normally colors will be determined by calling the colorAccessor
to get a value, and then passing that value through the colorScale
.
But sometimes it is difficult to get a color scale to produce the desired effect. The colorCalculator
takes the datum and index and returns a color directly.
colorCalculator
* <optional>
Set or get the current domain for the color mapping function. The domain must be supplied as an array.
Note: previously this method accepted a callback function. Instead you may use a custom scale set by .colors.
Parameters: Name Type Argument Descriptiondomain
Array.<String> <optional>
Retrieve current color scale or set a new color scale. This methods accepts any function that operates like a d3 scale.
Parameters: Name Type Argument Default DescriptioncolorScale
d3.scale <optional>
// alternate categorical scale chart.colors(d3.scale.category20b()); // ordinal scale chart.colors(d3.scaleOrdinal().range(['red','green','blue'])); // convenience method, the same as above chart.ordinalColors(['red','green','blue']); // set a linear scale chart.linearColors(["#4575b4", "#ffffbf", "#a50026"]);
Get the color for the datum d and counter i. This is used internally by charts to retrieve a color.
Parameters: Name Type Argument Descriptiond
* i
Number <optional>
Convenience method to set the color scale to an Hcl interpolated linear scale with range r
.
r
Array.<Number>
Convenience method to set the color scale to d3.scaleOrdinal with range r
.
r
Array.<String>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4