Ei muokkausyhteenvetoa |
Ei muokkausyhteenvetoa |
||
| (48 välissä olevaa versiota samalta käyttäjältä ei näytetä) | |||
| Rivi 85: | Rivi 85: | ||
memo.caption = jQuery( this ).attr( 'data-caption' ); if ( typeof memo.caption == 'undefined' ) { memo.caption = ""; } | memo.caption = jQuery( this ).attr( 'data-caption' ); if ( typeof memo.caption == 'undefined' ) { memo.caption = ""; } | ||
if ( typeof jQuery( this ).attr( 'data-jw-summerwinter' ) != 'undefined' ) { memo.summerwinter = ( jQuery( this ).attr( 'data-jw-summerwinter' ) == 'true' ); } else { memo.summerwinter = false; }; | if ( typeof jQuery( this ).attr( 'data-jw-summerwinter' ) != 'undefined' ) { memo.summerwinter = ( jQuery( this ).attr( 'data-jw-summerwinter' ) == 'true' ); } else { memo.summerwinter = false; }; | ||
if ( typeof jQuery( this ).attr( 'data-jw-summerother' ) != 'undefined' ) { memo.summerother = ( jQuery( this ).attr( 'data-jw-summerother' ) == 'true' ); } else { memo.summerother = false; }; | |||
if ( typeof jQuery( this ).attr( 'data-jw-bottomsurface' ) != 'undefined' ) { memo.bottomsurface = ( jQuery( this ).attr( 'data-jw-bottomsurface' ) == 'true' ); } else { memo.bottomsurface = false; }; | |||
if ( typeof jQuery( this ).attr( 'data-jw-divide' ) != 'undefined' ) { | |||
memo.divide = jQuery( this ).attr( 'data-jw-divide' ); | |||
} else if ( memo.bottomsurface ) { | |||
memo.divide = 'bottomsurface'; | |||
} else if ( memo.summerwinter ) { | |||
memo.divide = 'summerwinter'; | |||
} else if ( memo.summerother ) { | |||
memo.divide = 'summerother'; | |||
} else { | |||
memo.divide = '-'; | |||
}; | |||
if ( typeof jQuery( this ).attr( 'data-jw-divide-if-obses' ) != 'undefined' ) { | |||
memo.divideCond = parseInt( jQuery( this ).attr( 'data-jw-divide-if-obses' ) ); | |||
} else { | |||
memo.divideCond = 20; | |||
}; | |||
if ( typeof jQuery( this ).attr( 'data-showlink' ) == 'undefined' ) { | if ( typeof jQuery( this ).attr( 'data-showlink' ) == 'undefined' ) { | ||
| Rivi 102: | Rivi 122: | ||
memo.startDate = '1800-01-01'; | memo.startDate = '1800-01-01'; | ||
} | } | ||
memo.service = jQuery( this ).attr( 'data-coo311-service_code' ); | memo.service = jQuery( this ).attr( 'data-coo311-service_code' ); | ||
| Rivi 125: | Rivi 144: | ||
// add chart container | // add chart container | ||
memo.widgetEl.append( '<div class="card JwCard mb-2" style="position: relative; width: 100%; height: 100%;"><div class="card-header" style="min-height: 49px;"></div><div class="card-body p-2" style="position: relative; width: 100%; height: 100%;"><div class="chart-container" style="position: relative; z-index: 110; width: 100%; height: 100%;"></div></div><div class="card-footer"></div>' ); | memo.widgetEl.append( '<div class="card JwCard mb-2" style="position: relative; width: 100%; height: 100%;"><div class="card-header" style="min-height: 49px;"></div><div id="' + memo.id + '_collapsible" class="card-body p-2 collapse" style="position: relative; width: 100%; height: 100%;"><div class="chart-container" style="position: relative; z-index: 110; width: 100%; height: 100%;"></div></div><div class="card-footer"></div>' ); | ||
memo.chartEl = jQuery( this ).find( '.chart-container' ); | memo.chartEl = jQuery( this ).find( '.chart-container' ); | ||
memo.chartEl.css( 'height', memo.height + 'px' ); | memo.chartEl.css( 'height', memo.height + 'px' ); | ||
| Rivi 132: | Rivi 151: | ||
// add title | // add title | ||
memo.headerEl.append( '<div class="obscharttitle" style="float: left;"></div>' ); | memo.headerEl.append( '<a class="card-link" data-toggle="collapse" aria-expanded="false" href="#' + memo.id + '_collapsible' + '"><div class="obscharttitle" style="float: left;"></div></a>' ); | ||
memo.titleEl = jQuery( this ).find( '.obscharttitle' ); | memo.titleEl = jQuery( this ).find( '.obscharttitle' ); | ||
// add or hide footer | // add or hide footer | ||
| Rivi 143: | Rivi 162: | ||
// add fullscreen button | // add fullscreen button | ||
memo.headerEl.append( '<div class="obschartbutton fullscreen-button" style="display: none; margin-left: 10px; float: right; | memo.headerEl.append( '<div class="obschartbutton fullscreen-button" style="display: none; margin-left: 10px; float: right; font-size: 18.72px;"><button title="' + i18n['fullscreen'][memo.lang] + '" style=""><i class="fas fa-expand"></i></button></div>' ); | ||
memo.fullscreenEl = jQuery( this ).find( '.fullscreen-button' ); | memo.fullscreenEl = jQuery( this ).find( '.fullscreen-button' ); | ||
| Rivi 184: | Rivi 203: | ||
// add edit button | // add edit button | ||
if ( memo.editUrl != '-' ) { | if ( memo.editUrl != '-' ) { | ||
memo.headerEl.append( '<div class="obschartbutton edit-button" style=" | memo.headerEl.append( '<div class="obschartbutton edit-button" style="display: none; margin-left: 10px; float: right; font-size: 18.72px;"><button title="' + i18n['edit'][memo.lang] + '" style=""><i class="fas fa-edit"></i></button></div>' ); | ||
memo.editEl = jQuery( this ).find( '.edit-button' ); | memo.editEl = jQuery( this ).find( '.edit-button' ); | ||
memo.editEl.on( 'click', function() { window.location.href = memo.editUrl; }); | memo.editEl.on( 'click', function() { window.location.href = memo.editUrl; }); | ||
| Rivi 191: | Rivi 210: | ||
// add download data button | // add download data button | ||
if ( memo.download ) { | if ( memo.download ) { | ||
memo.headerEl.append( '<div class="obschartbutton download-button" style="display: none; margin-left: 10px; float: right; | memo.headerEl.append( '<div class="obschartbutton download-button" style="display: none; margin-left: 10px; float: right; font-size: 18.72px;"><button title="' + i18n['download'][memo.lang] + '" style=""><i class="fas fa-download"></i></button></div>' ); | ||
memo.downloadEl = jQuery( this ).find( '.download-button' ); | memo.downloadEl = jQuery( this ).find( '.download-button' ); | ||
| Rivi 206: | Rivi 225: | ||
if ( i18n[memo.obscode].type == 'num' ) { | if ( i18n[memo.obscode].type == 'num' ) { | ||
headerCols.push( '"' + i18n[memo.obscode].axisTitleV[memo.lang] + '"' ); | headerCols.push( '"' + i18n[memo.obscode].axisTitleV[memo.lang] + '"' ); | ||
headerCols.push( 'Lisätiedot' ); | headerCols.push( 'Lisätiedot' ); | ||
| Rivi 334: | Rivi 351: | ||
// add show site link button | // add show site link button | ||
if ( memo.showlink ) { | if ( memo.showlink ) { | ||
memo.headerEl.append( '<div class="obschartbutton sitelink-button" style="display: none; margin-left: 10px; float: right; | memo.headerEl.append( '<div class="obschartbutton sitelink-button" style="display: none; margin-left: 10px; float: right; font-size:18.72px;"><button title="' + i18n['sitelink'][memo.lang] + '" style="width: 24px; height: 24px; padding: 0; margin: 0; background: none; border: none; "><i class="fas fa-map-marked"></i></button></div>' ); | ||
memo.sitelinkEl = jQuery( this ).find( '.sitelink-button' ); | memo.sitelinkEl = jQuery( this ).find( '.sitelink-button' ); | ||
memo.sitelinkEl.on( 'click', function() { | memo.sitelinkEl.on( 'click', function() { | ||
| Rivi 342: | Rivi 359: | ||
} | } | ||
} | } | ||
memo.loadStarts = 0; | memo.loadStarts = 0; | ||
| Rivi 381: | Rivi 398: | ||
so.waterbody = memo.waterbody; | so.waterbody = memo.waterbody; | ||
} | } | ||
if ( memo.siteid == '170072' ) { | |||
so.test = true; | |||
} | |||
memo.jw.loadObses( so, function( o ) { | memo.jw.loadObses( so, function( o ) { | ||
| Rivi 399: | Rivi 420: | ||
} | } | ||
function drawVisualization( memo ) { | function drawVisualization( memo ) { | ||
if ( typeof i18n[ memo.obscode ].direction != 'undefined' ) { memo.vaxisdir = i18n[ memo.obscode ].direction; } else { memo.vaxisdir = 1; } | if ( typeof i18n[ memo.obscode ].direction != 'undefined' ) { memo.vaxisdir = i18n[ memo.obscode ].direction; } else { memo.vaxisdir = 1; } | ||
| Rivi 405: | Rivi 426: | ||
memo.options = { | memo.options = { | ||
backgroundColor: 'transparent', | backgroundColor: 'transparent', | ||
chartArea: { backgroundColor: { fill: '#ffffff', stroke: ' | chartArea: { backgroundColor: { fill: '#ffffff', stroke: colors['gridlines'], strokeWidth: 1 } }, | ||
legend: { position: 'bottom', textStyle: { color: colors['text'] } }, | legend: { position: 'bottom', textStyle: { color: colors['text'] } }, | ||
crosshair: { trigger: 'both' }, | crosshair: { trigger: 'both' }, | ||
| Rivi 416: | Rivi 437: | ||
textStyle: { color: colors['text'] }, | textStyle: { color: colors['text'] }, | ||
slantedText: false, | slantedText: false, | ||
maxAlternation: 1, | maxAlternation: 1, | ||
direction: memo.vaxisdir, | direction: memo.vaxisdir, | ||
baselineColor: colors[ 'text' ], | baselineColor: colors[ 'text' ], | ||
gridlines: { color: colors[ 'gridlines' ], | gridlines: { color: colors[ 'gridlines' ], Xcount: -1 }, | ||
minorGridlines: { count: 0 }, | minorGridlines: { count: 0 }, | ||
viewWindow: { } | viewWindow: { } | ||
| Rivi 523: | Rivi 544: | ||
// add series id | // add series id | ||
if ( memo.graphType == 'trend' ) { | if ( memo.graphType == 'trend' ) { | ||
if ( memo. | if ( memo.divide == 'summerwinter' ) { | ||
if ( obs.compareDate.getMonth() > 4 && obs.compareDate.getMonth() < 9 ) { | if ( obs.compareDate.getMonth() > 4 && obs.compareDate.getMonth() < 9 ) { | ||
obs.seriesId = 'summer'; | obs.seriesId = 'summer'; | ||
| Rivi 536: | Rivi 552: | ||
obs.seriesId = 'other'; | obs.seriesId = 'other'; | ||
} | } | ||
} else if ( memo.divide == 'summerother' ) { | |||
if ( obs.compareDate.getMonth() > 4 && obs.compareDate.getMonth() < 9 ) { | |||
obs.seriesId = 'summer'; | |||
} else { | |||
obs.seriesId = 'other'; | |||
} | |||
} else if ( memo.divide == 'bottomsurface' ) { | |||
if ( obs.data.depthR == 'bottom' ) { | |||
obs.seriesId = 'bottom'; | |||
} else if ( obs.data.depthR == 'surface' ) { | |||
obs.seriesId = 'surface'; | |||
} else { | |||
obs.seriesId = 'other'; | |||
} | |||
} else { | } else { | ||
obs.seriesId = 0; | obs.seriesId = 0; | ||
| Rivi 577: | Rivi 606: | ||
memo.obsMaxCompDate = new Date( memo.obsMaxCompDateMs ); | memo.obsMaxCompDate = new Date( memo.obsMaxCompDateMs ); | ||
memo.obsesA = []; memo.dataA = []; | memo.obsesA = []; memo.dataA = []; memo.depthsO = {}; | ||
for ( var o in memo.obses ) { | for ( var o in memo.obses ) { | ||
| Rivi 608: | Rivi 637: | ||
memo.obsesA.push( obs ); | memo.obsesA.push( obs ); | ||
if ( typeof obs.data.depthR != 'undefined' ) { | |||
if ( typeof memo.depthsO[ obs.data.depthR ] == 'undefined' ) { memo.depthsO[ obs.data.depthR ] = { 'values': [], 'valstrings': [], 'valstring': '' }; } | |||
if ( typeof obs.data.depthAval != 'undefined' ) { | |||
if ( obs.data.depthAval!==null && obs.data.depthAval != '' ) { | |||
memo.depthsO[ obs.data.depthR ].values.push( obs.data.depthAval ); | |||
} | |||
} else { | |||
//memo.depthsO[ obs.data.depthR ].values.push( -1 ); | |||
} | |||
} | |||
} | } | ||
| Rivi 619: | Rivi 659: | ||
// col for xAxis values | // col for xAxis values | ||
memo.data.addColumn( 'date', 'time' ); | memo.data.addColumn( 'date', 'time' ); | ||
// make ticks for y axis on cat types | // | ||
if ( memo.obsesA.length > 0 && memo.graphType != 'current' ) { | var depthcats = []; var depthvals; | ||
for ( var di in memo.depthsO ) { | |||
memo.depthsO[ di ].values = [...new Set( memo.depthsO[ di ].values )].sort((a, b) => a - b); | |||
for ( var dv in memo.depthsO[ di ].values ) { | |||
memo.depthsO[ di ]['valstrings'].push( memo.depthsO[ di ].values[ dv ].toString().replace( '.', ',' ) ); | |||
} | |||
if ( memo.depthsO[ di ]['valstrings'].length > 0 ) { | |||
if ( memo.depthsO[ di ]['valstrings'].length == 1 ) { | |||
memo.depthsO[ di ]['valstring'] = memo.depthsO[ di ]['valstrings'][ 0 ] + ' m'; | |||
} else { | |||
memo.depthsO[ di ]['valstring'] = memo.depthsO[ di ]['valstrings'][ 0 ] + '–' + memo.depthsO[ di ]['valstrings'][ memo.depthsO[ di ]['valstrings'].length-1 ] + ' m'; | |||
} | |||
} | |||
depthcats.push( di ); | |||
} | |||
if ( depthcats.length == 1 ) { | |||
if ( depthcats[0] == 'surface' ) { | |||
memo.title = memo.title.replace( '–', '(' + i18n[ 'surface' ][ memo.lang ] + ') –' ); | |||
} else if ( depthcats[0] == 'bottom' ) { | |||
memo.title = memo.title.replace( '–', '(' + i18n[ 'bottom' ][ memo.lang ] + ') –' ); | |||
} | |||
} else if ( depthcats.length == 2 ) { | |||
} else { | |||
} | |||
// make ticks for y axis on cat types | |||
if ( memo.obsesA.length > 0 && memo.graphType != 'current' ) { | |||
if ( i18n[memo.obscode]['type'] == 'cat') { | if ( i18n[memo.obscode]['type'] == 'cat') { | ||
memo.options.vAxis.format = '0'; | |||
memo.options.vAxis.ticks = []; | memo.options.vAxis.ticks = []; | ||
for (var c in i18n[memo.obscode]['catNamesShort']) { | for (var c in i18n[memo.obscode]['catNamesShort']) { | ||
| Rivi 631: | Rivi 708: | ||
memo.options.vAxis.ticks.sort( function(a, b) { return a.v-b.v } ); | memo.options.vAxis.ticks.sort( function(a, b) { return a.v-b.v } ); | ||
memo.options.vAxis.viewWindow.min = -0.5; | memo.options.vAxis.viewWindow.min = -0.5; | ||
//memo.options.vAxis.minValue = -0.5; | |||
memo.options.vAxis.viewWindow.max = parseInt(memo.options.vAxis.ticks[memo.options.vAxis.ticks.length-1].v)+0.5; | memo.options.vAxis.viewWindow.max = parseInt(memo.options.vAxis.ticks[memo.options.vAxis.ticks.length-1].v)+0.5; | ||
memo.options.vAxis.gridlines.color = ' | //memo.options.vAxis.viewWindow.max = memo.options.vAxis.viewWindow.max; | ||
memo.options.vAxis.gridlines.color = colors['gridlines']; | |||
memo.options.vAxis.baselineColor = colors['text']; | |||
} else { | } else { | ||
| Rivi 639: | Rivi 718: | ||
if ( i18n[memo.obscode]['min'] != -999 ) { | if ( i18n[memo.obscode]['min'] != -999 ) { | ||
memo.options.vAxis.viewWindow.min = i18n[memo.obscode]['min']; | memo.options.vAxis.viewWindow.min = i18n[memo.obscode]['min']; | ||
} | |||
} else if ( memo.obsMinValue >= 0) { | |||
if ( memo.obscode != 'level' && memo.obscode != 'pH' ) { | |||
memo.options.vAxis.viewWindow.min = 0; | |||
} else { | |||
memo.options.vAxis.viewWindow.min = memo.obsMinValue; | |||
} | } | ||
} else | } else { | ||
// | // | ||
} | } | ||
| Rivi 649: | Rivi 733: | ||
memo.options.vAxis.viewWindow.max = i18n[memo.obscode]['max']; | memo.options.vAxis.viewWindow.max = i18n[memo.obscode]['max']; | ||
} | } | ||
} | } | ||
} | } | ||
memo.titleEl.html( memo.title ); | memo.titleEl.html( memo.title ); | ||
if ( typeof i18n[ memo.obscode ].changes != 'undefined' ) { | if ( typeof i18n[ memo.obscode ].changes != 'undefined' ) { | ||
| Rivi 665: | Rivi 744: | ||
} | } | ||
} | } | ||
if ( memo.info == '' ) { | |||
if ( memo.siteid != '-' ) { | |||
memo.info += i18n[ 'siteinfostring' ][ memo.lang] + ': ' + memo.jw.site[ memo.siteid ].name; | |||
} | |||
if ( depthcats.length == 1 ) { | |||
if ( memo.depthsO[ depthcats[0] ].valstring != '' ) { | |||
if ( memo.info != '' ) { memo.info += "<br />"; } | |||
memo.info += i18n[ 'depthinfostring' ][ memo.lang] + ': ' + memo.depthsO[ depthcats[0] ].valstring; | |||
} | |||
} | |||
} | |||
if ( memo.info != '' ) { | if ( memo.info != '' ) { | ||
memo.titleEl.append( ' <button style="padding: 0 0.25em; font-size: 13px; margin-bottom: 3px;" type="button" class="btn btn-secondary btn-info" data-toggle="tooltip" data-placement="top" title="' + memo.info + '"><span class="fontawesome"></span></button>' ); | memo.titleEl.append( ' <button style="padding: 0 0.25em; font-size: 13px; margin-bottom: 3px;" type="button" class="btn btn-secondary btn-info" data-toggle="tooltip" data-placement="top" data-html="true" title="' + memo.info + '"><span class="fontawesome"></span></button>' ); | ||
jQuery( '[data-toggle="tooltip"]' ).tooltip(); | jQuery( '[data-toggle="tooltip"]' ).tooltip(); | ||
} | } | ||
| Rivi 673: | Rivi 766: | ||
} | } | ||
if (memo.graphType == 'trend') { | if ( memo.obsesA.length == 0 ) { | ||
console.log( 'No obses' ); | |||
} else if (memo.graphType == 'trend') { | |||
addDataToTrendChart(memo); | addDataToTrendChart(memo); | ||
| Rivi 714: | Rivi 811: | ||
// do Y axis min and max for this chart type | // do Y axis min and max for this chart type | ||
memo.options.vAxis. | memo.options.vAxis.viewWindow.min = new Date( memo.obsMinCompDate.getTime() ); | ||
memo.options.vAxis. | memo.options.vAxis.viewWindow.min.setDate(1); | ||
memo.options.vAxis.viewWindow.min | memo.options.vAxis.viewWindow.min.setHours( 0, 0, 0 ); | ||
memo.options.vAxis. | memo.options.vAxis.viewWindow.max = new Date( memo.obsMaxCompDate.getTime() ); | ||
memo.options.vAxis. | memo.options.vAxis.viewWindow.max.setMonth( memo.options.vAxis.viewWindow.max.getMonth()+1 ); | ||
memo.options.vAxis. | memo.options.vAxis.viewWindow.max.setDate(0); | ||
memo.options.vAxis.viewWindow.max | memo.options.vAxis.viewWindow.max.setHours( 0, 0, 0 ); | ||
// do Y axis ticks and gridlines | // do Y axis ticks and gridlines | ||
| Rivi 728: | Rivi 825: | ||
memo.options.vAxis.gridlines = { color: 'transparent' }; | memo.options.vAxis.gridlines = { color: 'transparent' }; | ||
memo.options.vAxis.minorGridlines = { color: 'transparent' }; | memo.options.vAxis.minorGridlines = { color: 'transparent' }; | ||
minM = memo.options.vAxis. | minM = memo.options.vAxis.viewWindow.min.getMonth(); | ||
maxM = memo.options.vAxis. | maxM = memo.options.vAxis.viewWindow.max.getMonth(); | ||
if ( minM > maxM ) { mc = 13-minM+maxM; } | if ( minM > maxM ) { mc = 13-minM+maxM; } | ||
| Rivi 737: | Rivi 834: | ||
mx = minM+mi; | mx = minM+mi; | ||
yx = memo.options.vAxis. | yx = memo.options.vAxis.viewWindow.min.getFullYear(); | ||
if ( mx > 11 ) { yx = memo.options.vAxis. | if ( mx > 11 ) { yx = memo.options.vAxis.viewWindow.max.getFullYear(); mx = mx - 12; } | ||
startOfMonth = new Date( yx, mx, 1 ); | startOfMonth = new Date( yx, mx, 1 ); | ||
| Rivi 810: | Rivi 907: | ||
memo.data.addColumn( { type: 'string', role: 'annotation' } ); | memo.data.addColumn( { type: 'string', role: 'annotation' } ); | ||
memo.options.series.push( { type: 'scatter', pointType: 'circle', pointSize: 10, color: memo.seriesA[ s ].color | memo.options.series.push( { type: 'scatter', pointType: 'circle', pointSize: 10, color: memo.seriesA[ s ].color } ); | ||
if ( memo.seriesA[ s ].obses.length > | if ( memo.seriesA[ s ].obses.length > 4 ) { | ||
memo.options.trendlines[ memo.options.series.length - 1 ] = { type: 'linear', title: i18n.trendline, lineWidth: | memo.options.trendlines[ memo.options.series.length - 1 ] = { type: 'linear', title: i18n.trendline, lineWidth: 3, visibleInLegend: false, tooltip: false }; | ||
} else { | } else { | ||
memo.options.trendlines[ memo.options.series.length - 1 ] = { type: 'linear', title: i18n.trendline, lineWidth: 0, color: 'transparent', visibleInLegend: false, tooltip: false }; | memo.options.trendlines[ memo.options.series.length - 1 ] = { type: 'linear', title: i18n.trendline, lineWidth: 0, color: 'transparent', visibleInLegend: false, tooltip: false }; | ||
| Rivi 896: | Rivi 993: | ||
} | } | ||
} | } | ||
memo.options.hAxis.gridlines.color = ' | memo.options.hAxis.gridlines.color = 'transparent'; | ||
memo.options.vAxis.gridlines.color = '#cccccc'; | memo.options.vAxis.gridlines.color = '#cccccc'; | ||
| Rivi 1 045: | Rivi 1 142: | ||
memo.axisMinDate.setDate(1); | memo.axisMinDate.setDate(1); | ||
memo.axisMaxDate.setDate(31); | memo.axisMaxDate.setDate(31); | ||
if ( memo.obsesA.length < memo.divideCond ) { memo.divide = '-'; } | |||
if ( memo.summerwinter ) { | if ( memo.divide == 'summerwinter' ) { | ||
memo.options.series[0] = { type: 'scatter', pointSize: 10, color: colors[ 'spring-autumn' ] }; | memo.options.series[0] = { type: 'scatter', pointSize: 10, color: colors[ 'spring-autumn' ] }; | ||
| Rivi 1 067: | Rivi 1 166: | ||
memo.data.addColumn( { type: 'string', role: 'tooltip', 'p': { 'html': true } } ); | memo.data.addColumn( { type: 'string', role: 'tooltip', 'p': { 'html': true } } ); | ||
} else { | } else if ( memo.divide == 'summerother' ) { | ||
memo.options.series[0] = { type: 'scatter', pointSize: 10, color: colors[ ' | memo.options.series[0] = { type: 'scatter', pointSize: 10, color: colors[ 'spring-autumn' ] }; | ||
memo.options.series[1] = { type: 'scatter', pointSize: 10, color: colors[ 'summer' ] }; | |||
memo.data.addColumn( 'number', | memo.data.addColumn( 'number', 'Muu vuodenaika' ); | ||
memo.data.addColumn( {'type': 'string', 'role': 'style' } ); | memo.data.addColumn( {'type': 'string', 'role': 'style' } ); | ||
memo.data.addColumn( { type: 'string', role: 'annotation' } ); | memo.data.addColumn( { type: 'string', role: 'annotation' } ); | ||
memo.data.addColumn( { type: 'string', role: 'tooltip', 'p': { 'html': true } } ); | memo.data.addColumn( { type: 'string', role: 'tooltip', 'p': { 'html': true } } ); | ||
memo.data.addColumn( 'number', 'Kesä (kesä-syyskuu)' ); | |||
memo.data.addColumn( {'type': 'string', 'role': 'style' } ); | |||
memo.data.addColumn( { type: 'string', role: 'annotation' } ); | |||
memo.data.addColumn( { type: 'string', role: 'tooltip', 'p': { 'html': true } } ); | |||
} else if ( memo.divide == 'bottomsurface' ) { | |||
memo.options.series[0] = { type: 'scatter', pointSize: 10, color: colors[ 'spring-autumn' ] }; | |||
memo.options.series[1] = { type: 'scatter', pointSize: 10, color: colors[ 'summer' ] }; | |||
memo.options.series[2] = { type: 'scatter', pointSize: 10, color: colors[ 'winter' ] }; | |||
/ | memo.data.addColumn( 'number', 'Välivesi/Ei tietoa' ); | ||
memo.data.addColumn( {'type': 'string', 'role': 'style' } ); | |||
memo.data.addColumn( { type: 'string', role: 'annotation' } ); | |||
memo.data.addColumn( { type: 'string', role: 'tooltip', 'p': { 'html': true } } ); | |||
memo.data.addColumn( 'number', 'Pohja' ); | |||
memo.data.addColumn( {'type': 'string', 'role': 'style' } ); | |||
memo.data.addColumn( { type: 'string', role: 'annotation' } ); | |||
memo.data.addColumn( { type: 'string', role: 'tooltip', 'p': { 'html': true } } ); | |||
memo.data.addColumn( 'number', 'Pinta' ); | |||
memo.data.addColumn( {'type': 'string', 'role': 'style' } ); | |||
memo.data.addColumn( { type: 'string', role: 'annotation' } ); | |||
memo.data.addColumn( { type: 'string', role: 'tooltip', 'p': { 'html': true } } ); | |||
} else { | |||
memo.options.series[0] = { type: 'scatter', pointSize: 10, color: colors[ 'allyear' ] }; | |||
memo.data.addColumn( 'number', memo.obsMinYear + '-' + memo.obsMaxYear ); | |||
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 | |||
if ( memo.showTrend ) { | |||
if ( memo.divide == 'summerwinter' ) { | |||
memo.options.trendlines[0] = { 'lineWidth': 0, 'opacity': 0, tooltip: false, visibleInLegend: false }; | |||
memo.options.trendlines[1] = { labelInLegend: i18n['trendline'][memo.lang], tooltip: false, color: colors['summer'], lineWidth: 3, originalLineWidth: 3, opacity: 1, type: memo.trendType, 'degree': 2, visibleInLegend: false }; | |||
memo.options.trendlines[2] = { labelInLegend: i18n['trendline'][memo.lang], tooltip: false, color: colors['winter'], lineWidth: 3, originalLineWidth: 3, opacity: 1, type: memo.trendType, 'degree': 2, visibleInLegend: false }; | |||
} else if ( memo.divide == 'summerother' ) { | |||
memo.options.trendlines[0] = { 'lineWidth': 0, 'opacity': 0, tooltip: false, visibleInLegend: false }; | |||
memo.options.trendlines[1] = { labelInLegend: i18n['trendline'][memo.lang], tooltip: false, color: colors['summer'], lineWidth: 3, originalLineWidth: 3, opacity: 1, type: memo.trendType, 'degree': 2, visibleInLegend: false }; | |||
} else if ( memo.divide == 'bottomsurface' ) { | |||
memo.options.trendlines[0] = { 'lineWidth': 0, 'opacity': 0, tooltip: false, visibleInLegend: false }; | |||
memo.options.trendlines[1] = { labelInLegend: i18n['trendline'][memo.lang], tooltip: false, color: colors['summer'], lineWidth: 3, originalLineWidth: 3, opacity: 1, type: memo.trendType, 'degree': 2, visibleInLegend: false }; | |||
memo.options.trendlines[2] = { labelInLegend: i18n['trendline'][memo.lang], tooltip: false, color: colors['winter'], lineWidth: 3, originalLineWidth: 3, opacity: 1, type: memo.trendType, 'degree': 2, visibleInLegend: false }; | |||
} else { | |||
memo.options.trendlines[0] = { labelInLegend: i18n['trendline'][memo.lang], tooltip: false, color: colors['allyear'], lineWidth: 3, originalLineWidth: 3, opacity: 1, type: memo.trendType, 'degree': 2, visibleInLegend: memo.trendType!='moving' }; | |||
} | |||
for ( var t in memo.options.trendlines ) { | |||
if ( memo.trendType == 'linear' ) { | |||
memo.options.trendlines[ t ].type = 'linear'; | |||
} else if ( memo.trendType = 'poly2deg' ) { | |||
memo.options.trendlines[ t ].type = 'polynomial'; | |||
memo.options.trendlines[ t ].degree = 2; | |||
} else if ( memo.trendType = 'poly3deg' ) { | |||
memo.options.trendlines[ t ].type = 'polynomial'; | |||
memo.options.trendlines[ t ].degree = 3; | |||
} else if ( memo.trendType == 'smart' ) { | |||
if ( ( memo.axisMaxDate.getFullYear() - memo.axisMinDate.getFullYear() > 10 ) && memo.obsesTotal > 20 ) { | |||
memo.options.trendlines[ t ].type = 'polynomial'; | |||
memo.options.trendlines[ t ].degree = 2; | |||
} else { | |||
memo.options.trendlines[ t ].type = 'linear'; | |||
} | |||
} | |||
} | |||
} | |||
for (var o in memo.obsesA) { | for (var o in memo.obsesA) { | ||
if ( memo.divide == 'summerwinter' ) { | |||
if ( memo.obsesA[o].seriesId == 'summer' ) { | |||
memo.dataA.push( [ memo.obsesA[o].obsdatetime, null, null, null, null, memo.obsesA[o].value, memo.obsesA[o].style, null, memo.obsesA[o].popup, null, null, null, null ] ); | |||
} else if ( memo.obsesA[o].seriesId == 'winter' ) { | |||
memo.dataA.push( [ memo.obsesA[o].obsdatetime, null, null, null, null, null, null, null, null, memo.obsesA[o].value, memo.obsesA[o].style, null, memo.obsesA[o].popup ] ); | |||
} else { | |||
memo.dataA.push( [ memo.obsesA[o].obsdatetime, memo.obsesA[o].value, memo.obsesA[o].style, null, memo.obsesA[o].popup, null, null, null, null, null, null, null, null ] ); | |||
} | |||
} else if ( memo.divide == 'summerother' ) { | |||
if ( memo.obsesA[o].seriesId == 'summer' ) { | |||
memo.dataA.push( [ memo.obsesA[o].obsdatetime, null, null, null, null, memo.obsesA[o].value, memo.obsesA[o].style, null, memo.obsesA[o].popup ] ); | |||
} else { | |||
memo. | memo.dataA.push( [ memo.obsesA[o].obsdatetime, memo.obsesA[o].value, memo.obsesA[o].style, null, memo.obsesA[o].popup, null, null, null, null ] ); | ||
} | |||
} else if ( memo.divide == 'bottomsurface' ) { | |||
if ( memo.obsesA[o].seriesId == 'bottom' ) { | |||
memo.dataA.push( [ memo.obsesA[o].obsdatetime, null, null, null, null, memo.obsesA[o].value, memo.obsesA[o].style, null, memo.obsesA[o].popup, null, null, null, null ] ); | |||
} else if ( memo.obsesA[o].seriesId == 'surface' ) { | |||
memo.dataA.push( [ memo.obsesA[o].obsdatetime, null, null, null, null, null, null, null, null, memo.obsesA[o].value, memo.obsesA[o].style, null, memo.obsesA[o].popup ] ); | |||
} else { | |||
memo.dataA.push( [ memo.obsesA[o].obsdatetime, memo.obsesA[o].value, memo.obsesA[o].style, null, memo.obsesA[o].popup, null, null, null, null, null, null, null, null ] ); | |||
} | |||
} else { | } else { | ||
memo. | memo.dataA.push( [ memo.obsesA[o].obsdatetime, memo.obsesA[o].value, memo.obsesA[o].style, null, memo.obsesA[o].popup ] ); | ||
} | } | ||
} | |||
memo.options.hAxis.ticks = []; | |||
var years = memo.axisMaxDate.getFullYear() - memo.axisMinDate.getFullYear(); | |||
for (i=memo.axisMinDate.getFullYear(); i<=memo.axisMaxDate.getFullYear(); i++) { | |||
middleOfYear = new Date( i, 6, 1 ); | |||
if ( years > 50 ) { | |||
if ( i % 10 == 0 ) { | |||
memo.options.hAxis.ticks.push({v: middleOfYear, f: String(i) }); | |||
if ( | } | ||
memo.options. | } else if ( years > 11 ) { | ||
if ( i % 5 == 0 ) { | |||
memo.options. | memo.options.hAxis.ticks.push({v: middleOfYear, f: String(i) }); | ||
} | |||
} else if ( years > 6 ) { | |||
if ( i % 2 == 0 ) { | |||
memo.options.hAxis.ticks.push({v: middleOfYear, f: String(i) }); | |||
} | } | ||
} else { | } else { | ||
memo.options. | memo.options.hAxis.ticks.push({v: middleOfYear, f: String(i) }); | ||
} | } | ||
} | } | ||
memo.options.hAxis.gridlines.color = '#ffffff'; | |||
drawChart(memo); | |||
} | |||
function addDataToSeasonChart(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 = []; | |||
memo. | |||
for (var o in memo.obsesA) { | |||
memo. | s = memo.obsesA[o].seriesId; | ||
if ( | 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 | ||
memo. | 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'], lineWidth: 0, visibleInLegend: true, hideThis: false }; | |||
memo. | } else { | ||
memo.options.series[sc++] = { type: 'scatter', curveType: 'function', color: colors['curObses'], pointSize: 10, lineWidth: 4, visibleInLegend: true, hideThis: false }; | |||
} | |||
} else { | |||
memo.options.series[sc++] = { type: 'scatter', curveType: 'function', color: colors['obses'], pointSize: 10, lineWidth: 0, visibleInLegend: false, hideThis: true }; | |||
} | |||
} | |||
// legend entry for timespan | |||
memo.data.addColumn( 'number', memo.obsMinDate.getFullYear() + '-' + memo.obsMaxDate.getFullYear() ); | |||
memo.options.series[sc++] = { type: 'scatter', color: colors['obses'], pointSize: 10, visibleInLegend: true, hideThis: false }; | |||
// series for average | |||
memo.data.addColumn( 'number', i18n['average'][memo.lang] ); | |||
if ( i18n[memo.obscode].trend.layout == 'area') { | |||
memo.options.series[sc++] = { type: 'area', curveType: 'function', lineWidth: 2, pointSize: 0, color: colors['averagearea'], areaOpacity: 1, lineDashStyle: [2,2], enableInteractivity: false, visibleInLegend: memo.trendType=='moving' }; | |||
} else { | |||
memo.options.series[sc++] = { type: 'line', curveType: 'function', lineWidth: 3, pointSize: 0, color: colors['average'], dataOpacity: 1, lineDashStyle: [6,3], enableInteractivity: false, visibleInLegend: memo.trendType=='moving' }; | |||
} | |||
memo.data.addColumn( { id: 'dev', type: 'number', role: 'interval' } ); | |||
memo.data.addColumn( { id: 'dev', type: 'number', role: 'interval' } ); | |||
//memo.options.intervals = { 'style': 'color': colors['averagearea'] }; | |||
if ( memo.seasonsA.length == 1 && memo.seasonsA[0] == memo.curSeason ) { | |||
memo.options.series[ sc-1 ].lineWidth = 0; | |||
memo.options.series[ sc-1 ].pointSize = 0; | |||
//memo.options.series[ sc-1 ].color = colors['averagearea']; | |||
//memo.options.series[ sc-1 ].areaOpacity = 1; | |||
memo.options.series[ sc-1 ].labelInLegend = false; | |||
memo.options.intervals = { 'style':'none' }; | |||
} | |||
// series for trend line | |||
memo.data.addColumn( 'number', 'trend' ); | |||
memo.options.series[sc++] = { type: 'scatter', pointSize: 0, enableInteractivity: false, visibleInLegend: false, hideThis: false }; | |||
// do average | |||
console.log( memo ); | |||
if (memo.trendType == 'gaussian') { | |||
memo.gSmoothing = 4; | |||
if ( i18n[memo.obscode]['type'] == 'cat') { | |||
memo.distF = 0.1; | |||
} else { | |||
} | memo.distF = 0; | ||
} | |||
memo. | // sort according to compare date | ||
memo.obsesA.sort( function( a, b ) { return a.compareDate - b.compareDate; }); | |||
// make week averages | |||
memo.avgW = {}; | |||
for ( var o in memo.obsesA ) { | |||
//mwDate = new Date( memo.obsesA[o].compareDate.getFullYear(), memo.obsesA[o].compareDate.getMonth(), memo.obsesA[o].compareDate.getDate() ); | |||
//mwDate.setHours( 12 ); | |||
mwDate = new Date( memo.obsesA[o].compareDate.getTime() ); | |||
mwDate.setDate( mwDate.getDate() - mwDate.getDay() + 3 ); | |||
memo.obsesA[o].mwDate = mwDate; | |||
y = mwDate.getFullYear(); | |||
w = mwDate.getWeek(); | |||
v = memo.obsesA[o].value + memo.distF*Math.random() - memo.distF*Math.random(); | |||
if ( typeof memo.avgW[y] == 'undefined' ) { memo.avgW[y] = {}; } | |||
if ( y == | if ( typeof memo.avgW[y][w] == 'undefined' ) { | ||
else { | //mwDate.setDate( mwDate.getDate() - mwDate.getDay() + 3 ); | ||
memo.avgW[y][w] = { cDate: mwDate, values: [ v ], sum: v, count: 1, avg: v }; | |||
} else { | |||
memo.avgW[y][w].values.push( v ); | |||
memo.avgW[y][w].sum += v; | |||
memo.avgW[y][w].count++; | |||
memo.avgW[y][w].avg = memo.avgW[y][w].sum / memo.avgW[y][w].count; | |||
} | |||
} | |||
// calculate standard deviation | |||
devSum = 0; | |||
devC = 0; | |||
for ( var w= | devMax = 0; | ||
for ( var y in memo.avgW ) { | |||
for ( var w in memo.avgW[y] ) { | |||
devC++; | |||
devx = 0; | |||
for (var vi in memo.avgW[y][w].values ) { | |||
devx += Math.pow( (memo.avgW[y][w].values[vi] - memo.avgW[y][w].avg), 2 ); | |||
} | |||
memo.avgW[y][w].dev = Math.sqrt( devx/memo.avgW[y][w].count ); | |||
devSum += memo.avgW[y][w].dev; | |||
devMax = Math.max( memo.avgW[y][w].dev, devMax ); | |||
} | |||
} | |||
devAvg = devSum/devC; | |||
for ( var y in memo.avgW ) { | |||
for ( var w in memo.avgW[y] ) { | |||
if ( memo.avgW[y][w].count < 5 ) { | |||
//memo.avgW[y][w].dev = Math.max( memo.avgW[y][w].dev, devAvg ); | |||
} | |||
} | |||
} | |||
memo.avgWlist = []; | |||
for ( var y in memo.avgW ) { | |||
for ( var w in memo.avgW[y] ) { | |||
memo.avgWlist.push( { y: parseInt(y), w: parseInt(w), avg: memo.avgW[y][w].avg, dev: memo.avgW[y][w].dev } ); | |||
} | |||
} | |||
memo.avgWlist.sort( function(a, b) { return (a.y*100+a.w) - (b.y*100+b.w); }); | |||
firstY = memo.avgWlist[0].y; | |||
firstW = memo.avgWlist[0].w; | |||
lastY = memo.avgWlist[memo.avgWlist.length-1].y; | |||
lastW = memo.avgWlist[memo.avgWlist.length-1].w; | |||
memo.avgMlist = []; | |||
memo.avgLlist = []; | |||
memo.avgHlist = []; | |||
for ( var y=firstY; y<=lastY; y++ ) { | |||
if ( y == firstY ) { w1 = firstW; } | |||
else { w1 = 1; } | |||
if ( y == lastY ) { w2 = lastW; } | |||
else { w2 = 52; } | |||
for ( var w=w1; w<=w2; w++) { | |||
if ( typeof(memo.avgW[y][w]) == 'undefined' ) { | |||
memo.avgMlist.push( null ); | |||
memo.avgLlist.push( null ); | |||
memo.avgHlist.push( null ); | |||
} else { | |||
memo.avgMlist.push( memo.avgW[y][w].avg ); | |||
if ( memo.avgW[y][w].count < 2 ) { | |||
d = Math.max( devMax, memo.avgW[y][w].dev ); | |||
} else if ( memo.avgW[y][w].count < 4 ) { | |||
d = Math.max( devAvg, memo.avgW[y][w].dev ); | |||
} else { | |||
d = memo.avgW[y][w].dev; | |||
} | |||
if ( i18n[memo.obscode].type == 'cat' && ( memo.avgW[y][w].avg - 2*memo.avgW[y][w].dev ) < -memo.distF ) { | |||
memo.avgLlist.push( -memo.distF*Math.random()*2 ); | |||
} else { | |||
memo.avgLlist.push( memo.avgW[y][w].avg - 2*d ); //memo.avgW[y][w].dev ); | |||
} | |||
memo.avgHlist.push( memo.avgW[y][w].avg + 2*d ); //memo.avgW[y][w].dev ); | |||
} | } | ||
} | |||
} | |||
for ( var i=0; i<memo.avgMlist.length; i++ ) { | |||
if ( memo.avgMlist[i] === null ) { | |||
memo. | lastM = memo.avgMlist[i-1]; | ||
memo.avgHlist | lastL = memo.avgLlist[i-1]; | ||
lastH = memo.avgHlist[i-1]; | |||
for ( var ix=(i+1); ix < memo.avgMlist.length; ix++ ) { | |||
if ( memo.avgMlist[ix] !== null ) { | |||
memo.avgMlist[i] = lastM + (memo.avgMlist[ix]-lastM) / (ix-i+1); | |||
memo.avgLlist[i] = lastL + (memo.avgLlist[ix]-lastL) / (ix-i+1); | |||
memo.avgHlist[i] = lastH + (memo.avgHlist[ix]-lastH) / (ix-i+1); | |||
break; | |||
} | |||
} | |||
} | |||
} | |||
if ( memo.avgMlist.length >= 52 ) { | |||
// | memo.avgMlist = memo.avgMlist.slice( memo.avgMlist.length - memo.gSmoothing/2 - 2 ).concat( memo.avgMlist ).concat( memo.avgMlist.slice( 0, memo.gSmoothing/2 + 2 ) ); | ||
memo.avgLlist = memo.avgLlist.slice( memo.avgLlist.length - memo.gSmoothing/2 - 2 ).concat( memo.avgLlist ).concat( memo.avgLlist.slice( 0, memo.gSmoothing/2 + 2 ) ); | |||
memo.avgHlist = memo.avgHlist.slice( memo.avgHlist.length - memo.gSmoothing/2 - 2 ).concat( memo.avgHlist ).concat( memo.avgHlist.slice( 0, memo.gSmoothing/2 + 2 ) ); | |||
} else { | |||
for (var x=0; x < ( memo.gSmoothing/2 + 3 ); x++) { | |||
if ( memo.obscode == 'secchi' ) { | |||
prev = Math.max ( memo.avgMlist[0], 0 ); | |||
next = Math.max ( memo.avgMlist[memo.avgMlist.length-1], 0 ); | |||
} else { | |||
prev = Math.max ( 2 * memo.avgMlist[0] - memo.avgMlist[1], 0 ); | |||
next = Math.max ( 2 * memo.avgMlist[memo.avgMlist.length-1] - memo.avgMlist[memo.avgMlist.length-2], 0 ); | |||
} | |||
memo.avgMlist.unshift( prev ); | |||
memo.avgMlist.push( next ); | |||
memo.avgLlist.unshift( prev - 2 * devAvg ); | |||
memo.avgLlist.push( next - 2 * devAvg ); | |||
memo.avgHlist.unshift( prev + 2 * devAvg ); | |||
memo.avgHlist.push( next + 2 * devAvg ); | |||
} | |||
} | |||
memo.avgMsmooth = smooth( memo.avgMlist, memo.gSmoothing ); | |||
memo.avgLsmooth = smooth( memo.avgLlist, memo.gSmoothing ); | |||
memo.avgHsmooth = smooth( memo.avgHlist, memo.gSmoothing ); | |||
cc = memo.data.getNumberOfColumns(); | |||
msW = 7*24*60*60*1000; | |||
for ( var i=0; i < ( memo.avgMsmooth.length ); i++ ) { | |||
// | // put data into dataArr | ||
for (var | dataRow = []; | ||
for (var e=0; e<cc; e++) { dataRow.push( null ); } | |||
/ | xdate = new Date( memo.avgW[firstY][firstW].cDate.getTime() + ( i + 1 - memo.gSmoothing/2 ) * msW ); | ||
dataRow[0] = | if ( xdate.getTime() < memo.axisMinDate.getTime() ) { | ||
dataRow[0] = memo.axisMinDate; | |||
} else if ( xdate.getTime() > memo.axisMaxDate.getTime() ) { | |||
if ( memo. | dataRow[0] = memo.axisMaxDate; | ||
dataRow[ | |||
} else { | } else { | ||
dataRow[ | dataRow[0] = xdate; //new Date( memo.avgW[firstY][firstW].cDate.getTime() + ( i + 1 - memo.gSmoothing/2 ) * msW ); | ||
} | } | ||
dataRow[cc-4] = memo.avgMsmooth[i]; | |||
} else { | |||
dataRow[ | if ( memo.obscode == 'level' ) { | ||
dataRow[cc-3] = memo.avgLsmooth[i]; | |||
} else { | |||
dataRow[cc-3] = Math.max( memo.avgLsmooth[i], 0 ); | |||
} | } | ||
dataRow[cc-2] = memo.avgHsmooth[i]; | |||
memo.dataA.push( dataRow ); | memo.dataA.push( dataRow ); | ||
} | |||
} else if (memo.trendType == 'moving') { | |||
} | // | ||
} | |||
// | // 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; | |||
if ( ( today.getTime() - obs.compareDate.getTime() < 10*24*60*60*1000 ) && s == 0 && o == ( memo.seasonsO[memo.seasonsA[s]].obses.length - 1 ) ) { | |||
var diff = obs.value - memo.avgW[ obs.mwDate.getFullYear() ][ obs.mwDate.getWeek() ].avg; | |||
var diff = Math.round( diff*100 ); | |||
var diffStr = diff.toString() + ' cm'; | |||
if ( diff > 0 ) { diffStr = '+' + diffStr; } | |||
dataRow[s*4+4] = null; //diffStr; //annotation | |||
} else { | |||
dataRow[s*4+4] = null; //annotation | |||
} | |||
memo.dataA.push( dataRow ); | |||
} | } | ||
middleOfMonth = new Date( maxY, m, 16 ); | } | ||
// make ticks for x axis | |||
var minM = memo.axisMinDate.getMonth(); | |||
var minY = memo.axisMinDate.getFullYear(); | |||
var maxM = memo.axisMaxDate.getMonth(); | |||
if (maxM < minM) { | |||
mCount = 13 - minM + maxM; // 13-10+4 = 1+4 | |||
} else { | |||
mCount = maxM - minM + 1; | |||
} | |||
memo.options.hAxis.viewWindow.min = memo.axisMinDate; | |||
memo.options.hAxis.viewWindow.max = memo.axisMaxDate; | |||
memo.options.hAxis.ticks = []; | |||
for (i=0; i<mCount; i++) { | |||
m = minM + i; | |||
maxY = minY; | |||
if (m > 11) { | |||
m = minM + i - 12; | |||
maxY++; | |||
} | |||
middleOfMonth = new Date( maxY, m, 16 ); | |||
if (mCount < 5) { | if (mCount < 5) { | ||
| Rivi 1 761: | Rivi 1 922: | ||
var i18n = { | var i18n = { | ||
'surface': { 'fi': 'pinta', 'en': 'surface', 'sv': 'ytan' }, | |||
'bottom': { 'fi': 'pohja', 'en': 'bottom', 'sv': 'bottnet' }, | |||
'siteinfostring': { 'fi': 'Havaintopaikka', 'en': 'Observation site', 'sv': 'Observationsplatsen' }, | |||
'depthinfostring': { 'fi': 'Havainnot syvyydeltä', 'en': 'Depth of observations', 'sv': 'Djup för observationer' }, | |||
'download': { 'fi': 'Lataa csv-muodossa', 'en': 'Download in csv format', 'sv': 'Ladda ner i csv-format' }, | 'download': { 'fi': 'Lataa csv-muodossa', 'en': 'Download in csv format', 'sv': 'Ladda ner i csv-format' }, | ||
'fullscreen': { 'fi': 'Ota käyttöön/poista kokoruututila', 'en': 'Toggle fullscreen mode', 'sv': 'Växla helskärmsläge' }, | 'fullscreen': { 'fi': 'Ota käyttöön/poista kokoruututila', 'en': 'Toggle fullscreen mode', 'sv': 'Växla helskärmsläge' }, | ||
| Rivi 1 773: | Rivi 1 938: | ||
'season': 'summer', | 'season': 'summer', | ||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | 'trend': { 'type': 'gaussian', 'layout': 'line' }, | ||
'title': { 'fi': 'Sinilevätilanne', 'en': ' | 'title': { 'fi': 'Sinilevätilanne', 'en': 'Cyanobacteria situation', 'sv': 'Cyanobakterieläget', 'ru': '???' }, | ||
'catNames': { 0: { 'fi': 'Ei levää', 'en': 'No algae', 'sv': 'Inga alger' }, 1: { 'fi': 'Hieman levää', 'en': 'Some algae', 'sv': 'Lite med alger' }, 2: { 'fi': 'Runsaasti levää', 'en': 'Abundant with algae', 'sv': 'Rikligt med alger' }, 3: { 'fi': 'Erittäin runsaasti levää', 'en': 'Very abundant with algae', 'sv': 'Ytterst rikligt med alger' } }, | 'catNames': { 0: { 'fi': 'Ei levää', 'en': 'No algae', 'sv': 'Inga alger' }, 1: { 'fi': 'Hieman levää', 'en': 'Some algae', 'sv': 'Lite med alger' }, 2: { 'fi': 'Runsaasti levää', 'en': 'Abundant with algae', 'sv': 'Rikligt med alger' }, 3: { 'fi': 'Erittäin runsaasti levää', 'en': 'Very abundant with algae', 'sv': 'Ytterst rikligt med alger' } }, | ||
'catNamesShort': { 0: { 'fi': 'Ei levää', 'en': 'No algae', 'sv': 'Inga alger' }, 1: { 'fi': 'Hieman', 'en': 'Some', 'sv': 'Lite' }, 2: { 'fi': 'Runsaasti', 'en': 'Abundant', 'sv': 'Rikligt' }, 3: { 'fi': 'Erit. runsaasti', 'en': 'Very abundant', 'sv': 'Ytterst rikligt' } }, | 'catNamesShort': { 0: { 'fi': 'Ei levää', 'en': 'No algae', 'sv': 'Inga alger' }, 1: { 'fi': 'Hieman', 'en': 'Some', 'sv': 'Lite' }, 2: { 'fi': 'Runsaasti', 'en': 'Abundant', 'sv': 'Rikligt' }, 3: { 'fi': 'Erit. runsaasti', 'en': 'Very abundant', 'sv': 'Ytterst rikligt' } }, | ||
| Rivi 1 781: | Rivi 1 946: | ||
'temp': { | 'temp': { | ||
'type': 'num', | 'type': 'num', | ||
'season': 'summer', | 'season': 'summer', | ||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | 'trend': { 'type': 'gaussian', 'layout': 'line' }, | ||
'title': { 'fi': 'Pintaveden lämpötila', 'en': 'Surface water | 'title': { 'fi': 'Pintaveden lämpötila', 'en': 'Surface water temperature', 'sv': 'Ytvattentemperatur', 'ru': '???' }, | ||
'unit': '°C', | 'unit': '°C', | ||
'axisTitleV': { 'fi': 'Lämpötila, °C', 'en': 'Temperature, °C', 'sv': 'Temperatur, °C', 'ru': '°C' } | 'axisTitleV': { 'fi': 'Lämpötila, °C', 'en': 'Temperature, °C', 'sv': 'Temperatur, °C', 'ru': '°C' } | ||
| Rivi 1 820: | Rivi 1 984: | ||
}, | }, | ||
}, | }, | ||
'snow': { | |||
'catName': 'Lumitilanne', | |||
'type': 'num', | |||
'season': 'winter', | |||
'min': 0, | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'title': { 'fi': 'Lumipeite', 'en': 'Snow cover', 'sv': 'Snötöcket', 'ru': '???' }, | |||
'unit': 'cm', | |||
'axisTitleV': { 'fi': 'Lumipeitteen paksuus, cm', 'en': 'Snow cover, cm', 'sv': 'Snötäcket, cm', 'ru': 'm' } | |||
}, | |||
'snow_load': { | 'snow_load': { | ||
'catName': 'Lumikuorma', | 'catName': 'Lumikuorma', | ||
| Rivi 1 825: | Rivi 1 999: | ||
'season': 'winter', | 'season': 'winter', | ||
'min': 0, | 'min': 0, | ||
'trend': { 'type': ' | 'trend': { 'type': 'gaussian', 'layout': 'line' }, | ||
'title': { 'fi': 'Lumikuorma', 'en': 'Snow load', 'sv': 'Snöbelastning', 'ru': '???' }, | 'title': { 'fi': 'Lumikuorma', 'en': 'Snow load', 'sv': 'Snöbelastning', 'ru': '???' }, | ||
'unit': 'kg/m²', | 'unit': 'kg/m²', | ||
'axisTitleV': { 'fi': 'Lumikuorma, kg/m²', 'en': 'Snow load, kg/m²', 'sv': 'Snöbelastning, kg/m²', 'ru': 'm' } | 'axisTitleV': { 'fi': 'Lumikuorma, kg/m²', 'en': 'Snow load, kg/m²', 'sv': 'Snöbelastning, kg/m²', 'ru': 'm' } | ||
}, | }, | ||
'pH': { | |||
'type': 'num', | |||
'season': 'summer', | |||
//'min': 0, | |||
'direction': 1, | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'title': { 'fi': 'Happamuus, pH', 'en': 'Acidity, pH', 'sv': 'Surhet, pH', 'ru': '???' }, | |||
'unit': '', | |||
'axisTitleV': { 'fi': 'Happamuus, pH', 'en': 'Acidity, pH', 'sv': 'Surhet, pH', 'ru': 'm' } | |||
}, | |||
'cond': { | |||
'type': 'num', | |||
'season': 'summer', | |||
'min': 0, | |||
'direction': 1, | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'title': { 'fi': 'Sähkönjohtavuus', 'en': 'Conductivity', 'sv': 'Konduktivitet', 'ru': '???' }, | |||
'unit': 'mS/m', | |||
'axisTitleV': { 'fi': 'Sähkönjohtavuus, mS/m', 'en': 'Conductivity, mS/m', 'sv': 'Konduktivitet, mS/m', 'ru': 'm' } | |||
}, | |||
'ptot': { | 'ptot': { | ||
'type': 'num', | 'type': 'num', | ||
| Rivi 1 838: | Rivi 2 032: | ||
'title': { 'fi': 'Kokonaisfosfori', 'en': 'Total phosphorus', 'sv': 'Totalfosfor', 'ru': '???' }, | 'title': { 'fi': 'Kokonaisfosfori', 'en': 'Total phosphorus', 'sv': 'Totalfosfor', 'ru': '???' }, | ||
'unit': 'µg/l', | 'unit': 'µg/l', | ||
'axisTitleV': { 'fi': 'Pitoisuus, µg/l', 'en': 'Concentration, µg/l', 'sv': 'Koncentration, µg/l', 'ru': 'm' } | 'axisTitleV': { 'fi': 'Pitoisuus, µg/l', 'en': 'Concentration, µg/l', 'sv': 'Koncentration, µg/l', 'ru': 'm' }, | ||
'depths': true | |||
}, | }, | ||
'ntot': { | 'ntot': { | ||
| Rivi 1 849: | Rivi 2 044: | ||
'unit': 'µg/l', | 'unit': 'µg/l', | ||
'axisTitleV': { 'fi': 'Pitoisuus, µg/l', 'en': 'Concentration, µg/l', 'sv': 'Koncentration, µg/l', 'ru': 'm' } | 'axisTitleV': { 'fi': 'Pitoisuus, µg/l', 'en': 'Concentration, µg/l', 'sv': 'Koncentration, µg/l', 'ru': 'm' } | ||
}, | }, | ||
'o2': { | 'o2': { | ||
'type': 'num', | 'type': 'num', | ||
'season': 'summer', | 'season': 'summer', | ||
'min': 0, | 'min': 0, | ||
'direction': 1, | 'direction': 1, | ||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | 'trend': { 'type': 'gaussian', 'layout': 'line' }, | ||
'title': { 'fi': 'Happipitoisuus', 'en': 'Dissolved oxygen', 'sv': 'Syrehalt', 'ru': '???' }, | 'title': { 'fi': 'Happipitoisuus', 'en': 'Dissolved oxygen', 'sv': 'Syrehalt', 'ru': '???' }, | ||
'unit': 'mg/l', | 'unit': 'mg/l', | ||
'axisTitleV': { 'fi': 'Pitoisuus, mg/l', 'en': 'Concentration, mg/l', 'sv': 'Koncentration, mg/l', 'ru': 'm' } | 'axisTitleV': { 'fi': 'Pitoisuus, mg/l', 'en': 'Concentration, mg/l', 'sv': 'Koncentration, mg/l', 'ru': 'm' } | ||
}, | |||
'o2s': { | |||
'type': 'num', | |||
'season': 'summer', | |||
'min': 0, | |||
'max': 110, | |||
'direction': 1, | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'title': { 'fi': 'Hapen kyllästysaste', 'en': 'Oxygen saturation', 'sv': 'Syremättnad' }, | |||
'unit': '%', | |||
'axisTitleV': { 'fi': 'Kyllästys-%', 'en': 'Oxygen saturation, %', 'sv': 'Syremättnad, %' } | |||
}, | |||
'chla': { | |||
'type': 'num', | |||
'season': 'summer', | |||
'min': 0, | |||
'direction': 1, | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'title': { 'fi': 'A-klorofylli', 'en': 'Chlorophyll a', 'sv': 'Klorofyll a', 'ru': '???' }, | |||
'unit': 'µg/l', | |||
'axisTitleV': { 'fi': 'pitoisuus, µg/l', 'en': 'Concentration, µg/l', 'sv': 'Konsentration, µg/l' } | |||
}, | |||
'secchi': { | |||
'type': 'num', | |||
'season': 'summer', | |||
'min': 0, | |||
'direction': 1, | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'title': { 'fi': 'Näkösyvyys', 'en': 'Water transparency', 'sv': 'Siktdjupet', 'ru': '???' }, | |||
'unit': 'm', | |||
'axisTitleV': { 'fi': 'Näkösyvyys, m', 'en': 'Secchi depth, m', 'sv': 'Siktdjupet, m', 'ru': 'm' } | |||
}, | |||
'turb': { | |||
'type': 'num', | |||
'season': 'summer', | |||
'min': 0, | |||
'direction': 1, | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'title': { 'fi': 'Sameus', 'en': 'Turbidity', 'sv': 'Grumlighet', 'ru': '???' }, | |||
'unit': 'FTU/FNU/NTU', | |||
'axisTitleV': { 'fi': 'Sameus, FTU/FNU/NTU', 'en': 'Turbidity, FTU/FNU/NTU', 'sv': 'Grumlighet, FTU/FNU/NTU', 'ru': 'm' } | |||
}, | }, | ||
'level': { | 'level': { | ||
'title': { 'fi': 'Vedenkorkeus', 'en': 'Water level', 'sv': 'Vattenståndpunkt', 'ru': '???' }, | 'title': { 'fi': 'Vedenkorkeus', 'en': 'Water level', 'sv': 'Vattenståndpunkt', 'ru': '???' }, | ||
| Rivi 1 967: | Rivi 2 183: | ||
'long': { 'fi': 'Elokuu', 'en': 'August', 'sv': 'Augusti', 'ru': '???' }, | 'long': { 'fi': 'Elokuu', 'en': 'August', 'sv': 'Augusti', 'ru': '???' }, | ||
'short': { 'fi': 'Elo', 'en': 'Aug', 'sv': 'Aug', 'ru': '???' }, | 'short': { 'fi': 'Elo', 'en': 'Aug', 'sv': 'Aug', 'ru': '???' }, | ||
'roman': ' | 'roman': 'VIII' | ||
}, | }, | ||
8: { | 8: { | ||


