new graph

This commit is contained in:
Martin Donnelly 2016-08-15 14:12:34 +01:00
parent 3721138bad
commit 81b5cddd28

View File

@ -273,9 +273,19 @@ var self = this;
var chartData = []; var chartData = [];
var temporal = {high:0, low:0};
_(this.collection.models).each(function(i) { _(this.collection.models).each(function(i) {
var dt = i.get('dt');
if (temporal.low === 0 || dt < temporal.low) {
temporal.low = dt;
}
if (temporal.high === 0 || dt > temporal.high) {
temporal.high = dt;
}
chartData.push({ chartData.push({
date: i.get('dt'), date: dt,
value: i.get(getMode) value: i.get(getMode)
}); });
@ -349,8 +359,8 @@ var self = this;
// first trend line // first trend line
var trendLine = new AmCharts.TrendLine(); var trendLine = new AmCharts.TrendLine();
// note,when creating date objects 0 month is January, as months are zero based in JavaScript. // note,when creating date objects 0 month is January, as months are zero based in JavaScript.
trendLine.initialDate = new Date(2016, 7, 8, 12); // 12 is hour - to start trend line in the middle of the day trendLine.initialDate = temporal.low; // 12 is hour - to start trend line in the middle of the day
trendLine.finalDate = new Date(2012, 7, 15, 12); trendLine.finalDate = temporal.high;
trendLine.initialValue = 10; trendLine.initialValue = 10;
trendLine.finalValue = 19; trendLine.finalValue = 19;
trendLine.lineColor = "#CC0000"; trendLine.lineColor = "#CC0000";
@ -358,8 +368,8 @@ var self = this;
// second trend line // second trend line
trendLine = new AmCharts.TrendLine(); trendLine = new AmCharts.TrendLine();
trendLine.initialDate = new Date(2016, 7, 8, 12); // 12 is hour - to start trend line in the middle of the day trendLine.initialDate = temporal.low; // 12 is hour - to start trend line in the middle of the day
trendLine.finalDate = new Date(2012, 7, 15, 12); trendLine.finalDate = new temporal.high;
trendLine.initialValue = 16; trendLine.initialValue = 16;
trendLine.finalValue = 10; trendLine.finalValue = 10;
trendLine.lineColor = "#CC0000"; trendLine.lineColor = "#CC0000";