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.0 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; }
11 years ago
Object.keys(names).forEach(function (id) {
config.data_names[id] = names[id];
11 years ago
});
$$.redraw({withLegend: true});
return config.data_names;
11 years ago
};
c3_chart_fn.data.colors = function (colors) {
var $$ = this.internal, config = $$.config;
if (!arguments.length) { return config.data_colors; }
11 years ago
Object.keys(colors).forEach(function (id) {
config.data_colors[id] = colors[id];
11 years ago
});
$$.redraw({withLegend: true});
return config.data_colors;
11 years ago
};