From b1c83a53aa41e1dcada50d648a52eab4d7628040 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Sun, 13 Jan 2013 01:14:58 +0100 Subject: [PATCH] Fixed horizontal and vertical line drawing. --- src/html/index.html | 1 + src/html/js/entries.js | 36 +++++++++++++++++++----------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/html/index.html b/src/html/index.html index b2bb9b3..4167fc6 100644 --- a/src/html/index.html +++ b/src/html/index.html @@ -145,6 +145,7 @@ + diff --git a/src/html/js/entries.js b/src/html/js/entries.js index 08b3cac..c8df74d 100644 --- a/src/html/js/entries.js +++ b/src/html/js/entries.js @@ -379,18 +379,9 @@ drawChart = function(entries, element) { $(element).html(""); if(entries && entries.length > 0) { - var day = 24 * 60 * 60 * 1000; - - var lastDate = new Date(Date.parse(entries[entries.length -1][0]).valueOf() + 1 * day); - var firstDate = new Date(Date.parse(entries[0][0]).valueOf() - 1 * day); var chartValues = [[], []]; - // For the '0' line. - chartValues[0].push( - [new Date(firstDate.valueOf()).toString(), 0], - [new Date(lastDate.valueOf()).toString(), 0]); - - chartValues[1] = entries; + chartValues[0] = entries; // plot chart window.chart = $.jqplot(element.id, chartValues, { @@ -411,16 +402,27 @@ drawChart = function(entries, element) { }, series: [{ - linePattern: "dashed", - lineWidth: 1, - color: "red", - showMarker: false - },{ renderer:$.jqplot.OHLCRenderer, color: "blue", lineWidth: 3, - rendererOptions:{ - }}], + rendererOptions:{} + }], + canvasOverlay: { + show: true, + objects: [{ + dashedHorizontalLine: { + name: "zero", + y: 0, + lineWidth: 1, + color: "red" + }}, + { dashedVerticalLine: { + name: "today", + x: new Date(), + lineWidth: 1, + color: "gray" + }}] + } }); } else { window.chart = null;