Ero sivun ”Widget:JwObsCharts” versioiden välillä
Järvi-meriwikistä
Rivi 352: | Rivi 352: | ||
memo.jwR.loadObses( { "obscode": memo.refcode, "siteid": memo.siteid, "sort": "SiteID", "custom": memo.reffilter }, function( r ) { | memo.jwR.loadObses( { "obscode": memo.refcode, "siteid": memo.siteid, "sort": "SiteID", "custom": memo.reffilter }, function( r ) { | ||
memo.refs = memo.jwR.obs; | memo.refs = memo.jwR.obs; | ||
+ | console.log( memo.obses ); | ||
+ | console.log( memo.refs ); | ||
drawVisualization(memo); | drawVisualization(memo); | ||
}); | }); | ||
Rivi 547: | Rivi 549: | ||
baseSize = 2; | baseSize = 2; | ||
} | } | ||
− | |||
− | |||
if ( memo.maintainerShow ) { maintcol = maintColors[obs.maintainer]; } | if ( memo.maintainerShow ) { maintcol = maintColors[obs.maintainer]; } | ||
Rivi 614: | Rivi 614: | ||
addDataToTrendChart(memo); | addDataToTrendChart(memo); | ||
+ | |||
+ | } else if (memo.graphType == 'seasonwithreferences') { | ||
+ | |||
+ | addDataToSeasonWithReferencesChart(memo); | ||
} else if (memo.graphType == 'trendwithhighlow') { | } else if (memo.graphType == 'trendwithhighlow') { | ||
Rivi 1 054: | Rivi 1 058: | ||
} | } | ||
+ | function addDataToSeasonWithReferencesChart(memo) { | ||
+ | |||
+ | // do axis min and max | ||
+ | memo.axisMinDate = new Date( memo.curSeason, 0, 1 ); | ||
+ | memo.axisMaxDate = new Date( memo.curSeason, 11, 31 ); | ||
+ | |||
+ | memo.data.addColumn( 'number', memo.obsMinYear + '-' + memo.obsMaxYear ); | ||
+ | memo.data.addColumn( { id:'i0', type:'number', role:'interval' } ); | ||
+ | memo.data.addColumn( { id:'i0', type:'number', role:'interval' } ); | ||
+ | memo.data.addColumn( {'type': 'string', 'role': 'style' } ); | ||
+ | memo.data.addColumn( { type: 'string', role: 'annotation' } ); | ||
+ | memo.data.addColumn( { type: 'string', role: 'tooltip', 'p': { 'html': true } } ); | ||
+ | |||
+ | // series for trend line | ||
+ | //memo.options.trendlines[0] = { labelInLegend: i18n['trendline'][memo.lang], tooltip: false, color: colors['trend'], lineWidth: 2, opacity: 0.5, type: 'linear', visibleInLegend: memo.trendType!='moving' }; | ||
+ | |||
+ | for (var o in memo.obsesA) { | ||
+ | dateStr = memo.obsesA[o].popup.match( /\([^)]*\)/g ); | ||
+ | yearStr = dateStr[0].match( /[0-9]{4}/g ); | ||
+ | memo.obsesA[o].popup = memo.obsesA[o].popup.replace( dateStr[0], '(' + yearStr[0] + ')' ); | ||
+ | memo.dataA.push( [ | ||
+ | memo.obsesA[o].obsdatetime, | ||
+ | memo.obsesA[o].value, | ||
+ | memo.obsesA[o].data.low/100, | ||
+ | memo.obsesA[o].data.high/100, | ||
+ | memo.obsesA[o].style, | ||
+ | null, | ||
+ | memo.obsesA[o].popup | ||
+ | ] ); | ||
+ | } | ||
+ | |||
+ | memo.options.hAxis.ticks = []; | ||
+ | for (i=memo.axisMinDate.getFullYear(); i<=memo.axisMaxDate.getFullYear(); i++) { | ||
+ | middleOfYear = new Date( i, 6, 1 ); | ||
+ | memo.options.hAxis.ticks.push({v: middleOfYear, f: String(i) }); | ||
+ | } | ||
+ | |||
+ | memo.options.seriesType = 'line'; | ||
+ | memo.options.series[0] = { type: 'line', pointSize: 3, color: '#3366cc' }; | ||
+ | memo.options.curveType = 'function'; | ||
+ | memo.options.intervals = { 'style': 'area' }; | ||
+ | |||
+ | memo.options.vAxis.viewWindow.min = 80; | ||
+ | memo.options.vAxis.viewWindow.max = 82; | ||
+ | |||
+ | memo.chart = new google.visualization.LineChart( memo.chartEl[0] ); // document.getElementById(memo.id) | ||
+ | |||
+ | drawChart(memo); | ||
+ | } | ||
+ | |||
function addDataToTrendWithHighLowChart (memo) { | function addDataToTrendWithHighLowChart (memo) { | ||