From d121a5bbab601a84241b293546bf4a4bd502d0e0 Mon Sep 17 00:00:00 2001 From: Phyks Date: Fri, 28 Mar 2014 20:55:19 +0100 Subject: [PATCH] Sort data array when treating it --- timeline.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/timeline.js b/timeline.js index 2f4e2e4..eb85c85 100644 --- a/timeline.js +++ b/timeline.js @@ -161,7 +161,17 @@ SVG.scale = function(data) { } SVG.addPoints = function (data) { - // TODO : Sort x croissants + data.sort(function (a, b) { + if(a.x < b.x) { + return -1; + } + else if(a.x == b.x) { + return 0; + } + else { + return 1; + } + }); for(point = 0; point < data.length; point++) { SVG.raw_points.push([data[point].x, data[point].y]); if(data[point].label !== 'undefined') {