mirror of https://github.com/masayuki0812/c3.git
Quite good looking graph derived from d3.js
http://c3js.org
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1.1 KiB
28 lines
1.1 KiB
11 years ago
|
c3_chart_fn.data = function () {};
|
||
|
c3_chart_fn.data.get = function (targetId) {
|
||
|
var target = this.data.getAsTarget(targetId);
|
||
|
return isDefined(target) ? target.values.map(function (d) { return d.value; }) : undefined;
|
||
|
};
|
||
|
c3_chart_fn.data.getAsTarget = function (targetId) {
|
||
|
var targets = this.data.targets.filter(function (t) { return t.id === targetId; });
|
||
|
return targets.length > 0 ? targets[0] : undefined;
|
||
|
};
|
||
|
c3_chart_fn.data.names = function (names) {
|
||
|
var $$ = this.internal, config = $$.config;
|
||
|
if (!arguments.length) { return config[__data_names]; }
|
||
|
Object.keys(names).forEach(function (id) {
|
||
|
config[__data_names][id] = names[id];
|
||
|
});
|
||
|
$$.redraw({withLegend: true});
|
||
|
return config[__data_names];
|
||
|
};
|
||
|
c3_chart_fn.data.colors = function (colors) {
|
||
|
var $$ = this.internal, config = $$.config;
|
||
|
if (!arguments.length) { return config[__data_colors]; }
|
||
|
Object.keys(colors).forEach(function (id) {
|
||
|
config[__data_colors][id] = colors[id];
|
||
|
});
|
||
|
$$.redraw({withLegend: true});
|
||
|
return config[__data_colors];
|
||
|
};
|