Browse Source

Fix update x domain for flow

pull/555/head
Masayuki Tanaka 10 years ago
parent
commit
ed6f738c34
  1. 16
      c3.js
  2. 4
      c3.min.js
  3. 5
      src/api.flow.js
  4. 5
      src/core.js
  5. 6
      src/domain.js

16
c3.js

@ -412,7 +412,7 @@
c3_chart_internal_fn.redraw = function (options, transitions) { c3_chart_internal_fn.redraw = function (options, transitions) {
var $$ = this, main = $$.main, d3 = $$.d3, config = $$.config; var $$ = this, main = $$.main, d3 = $$.d3, config = $$.config;
var areaIndices = $$.getShapeIndices($$.isAreaType), barIndices = $$.getShapeIndices($$.isBarType), lineIndices = $$.getShapeIndices($$.isLineType); var areaIndices = $$.getShapeIndices($$.isAreaType), barIndices = $$.getShapeIndices($$.isBarType), lineIndices = $$.getShapeIndices($$.isLineType);
var withY, withSubchart, withTransition, withTransitionForExit, withTransitionForAxis, withTransform, withUpdateXDomain, withUpdateOrgXDomain, withLegend; var withY, withSubchart, withTransition, withTransitionForExit, withTransitionForAxis, withTransform, withUpdateXDomain, withUpdateOrgXDomain, withTrimXDomain, withLegend;
var hideAxis = $$.hasArcType(); var hideAxis = $$.hasArcType();
var drawArea, drawBar, drawLine, xForText, yForText; var drawArea, drawBar, drawLine, xForText, yForText;
var duration, durationForExit, durationForAxis; var duration, durationForExit, durationForAxis;
@ -429,6 +429,7 @@
withTransform = getOption(options, "withTransform", false); withTransform = getOption(options, "withTransform", false);
withUpdateXDomain = getOption(options, "withUpdateXDomain", false); withUpdateXDomain = getOption(options, "withUpdateXDomain", false);
withUpdateOrgXDomain = getOption(options, "withUpdateOrgXDomain", false); withUpdateOrgXDomain = getOption(options, "withUpdateOrgXDomain", false);
withTrimXDomain = getOption(options, "withTrimXDomain", true);
withLegend = getOption(options, "withLegend", false); withLegend = getOption(options, "withLegend", false);
withTransitionForExit = getOption(options, "withTransitionForExit", withTransition); withTransitionForExit = getOption(options, "withTransitionForExit", withTransition);
withTransitionForAxis = getOption(options, "withTransitionForAxis", withTransition); withTransitionForAxis = getOption(options, "withTransitionForAxis", withTransition);
@ -450,7 +451,7 @@
} }
if (targetsToShow.length) { if (targetsToShow.length) {
$$.updateXDomain(targetsToShow, withUpdateXDomain, withUpdateOrgXDomain); $$.updateXDomain(targetsToShow, withUpdateXDomain, withUpdateOrgXDomain, withTrimXDomain);
// update axis tick values according to options // update axis tick values according to options
if (!config.axis_x_tick_values && (config.axis_x_tick_fit || config.axis_x_tick_count)) { if (!config.axis_x_tick_values && (config.axis_x_tick_fit || config.axis_x_tick_count)) {
tickValues = $$.generateTickValues($$.mapTargetsToUniqueXs(targetsToShow), config.axis_x_tick_count); tickValues = $$.generateTickValues($$.mapTargetsToUniqueXs(targetsToShow), config.axis_x_tick_count);
@ -1351,7 +1352,7 @@
} }
return [min, max]; return [min, max];
}; };
c3_chart_internal_fn.updateXDomain = function (targets, withUpdateXDomain, withUpdateOrgXDomain, domain) { c3_chart_internal_fn.updateXDomain = function (targets, withUpdateXDomain, withUpdateOrgXDomain, withTrim, domain) {
var $$ = this, config = $$.config; var $$ = this, config = $$.config;
if (withUpdateOrgXDomain) { if (withUpdateOrgXDomain) {
@ -1367,9 +1368,7 @@
} }
// Trim domain when too big by zoom mousemove event // Trim domain when too big by zoom mousemove event
if (!domain) { if (withTrim) { $$.x.domain($$.trimXDomain($$.x.orgDomain())); }
$$.x.domain($$.trimXDomain($$.x.orgDomain()));
}
return $$.x.domain(); return $$.x.domain();
}; };
@ -5601,12 +5600,12 @@
diff = 1; diff = 1;
} }
domain = [baseValue.x - diff, baseValue.x]; domain = [baseValue.x - diff, baseValue.x];
$$.updateXDomain(null, true, true, domain); $$.updateXDomain(null, true, true, false, domain);
} else if (orgDataCount === 1) { } else if (orgDataCount === 1) {
if ($$.isTimeSeries()) { if ($$.isTimeSeries()) {
diff = (baseTarget.values[baseTarget.values.length - 1].x - baseValue.x) / 2; diff = (baseTarget.values[baseTarget.values.length - 1].x - baseValue.x) / 2;
domain = [new Date(+baseValue.x - diff), new Date(+baseValue.x + diff)]; domain = [new Date(+baseValue.x - diff), new Date(+baseValue.x + diff)];
$$.updateXDomain(null, true, true, domain); $$.updateXDomain(null, true, true, false, domain);
} }
} }
@ -5624,6 +5623,7 @@
}, },
withLegend: true, withLegend: true,
withTransition: orgDataCount > 1, withTransition: orgDataCount > 1,
withTrimXDomain: false
}); });
}; };

4
c3.min.js vendored

File diff suppressed because one or more lines are too long

5
src/api.flow.js

@ -113,12 +113,12 @@ c3_chart_fn.flow = function (args) {
diff = 1; diff = 1;
} }
domain = [baseValue.x - diff, baseValue.x]; domain = [baseValue.x - diff, baseValue.x];
$$.updateXDomain(null, true, true, domain); $$.updateXDomain(null, true, true, false, domain);
} else if (orgDataCount === 1) { } else if (orgDataCount === 1) {
if ($$.isTimeSeries()) { if ($$.isTimeSeries()) {
diff = (baseTarget.values[baseTarget.values.length - 1].x - baseValue.x) / 2; diff = (baseTarget.values[baseTarget.values.length - 1].x - baseValue.x) / 2;
domain = [new Date(+baseValue.x - diff), new Date(+baseValue.x + diff)]; domain = [new Date(+baseValue.x - diff), new Date(+baseValue.x + diff)];
$$.updateXDomain(null, true, true, domain); $$.updateXDomain(null, true, true, false, domain);
} }
} }
@ -136,6 +136,7 @@ c3_chart_fn.flow = function (args) {
}, },
withLegend: true, withLegend: true,
withTransition: orgDataCount > 1, withTransition: orgDataCount > 1,
withTrimXDomain: false
}); });
}; };

5
src/core.js

@ -407,7 +407,7 @@ c3_chart_internal_fn.updateTargets = function (targets) {
c3_chart_internal_fn.redraw = function (options, transitions) { c3_chart_internal_fn.redraw = function (options, transitions) {
var $$ = this, main = $$.main, d3 = $$.d3, config = $$.config; var $$ = this, main = $$.main, d3 = $$.d3, config = $$.config;
var areaIndices = $$.getShapeIndices($$.isAreaType), barIndices = $$.getShapeIndices($$.isBarType), lineIndices = $$.getShapeIndices($$.isLineType); var areaIndices = $$.getShapeIndices($$.isAreaType), barIndices = $$.getShapeIndices($$.isBarType), lineIndices = $$.getShapeIndices($$.isLineType);
var withY, withSubchart, withTransition, withTransitionForExit, withTransitionForAxis, withTransform, withUpdateXDomain, withUpdateOrgXDomain, withLegend; var withY, withSubchart, withTransition, withTransitionForExit, withTransitionForAxis, withTransform, withUpdateXDomain, withUpdateOrgXDomain, withTrimXDomain, withLegend;
var hideAxis = $$.hasArcType(); var hideAxis = $$.hasArcType();
var drawArea, drawBar, drawLine, xForText, yForText; var drawArea, drawBar, drawLine, xForText, yForText;
var duration, durationForExit, durationForAxis; var duration, durationForExit, durationForAxis;
@ -424,6 +424,7 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
withTransform = getOption(options, "withTransform", false); withTransform = getOption(options, "withTransform", false);
withUpdateXDomain = getOption(options, "withUpdateXDomain", false); withUpdateXDomain = getOption(options, "withUpdateXDomain", false);
withUpdateOrgXDomain = getOption(options, "withUpdateOrgXDomain", false); withUpdateOrgXDomain = getOption(options, "withUpdateOrgXDomain", false);
withTrimXDomain = getOption(options, "withTrimXDomain", true);
withLegend = getOption(options, "withLegend", false); withLegend = getOption(options, "withLegend", false);
withTransitionForExit = getOption(options, "withTransitionForExit", withTransition); withTransitionForExit = getOption(options, "withTransitionForExit", withTransition);
withTransitionForAxis = getOption(options, "withTransitionForAxis", withTransition); withTransitionForAxis = getOption(options, "withTransitionForAxis", withTransition);
@ -445,7 +446,7 @@ c3_chart_internal_fn.redraw = function (options, transitions) {
} }
if (targetsToShow.length) { if (targetsToShow.length) {
$$.updateXDomain(targetsToShow, withUpdateXDomain, withUpdateOrgXDomain); $$.updateXDomain(targetsToShow, withUpdateXDomain, withUpdateOrgXDomain, withTrimXDomain);
// update axis tick values according to options // update axis tick values according to options
if (!config.axis_x_tick_values && (config.axis_x_tick_fit || config.axis_x_tick_count)) { if (!config.axis_x_tick_values && (config.axis_x_tick_fit || config.axis_x_tick_count)) {
tickValues = $$.generateTickValues($$.mapTargetsToUniqueXs(targetsToShow), config.axis_x_tick_count); tickValues = $$.generateTickValues($$.mapTargetsToUniqueXs(targetsToShow), config.axis_x_tick_count);

6
src/domain.js

@ -187,7 +187,7 @@ c3_chart_internal_fn.getXDomain = function (targets) {
} }
return [min, max]; return [min, max];
}; };
c3_chart_internal_fn.updateXDomain = function (targets, withUpdateXDomain, withUpdateOrgXDomain, domain) { c3_chart_internal_fn.updateXDomain = function (targets, withUpdateXDomain, withUpdateOrgXDomain, withTrim, domain) {
var $$ = this, config = $$.config; var $$ = this, config = $$.config;
if (withUpdateOrgXDomain) { if (withUpdateOrgXDomain) {
@ -203,9 +203,7 @@ c3_chart_internal_fn.updateXDomain = function (targets, withUpdateXDomain, withU
} }
// Trim domain when too big by zoom mousemove event // Trim domain when too big by zoom mousemove event
if (!domain) { if (withTrim) { $$.x.domain($$.trimXDomain($$.x.orgDomain())); }
$$.x.domain($$.trimXDomain($$.x.orgDomain()));
}
return $$.x.domain(); return $$.x.domain();
}; };

Loading…
Cancel
Save