Commit f1899271 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Add data.names API - #100

parent f2d80144
...@@ -3491,6 +3491,7 @@ ...@@ -3491,6 +3491,7 @@
legend.selectAll('text') legend.selectAll('text')
.data(ids) .data(ids)
.text(function (id) { return isDefined(__data_names[id]) ? __data_names[id] : id; }) // MEMO: needed for update
.each(function (id, i) { updatePositions(this, id, i === 0); }) .each(function (id, i) { updatePositions(this, id, i === 0); })
.transition().duration(withTransition ? 250 : 0) .transition().duration(withTransition ? 250 : 0)
.attr('x', xForLegendText) .attr('x', xForLegendText)
...@@ -3824,6 +3825,12 @@ ...@@ -3824,6 +3825,12 @@
var targets = getTargets(function (t) { return t.id === targetId; }); var targets = getTargets(function (t) { return t.id === targetId; });
return targets.length > 0 ? targets[0] : undefined; return targets.length > 0 ? targets[0] : undefined;
}; };
c3.data.names = function (names) {
if (!arguments.length) { return __data_names; }
__data_names = names;
updateLegend(c3.data.targets, {withTransition: true});
return __data_names;
};
c3.resize = function (size) { c3.resize = function (size) {
__size_width = size ? size.width : null; __size_width = size ? size.width : null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment