From d49a68afe4808ccb3b632cd3089c508879f766a8 Mon Sep 17 00:00:00 2001 From: Laurence Hudson Date: Mon, 22 Jun 2015 14:19:54 +0100 Subject: [PATCH] Ensure that the input data to is numerically sorted (not alpha) --- src/data.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/data.js b/src/data.js index 12f1b05..3ccc0cf 100644 --- a/src/data.js +++ b/src/data.js @@ -171,7 +171,8 @@ c3_chart_internal_fn.filterTargetsToShow = function (targets) { c3_chart_internal_fn.mapTargetsToUniqueXs = function (targets) { var $$ = this; var xs = $$.d3.set($$.d3.merge(targets.map(function (t) { return t.values.map(function (v) { return +v.x; }); }))).values(); - return $$.isTimeSeries() ? xs.map(function (x) { return new Date(+x); }) : xs.map(function (x) { return +x; }); + xs = $$.isTimeSeries() ? xs.map(function (x) { return new Date(+x); }) : xs.map(function (x) { return +x; }); + return xs.sort(function (a, b) { return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; }); }; c3_chart_internal_fn.addHiddenTargetIds = function (targetIds) { this.hiddenTargetIds = this.hiddenTargetIds.concat(targetIds);