Browse Source

Modify step chart interpolation - #566

pull/615/head
Masayuki Tanaka 10 years ago
parent
commit
35b7bdf426
  1. 8
      c3.js
  2. 4
      c3.min.js
  3. 2
      src/config.js
  4. 4
      src/interaction.js
  5. 2
      src/shape.js

8
c3.js

@ -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 @@
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 @@
$$.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 @@
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 () {

4
c3.min.js vendored

File diff suppressed because one or more lines are too long

2
src/config.js

@ -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,

4
src/interaction.js

@ -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) {
$$.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) {

2
src/shape.js

@ -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";
}; };

Loading…
Cancel
Save