Chart With Color Groups - mwasiluk/ODC-d3 GitHub Wiki
Base class for charts with color groups and legend. Provides support for data in series format. Extends Chart #Configuration
Configuration object properties:
- showLegend - show legend, boolean (default: false)
- legend - legend configuration object:
- width - number, default: 80
- margin - number, default: 10
- shapeWidth - number, default: 20
- groups - groups configuration object:
- key - object property name or array index with grouping variable, default: 2
- value - grouping value accessor with
this
set to the config object, may be used to override default accessor:function(d) { return d[this.groups.key] }
- displayValue - optional function returning display value (series label) for given group value, or object/array mapping value to display value
- color - css color string or function returning color's value for color scale
- d3ColorCategory - d3 color scale name, default: category10
- series - use series data, boolean (default: false)
Data format
Array of arrays or objects, e.g.:
var data = [
[1, 2, 'dog'],
[2, 3, 'cat'],
[3, 4, 'dog']
];
or
var data = [
{a: 1, b: 2, species: 'dog'},
{a: 2, b: 3, species: 'cat'},
{a: 3, b: 4, species: 'dog'},
];
or series (requires series
option set to true)
var data = [
{
key: "dog",
values: [{a: 1, b: 2}, {a: 3, b: 4}]
},
{
key: "cat",
values: [{a: 2, b: 3}]
}
];