Commit 1d6b4302 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Avoid generating line points for performance - #553

parent a9b0e620
...@@ -434,8 +434,8 @@ ...@@ -434,8 +434,8 @@
var waitForDraw, flow; var waitForDraw, flow;
var targetsToShow = $$.filterTargetsToShow($$.data.targets), tickValues, i, intervalForCulling, xDomainForZoom; var targetsToShow = $$.filterTargetsToShow($$.data.targets), tickValues, i, intervalForCulling, xDomainForZoom;
var xv = $$.xv.bind($$), var xv = $$.xv.bind($$),
cx = ($$.config.axis_rotated ? $$.circleY : $$.circleX).bind($$), cx = ($$.config.axis_rotated ? $$.generateCircleY() : $$.circleX).bind($$),
cy = ($$.config.axis_rotated ? $$.circleX : $$.circleY).bind($$); cy = ($$.config.axis_rotated ? $$.circleX : $$.generateCircleY()).bind($$);
options = options || {}; options = options || {};
withY = getOption(options, "withY", true); withY = getOption(options, "withY", true);
...@@ -2933,10 +2933,19 @@ ...@@ -2933,10 +2933,19 @@
c3_chart_internal_fn.circleX = function (d) { c3_chart_internal_fn.circleX = function (d) {
return d.x || d.x === 0 ? this.x(d.x) : null; return d.x || d.x === 0 ? this.x(d.x) : null;
}; };
c3_chart_internal_fn.circleY = function (d, i) { c3_chart_internal_fn.generateCircleY = function () {
var $$ = this, var $$ = this, lineIndices, getPoints;
lineIndices = $$.getShapeIndices($$.isLineType), getPoints = $$.generateGetLinePoints(lineIndices); if ($$.config.data_groups.length > 0) {
return $$.config.data_groups.length > 0 ? getPoints(d, i)[0][1] : $$.getYScale(d.id)(d.value); lineIndices = $$.getShapeIndices($$.isLineType),
getPoints = $$.generateGetLinePoints(lineIndices);
return function (d, i) {
return getPoints(d, i)[0][1];
};
} else {
return function (d) {
return $$.getYScale(d.id)(d.value);
};
}
}; };
c3_chart_internal_fn.getCircles = function (i, id) { c3_chart_internal_fn.getCircles = function (i, id) {
var $$ = this; var $$ = this;
...@@ -4916,8 +4925,8 @@ ...@@ -4916,8 +4925,8 @@
c3_chart_internal_fn.selectPoint = function (target, d, i) { c3_chart_internal_fn.selectPoint = function (target, d, i) {
var $$ = this, config = $$.config, var $$ = this, config = $$.config,
cx = (config.axis_rotated ? $$.circleY : $$.circleX).bind($$), cx = (config.axis_rotated ? $$.generateCircleY() : $$.circleX).bind($$),
cy = (config.axis_rotated ? $$.circleX : $$.circleY).bind($$), cy = (config.axis_rotated ? $$.circleX : $$.generateCircleY()).bind($$),
r = $$.pointSelectR.bind($$); r = $$.pointSelectR.bind($$);
config.data_onselected.call($$.api, d, target.node()); config.data_onselected.call($$.api, d, target.node());
// add selected-circle on low layer g // add selected-circle on low layer g
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -429,8 +429,8 @@ c3_chart_internal_fn.redraw = function (options, transitions) { ...@@ -429,8 +429,8 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
var waitForDraw, flow; var waitForDraw, flow;
var targetsToShow = $$.filterTargetsToShow($$.data.targets), tickValues, i, intervalForCulling, xDomainForZoom; var targetsToShow = $$.filterTargetsToShow($$.data.targets), tickValues, i, intervalForCulling, xDomainForZoom;
var xv = $$.xv.bind($$), var xv = $$.xv.bind($$),
cx = ($$.config.axis_rotated ? $$.circleY : $$.circleX).bind($$), cx = ($$.config.axis_rotated ? $$.generateCircleY() : $$.circleX).bind($$),
cy = ($$.config.axis_rotated ? $$.circleX : $$.circleY).bind($$); cy = ($$.config.axis_rotated ? $$.circleX : $$.generateCircleY()).bind($$);
options = options || {}; options = options || {};
withY = getOption(options, "withY", true); withY = getOption(options, "withY", true);
......
c3_chart_internal_fn.selectPoint = function (target, d, i) { c3_chart_internal_fn.selectPoint = function (target, d, i) {
var $$ = this, config = $$.config, var $$ = this, config = $$.config,
cx = (config.axis_rotated ? $$.circleY : $$.circleX).bind($$), cx = (config.axis_rotated ? $$.generateCircleY() : $$.circleX).bind($$),
cy = (config.axis_rotated ? $$.circleX : $$.circleY).bind($$), cy = (config.axis_rotated ? $$.circleX : $$.generateCircleY()).bind($$),
r = $$.pointSelectR.bind($$); r = $$.pointSelectR.bind($$);
config.data_onselected.call($$.api, d, target.node()); config.data_onselected.call($$.api, d, target.node());
// add selected-circle on low layer g // add selected-circle on low layer g
......
...@@ -306,10 +306,19 @@ c3_chart_internal_fn.addTransitionForCircle = function (transitions, cx, cy) { ...@@ -306,10 +306,19 @@ c3_chart_internal_fn.addTransitionForCircle = function (transitions, cx, cy) {
c3_chart_internal_fn.circleX = function (d) { c3_chart_internal_fn.circleX = function (d) {
return d.x || d.x === 0 ? this.x(d.x) : null; return d.x || d.x === 0 ? this.x(d.x) : null;
}; };
c3_chart_internal_fn.circleY = function (d, i) { c3_chart_internal_fn.generateCircleY = function () {
var $$ = this, var $$ = this, lineIndices, getPoints;
lineIndices = $$.getShapeIndices($$.isLineType), getPoints = $$.generateGetLinePoints(lineIndices); if ($$.config.data_groups.length > 0) {
return $$.config.data_groups.length > 0 ? getPoints(d, i)[0][1] : $$.getYScale(d.id)(d.value); lineIndices = $$.getShapeIndices($$.isLineType),
getPoints = $$.generateGetLinePoints(lineIndices);
return function (d, i) {
return getPoints(d, i)[0][1];
};
} else {
return function (d) {
return $$.getYScale(d.id)(d.value);
};
}
}; };
c3_chart_internal_fn.getCircles = function (i, id) { c3_chart_internal_fn.getCircles = function (i, id) {
var $$ = this; var $$ = this;
......
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