(Ak: Uusi sivu: <includeonly> <script type="text/javascript"> (function() { // globals var today = new Date(); function <!--{$id|default:TheGraph|escape:'html'}-->_jQueryTest() {...) |
Ei muokkausyhteenvetoa |
||
| Rivi 87: | Rivi 87: | ||
function drawVisualization(memo) { | function drawVisualization(memo) { | ||
console.log( memo ); | |||
// margin settings | // margin settings | ||
| Rivi 147: | Rivi 147: | ||
for (var o in memo.obses) { | for (var o in memo.obses) { | ||
obs = memo. | obs = memo.jw.obs[o]; | ||
memo.obsesTotal++; | memo.obsesTotal++; | ||
memo.obsMinValue = Math.min( memo.obsMinValue, | memo.obsMinValue = Math.min( memo.obsMinValue, obs.value ); | ||
memo.obsMaxValue = Math.max( memo.obsMaxValue, | memo.obsMaxValue = Math.max( memo.obsMaxValue, obs.value ); | ||
memo.obsMinDateMs = Math.min( memo.obsMinDateMs, | memo.obsMinDateMs = Math.min( memo.obsMinDateMs, obs.datetime.getTime() ); | ||
memo.obsMaxDateMs = Math.max( memo.obsMaxDateMs, | memo.obsMaxDateMs = Math.max( memo.obsMaxDateMs, obs.datetime.getTime() ); | ||
// add compare date to obses | // add compare date to obses | ||
if ( memo.season == 'summer' || obs.datetime.getMonth() > 7 ) { | if ( memo.season == 'summer' || obs.datetime.getMonth() > 7 ) { | ||
obs.compareDate = new Date( memo.curSeason, obs. | obs.compareDate = new Date( memo.curSeason, obs.obsdatetime.getMonth(), obs.obsdatetime.getDate() ); | ||
} else { | } else { | ||
obs.compareDate = new Date( memo.curSeason+1, obs. | obs.compareDate = new Date( memo.curSeason+1, obs.obsdatetime.getMonth(), obs.obsdatetime.getDate() ); | ||
} | } | ||
ms = obs.compareDate.getTime(); | ms = obs.compareDate.getTime(); | ||
| Rivi 169: | Rivi 169: | ||
// add series id | // add series id | ||
if ( memo.graphType == 'trend' ) { | if ( memo.graphType == 'trend' ) { | ||
obs.seriesId = 0; | |||
} else if ( memo.season == 'summer' || | } else if ( memo.season == 'summer' || obs.obsdatetime.getMonth() > 7 ) { | ||
obs.seriesId = obs.obsdatetime.getFullYear(); | |||
} else { | } else { | ||
obs.seriesId = obs.obsdatetime.getFullYear()-1; | |||
} | } | ||
// create popup for obs | // create popup for obs | ||
obs.popup = '<div style="padding: 8px;">'; | |||
obs.popup += '<div>'; | |||
if ( i18n[memo.obscode]['type'] == 'cat') { | if ( i18n[memo.obscode]['type'] == 'cat') { | ||
obs.popup +='<b>' + i18n[memo.obscode]['title'][memo.lang] + ': ' + i18n[memo.obscode]['catNames'][obs.value][memo.lang] + '</b> '; | |||
} else if ( i18n[memo.obscode]['type'] == 'date') { | } else if ( i18n[memo.obscode]['type'] == 'date') { | ||
obs.popup +='<b>' + i18n[memo.obscode]['title'][memo.lang] + '</b> '; | |||
} else { | } else { | ||
obs.popup +='<b>' + i18n[memo.obscode]['title'][memo.lang] + ': ' + (Math.round(obs.value * 10)/10).toString().replace( '.', i18n['dec'][memo.lang] ) + ' ' + i18n[memo.obscode]['unit'] + '</b> '; | |||
} | } | ||
obs.popup += '(' + obs.datetime.inRelationToToday(memo.lang) + ')'; | |||
obs.popup += '</div>'; | |||
if (!! | if (!!obs.addInfo) { obs.popup += '<div style="margin-top: 5px;">' + obs.addInfo + '</div>'; } | ||
obs.popup += '</div>'; | |||
} | } | ||
| Rivi 205: | Rivi 205: | ||
memo.obsesA = []; memo.dataA = []; | memo.obsesA = []; memo.dataA = []; | ||
for (var o in memo. | for ( var o in memo.jw.obs ) { | ||
obs = memo.jw.obs[o]; | |||
// style points | // style points | ||
if ( | if ( obs.seriesId == memo.curSeason ) { | ||
baseSize = 6; | baseSize = 6; | ||
} else if (memo.obsesTotal < 100) { | } else if (memo.obsesTotal < 100) { | ||
| Rivi 221: | Rivi 224: | ||
//if ( memo.graphType == 'dateofyear' ) { baseSize = baseSize + 1; } | //if ( memo.graphType == 'dateofyear' ) { baseSize = baseSize + 1; } | ||
if (!! | if (!!obs.addInfo) { | ||
// | //obs.style = 'point { shape-type: star; size: ' + (baseSize+3) + '; shape-dent: 0.5; fill-color: ' + colors['noticeObses'] + '; stroke-width: 0; stroke-color: ' + maintColors[obs.maintainer] + '; }'; | ||
// | //obs.style = 'point { size: ' + (baseSize+1) + '; stroke-width: 2; stroke-color: gold; }'; | ||
obs.style = 'point { size: ' + (baseSize+1) + '; stroke-width: 3; stroke-color: ' + maintColors[obs.maintainer] + '; }'; | |||
} else { | } else { | ||
obs.style = 'point { size: ' + baseSize + '; stroke-width: 0.5; stroke-color: ' + maintColors[obs.maintainer] + '; }'; | |||
} | } | ||
memo.obsesA.push( | memo.obsesA.push( obs ); | ||
} | } | ||
// sort | // sort | ||
memo.obsesA.sort( function(a, b) { return a. | memo.obsesA.sort( function(a, b) { return a.obsdatetime - b.obsdatetime; }); | ||
// create DataTable | // create DataTable | ||


