Ei muokkausyhteenvetoa |
Ei muokkausyhteenvetoa |
||
| Rivi 601: | Rivi 601: | ||
} | } | ||
function | function XaddDataToSeasonChart(memo) { | ||
memo.axisMinDate = new Date( memo.obsMinCompDateMs ); | |||
memo.axisMinDate.setDate(1); | |||
memo.axisMaxDate = new Date( memo.obsMaxCompDateMs ); | |||
memo.axisMaxDate.setMonth( memo.axisMaxDate.getMonth()+1 ); | |||
memo.axisMaxDate.setDate(0); | |||
memo.seasonsO = {}; | |||
memo.seasonsA = []; | |||
for (var o in memo.obsesA) { | |||
s = memo.obsesA[o].seriesId; | |||
if (typeof memo.seasonsO[s] == 'undefined' ) { memo.seasonsO[s] = { 'obses': [] }; } | |||
memo.seasonsO[s].obses.push( memo.obsesA[o] ); | |||
} | |||
for (var o in memo.seasonsO) { memo.seasonsA.push(o); } memo.seasonsA.sort( function(a,b) { return b-a; } ); | |||
// create cols for each series | |||
var sc = 0; | |||
for (var s in memo.seasonsA) { | |||
// data | |||
if ( memo.season == 'summer' ) { | |||
memo.data.addColumn( 'number', memo.seasonsA[s].toString() ); | |||
} else { | |||
memo.data.addColumn( 'number', memo.seasonsA[s].toString() + '-' + (parseInt(memo.seasonsA[s])+1).toString() ); | |||
} | |||
// style | |||
memo.data.addColumn( { type: 'string', role: 'style' } ); | |||
// tooltip | |||
memo.data.addColumn( { type: 'string', role: 'tooltip', 'p': { 'html': true } } ); | |||
// annotation | |||
memo.data.addColumn( { type: 'string', role: 'annotation' } ); | |||
// add to series | |||
if ( memo.seasonsA[s] == memo.curSeason ) { | |||
if ( memo.type == 'cat' ) { | |||
memo.options.series[sc++] = { type: 'scatter', curveType: 'function', color: colors['curObses'], XpointSize: 3, lineWidth: 0, visibleInLegend: true, hideThis: false, origSize: 10 }; | |||
} else { | |||
memo.options.series[sc++] = { type: 'scatter', curveType: 'function', color: colors['curObses'], XpointSize: 3, lineWidth: 4, visibleInLegend: true, hideThis: false, origSize: 10 }; | |||
} | |||
} else { | |||
memo.options.series[sc++] = { type: 'scatter', curveType: 'function', color: colors['obses'], XpointSize: 5, lineWidth: 0, visibleInLegend: false, hideThis: true, origSize: 5 }; | |||
} | |||
} | |||
// legend entry for timespan | |||
memo.data.addColumn( 'number', memo.obsMinDate.getFullYear() + '-' + memo.obsMaxDate.getFullYear() ); | |||
memo.options.series[sc++] = { type: 'scatter', color: colors['obses'], pointSize: 5, visibleInLegend: true, hideThis: false }; | |||
// add data to table | |||
cc = memo.data.getNumberOfColumns(); | |||
for (var s in memo.seasonsA) { | |||
for (var o in memo.seasonsO[memo.seasonsA[s]].obses) { | |||
obs = memo.seasonsO[memo.seasonsA[s]].obses[o]; | |||
dataRow = []; | |||
// fill row with nulls | |||
for (var i=0; i<cc; i++) { dataRow.push( null ); } | |||
// x axis value | |||
dataRow[0] = obs.compareDate; | |||
// data for series cols | |||
if ( memo.seasonsA[s] == memo.curSeason ) { | |||
dataRow[s*4+1] = obs.value; | |||
} else { | |||
dataRow[s*4+1] = obs.value + memo.distF*Math.random() - memo.distF*Math.random(); | |||
} | |||
dataRow[s*4+2] = obs.style; | |||
dataRow[s*4+3] = obs.popup; | |||
dataRow[s*4+4] = null; //annotation | |||
memo.dataA.push( dataRow ); | |||
} | |||
} | |||
drawChart(memo); | |||
} | |||
function XaddDataToSeasonChart(memo) { | |||
memo.axisMinDate = new Date( memo.obsMinCompDateMs ); | memo.axisMinDate = new Date( memo.obsMinCompDateMs ); | ||


