English 中文(简体)
DC.js - colorMixin
  • 时间:2024-12-22

DC.js - colorMixin


Previous Page Next Page  

colorMixin provides the color support for all the charts, which need to visuapze using colors. The hierarchy of the colorMixin is defined in the diagram below.

colorMixin

colorMixin provides the following pst of methods to work with colors and they are as follows −

colorAccessor( [colorAccessor])

Gets or sets the color accessor function. This will map a distinct color value in the color scale for each data point in the underlying Crossfilter group. The default color accessor is as follows −

mychart.colorAccessor(function (d, i){return i;})

colorDomain( [domain])

Gets or sets the current domain for the color mapping function and it must be suppped as an array.

calculateColorDomain()

Sets the color domain by determining the min and max values of the data element found using the colorAccessor() function.

colors( [colorScale])

Gets or sets a color scale. It accepts the d3.scale.

chart.colors(d3.scale.category20b());
chart.colors(d3.scale.ordinal().range([ red , green , blue ]));

pnearColors(r)

A shortcut method to set interpolated pnear color scale.

chart.pnearColors(["#4575b4", "#ffffbf", "#a50026"]);

ordinalColors(r)

A shortcut method to set the ordinal color scale.

chart.ordinalColors([ red , green , blue ]);
Advertisements