Commit 35b7bdf4 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Modify step chart interpolation - #566

parent 29157e71
...@@ -1013,7 +1013,9 @@ ...@@ -1013,7 +1013,9 @@
point_focus_expand_enabled: true, point_focus_expand_enabled: true,
point_focus_expand_r: undefined, point_focus_expand_r: undefined,
point_select_r: undefined, point_select_r: undefined,
// line
line_connectNull: false, line_connectNull: false,
line_step_type: 'step',
// bar // bar
bar_width: undefined, bar_width: undefined,
bar_width_ratio: 0.6, bar_width_ratio: 0.6,
...@@ -2164,7 +2166,7 @@ ...@@ -2164,7 +2166,7 @@
if ($$.dragging || $$.flowing) { return; } // do nothing while dragging/flowing if ($$.dragging || $$.flowing) { return; } // do nothing while dragging/flowing
if ($$.hasArcType()) { return; } if ($$.hasArcType()) { return; }
if ($$.isStepType(d) && d3.mouse(this)[0] < $$.x($$.getXValue(d.id, index))) { if ($$.isStepType(d) && $$.config.line_step_type === 'step-after' && d3.mouse(this)[0] < $$.x($$.getXValue(d.id, index))) {
index -= 1; index -= 1;
} }
...@@ -2224,7 +2226,7 @@ ...@@ -2224,7 +2226,7 @@
$$.cancelClick = false; $$.cancelClick = false;
return; return;
} }
if ($$.isStepType(d) && d3.mouse(this)[0] < $$.x($$.getXValue(d.id, index))) { if ($$.isStepType(d) && config.line_step_type === 'step-after' && d3.mouse(this)[0] < $$.x($$.getXValue(d.id, index))) {
index -= 1; index -= 1;
} }
$$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) {
...@@ -2511,7 +2513,7 @@ ...@@ -2511,7 +2513,7 @@
c3_chart_internal_fn.getInterpolate = function (d) { c3_chart_internal_fn.getInterpolate = function (d) {
var $$ = this; var $$ = this;
return $$.isSplineType(d) ? "cardinal" : $$.isStepType(d) ? "step-after" : "linear"; return $$.isSplineType(d) ? "cardinal" : $$.isStepType(d) ? $$.config.line_step_type : "linear";
}; };
c3_chart_internal_fn.initLine = function () { c3_chart_internal_fn.initLine = function () {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -134,7 +134,9 @@ c3_chart_internal_fn.getDefaultConfig = function () { ...@@ -134,7 +134,9 @@ c3_chart_internal_fn.getDefaultConfig = function () {
point_focus_expand_enabled: true, point_focus_expand_enabled: true,
point_focus_expand_r: undefined, point_focus_expand_r: undefined,
point_select_r: undefined, point_select_r: undefined,
// line
line_connectNull: false, line_connectNull: false,
line_step_type: 'step',
// bar // bar
bar_width: undefined, bar_width: undefined,
bar_width_ratio: 0.6, bar_width_ratio: 0.6,
......
...@@ -158,7 +158,7 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) { ...@@ -158,7 +158,7 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) {
if ($$.dragging || $$.flowing) { return; } // do nothing while dragging/flowing if ($$.dragging || $$.flowing) { return; } // do nothing while dragging/flowing
if ($$.hasArcType()) { return; } if ($$.hasArcType()) { return; }
if ($$.isStepType(d) && d3.mouse(this)[0] < $$.x($$.getXValue(d.id, index))) { if ($$.isStepType(d) && $$.config.line_step_type === 'step-after' && d3.mouse(this)[0] < $$.x($$.getXValue(d.id, index))) {
index -= 1; index -= 1;
} }
...@@ -218,7 +218,7 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) { ...@@ -218,7 +218,7 @@ c3_chart_internal_fn.generateEventRectsForSingleX = function (eventRectEnter) {
$$.cancelClick = false; $$.cancelClick = false;
return; return;
} }
if ($$.isStepType(d) && d3.mouse(this)[0] < $$.x($$.getXValue(d.id, index))) { if ($$.isStepType(d) && config.line_step_type === 'step-after' && d3.mouse(this)[0] < $$.x($$.getXValue(d.id, index))) {
index -= 1; index -= 1;
} }
$$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) { $$.main.selectAll('.' + CLASS.shape + '-' + index).each(function (d) {
......
...@@ -62,5 +62,5 @@ c3_chart_internal_fn.isWithinShape = function (that, d) { ...@@ -62,5 +62,5 @@ c3_chart_internal_fn.isWithinShape = function (that, d) {
c3_chart_internal_fn.getInterpolate = function (d) { c3_chart_internal_fn.getInterpolate = function (d) {
var $$ = this; var $$ = this;
return $$.isSplineType(d) ? "cardinal" : $$.isStepType(d) ? "step-after" : "linear"; return $$.isSplineType(d) ? "cardinal" : $$.isStepType(d) ? $$.config.line_step_type : "linear";
}; };
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