Ei muokkausyhteenvetoa |
Ei muokkausyhteenvetoa |
||
| (148 välissä olevaa versiota samalta käyttäjältä ei näytetä) | |||
| Rivi 1: | Rivi 1: | ||
<includeonly> | <includeonly> | ||
<script type="text/javascript"> | |||
(function() { | |||
// globals | |||
var today = new Date(); | |||
function <!--{$id|default:TheGraph|escape:'html'}-->_jQueryTest() { | |||
if ( typeof window.jQuery == 'undefined' ) { | |||
setTimeout( function(){ <!--{$id|default:TheGraph|escape:'html'}-->_jQueryTest() }, 300); | |||
} else { | |||
<!--{$id|default:TheGraph|escape:'html'}-->_func(); | |||
} | |||
} | } | ||
setTimeout( <!--{$id|default:TheGraph|escape:'html'}-->_jQueryTest, 300); | |||
function <!--{$id|default:TheGraph|escape:'html'}-->_func() { | |||
if ( typeof window.jwobschart == 'undefined' ) { | |||
window.jwobschart = {}; | |||
css_link = jQuery( "<link>", { rel: "stylesheet", type: "text/css", href: "//www.jarviwiki.fi/embed/css/obschart.css?ver=1" }); | |||
css_link.appendTo('head'); | |||
jQuery.getScript( "//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js", function() { | |||
jQuery.getScript( "//www.jarviwiki.fi/citobsjs/jwapi.js", function() { | |||
jQuery.getScript( '//www.gstatic.com/charts/loader.js', function() { | |||
google.charts.load( 'current', { 'packages':[ 'corechart' ], 'language': 'fi' } ); | |||
google.charts.setOnLoadCallback( allReady ); | |||
}); | |||
}); | }); | ||
}); | }); | ||
} | } | ||
} | } | ||
function allReady() { | |||
// resize all when window resizes | |||
jQuery( window ).resize(function() { | |||
for ( var c in window.jwobschart ) { | |||
if ( window.jwobschart[c].memo.widgetEl.is( ':visible' ) ) { | |||
doResize( window.jwobschart[c].memo ); | |||
} | |||
} | } | ||
}); | |||
loadObservations(); | |||
} | |||
function loadObservations() { | |||
var hc = 0; | |||
jQuery( '.jwChartWidget' ).each( function() { | |||
var el = jQuery( this ); | |||
var id = el.attr( 'id' ); if ( typeof id == 'undefined' ) { id = 'jwsitegraph_' + Math.random() + '_container'; el.attr( 'id', id ); } | |||
if ( typeof el.attr( 'data-preload' ) == 'undefined' ) { | |||
preload = false; | |||
} else { | } else { | ||
preload = ( el.attr( 'data-preload' ).toLowerCase() == 'true' ); | |||
} | } | ||
if ( ( preload || el.is( ':visible' ) ) && typeof window.jwobschart[id] == 'undefined' ) { | |||
window.jwobschart[id] = {}; | |||
var memo = {}; window.jwobschart[id].memo = memo; | |||
memo.widgetEl = jQuery( this ); | |||
memo.lang = memo.widgetEl.attr( 'data-lang' ); if (typeof memo.lang == 'undefined') { memo.lang = 'fi'; } | |||
memo.height = memo.widgetEl.attr( 'data-height' ); if (typeof memo.height == 'undefined') { memo.height = 450; } | |||
memo. | |||
memo.siteid = jQuery( this ).attr( 'data-jw-siteid' ); if ( typeof memo.siteid == 'undefined' ) { memo.siteid = '-'; } | |||
memo. | memo.waterbody = jQuery( this ).attr( 'data-jw-waterbody' ); if ( typeof memo.waterbody == 'undefined' ) { memo.waterbody = '-'; } | ||
memo. | memo.obscode = jQuery( this ).attr( 'data-jw-obscode' ); if ( typeof memo.obscode == 'undefined' ) { memo.obscode = '-'; } | ||
memo.refcode = jQuery( this ).attr( 'data-jw-refcode' ); if ( typeof memo.refcode == 'undefined' ) { memo.refcode = '-'; } | |||
memo.reffilter = jQuery( this ).attr( 'data-jw-reffilter' ); if ( typeof memo.reffilter == 'undefined' ) { memo.reffilter = ''; } | |||
memo.obscodeParts = memo.obscode.split('_'); | |||
memo.title = jQuery( this ).attr( 'data-title' ); if ( typeof memo.title == 'undefined' ) { memo.title = i18n[ memo.obscode ][ 'title' ][ memo.lang ]; } | |||
memo.info = jQuery( this ).attr( 'data-info' ); if ( typeof memo.info == 'undefined' ) { memo.info = ""; } | |||
if ( typeof jQuery( this ).attr( 'data-info-addsite' ) != 'undefined' ) { memo.addsitetoinfo = ( jQuery( this ).attr( 'data-info-addsite' ) == 'true' ); } else { memo.addsitetoinfo = false; }; | |||
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-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' ) { | |||
if ( memo. | memo.divide = jQuery( this ).attr( 'data-jw-divide' ); | ||
memo. | } else if ( memo.bottomsurface ) { | ||
memo.divide = 'bottomsurface'; | |||
} else if ( memo.summerwinter ) { | |||
memo.divide = 'summerwinter'; | |||
} else if ( memo.summerother ) { | |||
memo.divide = 'summerother'; | |||
} else { | } else { | ||
memo. | 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' ) { | |||
memo.showlink = false; | |||
} else { | |||
memo.showlink = ( jQuery( this ).attr( 'data-showlink' ).toLowerCase() == 'true' ); | |||
} | |||
if ( typeof jQuery( this ).attr( 'data-min' ) != 'undefined' ) { i18n[memo.obscode]['min'] = parseInt( jQuery( this ).attr( 'data-min' ) ); } | |||
if ( typeof jQuery( this ).attr( 'data-max' ) != 'undefined' ) { i18n[memo.obscode]['max'] = parseInt( jQuery( this ).attr( 'data-max' ) ); } | |||
if ( typeof jQuery( this ).attr( 'data-start-date' ) != 'undefined' ) { | |||
memo.startDate = jQuery( this ).attr( 'data-start-date' ); | |||
} else if ( typeof jQuery( this ).attr( 'data-start-year' ) != 'undefined' ) { | |||
memo.startDate = jQuery( this ).attr( 'data-start-year' ) + '-01-01'; | |||
} else { | |||
memo.startDate = '1800-01-01'; | |||
} | } | ||
memo.service = jQuery( this ).attr( 'data-coo311-service_code' ); | |||
memo. | memo.graphType = jQuery( this ).attr( 'data-graph-type' ); | ||
memo.editUrl = jQuery( this ).attr( 'data-edit-url' ); if (typeof memo.editUrl == 'undefined') { memo.editUrl = '-'; } | |||
memo.download = true; if ( typeof jQuery( this ).attr( 'data-download' ) != 'undefined' ) { memo.download = ( jQuery( this ).attr( 'data-download' ) == '1' || jQuery( this ).attr( 'data-download' ) == 'true' ); } | |||
memo.fullscreenEl.on( 'click', function() { | memo.csvfile = jQuery( this ).attr( 'data-csv-filename' ); if (typeof memo.csvfile == 'undefined') { memo.csvfile = i18n[ memo.obscode ].title[ memo.lang ] + '_SiteID-' + memo.siteid + '_Downloaded-' + today.toISOString().split( 'T' )[0] + '.csv'; } | ||
if ( typeof jQuery( this ).attr( 'data-maintainer' ) == 'undefined' ) { memo.maintainerShow = false; } | |||
else { memo.maintainerShow = ( jQuery( this ).attr( 'data-maintainer' ).toLowerCase() == 'true' ); } | |||
memo.id = jQuery( this ).attr( 'id' ); if (typeof memo.id == 'undefined') { memo.id = 'jwsitegraph_' + Math.random() + '_container'; jQuery( this ).attr( 'id', memo.id ); } | |||
memo.widgetEl.css( 'position', 'relative' ); | |||
//memo.widgetEl.css( 'margin-bottom', '0.5em' ); | |||
// add loader animation | |||
memo.widgetEl.append( '<div style="display: none;" class="jwloading"></div>' ); | |||
memo.loaderEl = jQuery( this ).find( '.jwloading' ); | |||
memo.loaderEl.fadeIn( "slow" ); | |||
if ( memo.graphType != 'current' ) { | |||
// add chart container | |||
memo.widgetEl.append( '<div class="card JwCard Xmb-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.chartEl = jQuery( this ).find( '.chart-container' ); | |||
memo.chartEl.css( 'height', memo.height + 'px' ); | |||
memo.headerEl = jQuery( this ).find( '.card-header' ); | |||
memo.footerEl = jQuery( this ).find( '.card-footer' ); | |||
// add title | |||
memo.headerEl.append( '<div class="obscharttitle" style="float: left;"></div>' ); | |||
memo.titleEl = jQuery( this ).find( '.obscharttitle' ); | |||
// add or hide footer | |||
if ( memo.caption == '' ) { | |||
memo.footerEl.hide(); | |||
} else { | |||
memo.footerEl.append( memo.caption ); | |||
} | |||
// add fullscreen button | |||
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.on( 'click', function() { | |||
var elem = memo.widgetEl[0]; | |||
if (!!document.fullscreenElement) { | |||
if (document.exitFullscreen) { | |||
document.exitFullscreen(); | |||
} else if (document.mozCancelFullScreen) { /* Firefox */ | |||
document.mozCancelFullScreen(); | |||
} else if (document.webkitExitFullscreen) { /* Chrome, Safari and Opera */ | |||
document.webkitExitFullscreen(); | |||
} else if (document.msExitFullscreen) { /* IE/Edge */ | |||
document.msExitFullscreen(); | |||
} | |||
} else { | |||
if (elem.requestFullscreen) { | |||
elem.requestFullscreen(); | |||
} else if (elem.mozRequestFullScreen) { /* Firefox */ | |||
elem.mozRequestFullScreen(); | |||
} else if (elem.webkitRequestFullscreen) { /* Chrome, Safari and Opera */ | |||
elem.webkitRequestFullscreen(); | |||
} else if (elem.msRequestFullscreen) { /* IE/Edge */ | |||
elem.msRequestFullscreen(); | |||
} | |||
} | } | ||
} | }); | ||
if ( | |||
jQuery( document ).on('webkitfullscreenchange mozfullscreenchange fullscreenchange', function(e) { | |||
if (!document.fullscreenElement) { | |||
memo.chartEl.css( 'height', memo.height + 'px' ); | |||
} else | memo.fullscreenEl.find( 'button' ).html( '<i class="fas fa-expand"></i>' ); | ||
} else { | |||
memo.chartEl.css( 'height', '100%' ); | |||
memo.fullscreenEl.find( 'button' ).html( '<i class="fas fa-compress"></i>' ); | |||
} | } | ||
doResize( memo ); | |||
}); | |||
// add edit button | |||
if ( memo.editUrl != '-' ) { | |||
memo.headerEl.append( '<div class="obschartbutton edit-button" style="Xdisplay: 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.on( 'click', function() { window.location.href = memo.editUrl; }); | |||
} | } | ||
// add download data button | |||
if ( | if ( memo.download ) { | ||
memo. | 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. | memo.downloadEl.on( 'click', function() { | ||
memo. | |||
var header = ''; | |||
header += '\uFEFF'; // BOM | |||
var csv = ''; | |||
//csv += '\r\nsep=,\r\n'; | |||
var headerCols = []; | |||
var csvCols = []; | |||
if ( i18n[memo.obscode].type == 'num' ) { | |||
headerCols.push( '"' + i18n[memo.obscode].axisTitleV[memo.lang] + '"' ); | |||
headerCols.push( 'Lisätiedot' ); | |||
headerCols.push( 'Valokuva' ); | |||
headerCols.push( 'Havainnoijan status' ); | |||
header += headerCols.join( i18n['sep'][memo.lang] ); | |||
for ( var o in memo.obses ) { | |||
csvCols = []; | |||
csvCols.push( memo.obses[o].obsdatetime.getFullYear() + '-' + ( memo.obses[o].obsdatetime.getMonth() + 1 ) + '-' + memo.obses[o].obsdatetime.getDate() ); | |||
if ( memo.obses[o].obsdatetime.getUTCHours() == 0 && memo.obses[o].obsdatetime.getUTCMinutes() == 0 && memo.obses[o].obsdatetime.getUTCSeconds() == 0 ) { | |||
csvCols.push( '' ); | |||
} else { | |||
csvCols.push( ( "0" + memo.obses[o].obsdatetime.getUTCHours() ).slice(-2) + ':' + ( "0" + memo.obses[o].obsdatetime.getUTCMinutes() ).slice(-2) ); | |||
} | |||
csvCols.push( '"' + memo.obses[o].value.toString().replace( '.', i18n['dec'][memo.lang] ) + '"' ); | |||
csvCols.push( memo.obses[o].addInfo ); | |||
csvCols.push( '' ); | csvCols.push( '' ); | ||
csvCols.push( memo.obses[o].maintainer ); | |||
csv += '\r\n' + csvCols.join( i18n['sep'][memo.lang] ); | |||
} | |||
} else if ( i18n[memo.obscode].type == 'date' ) { | |||
if ( i18n[memo.obscode].season == 'winter' ) { | |||
header += i18n[ 'season' ][ i18n[memo.obscode].season ][ memo.lang ]; | |||
} else { | } else { | ||
header += i18n[ 'year' ][ memo.lang ]; | |||
} | } | ||
header += ';' + i18n[ 'Observation' ][ memo.lang ]; | |||
header += ';' + i18n[ 'Value' ][ memo.lang ]; | |||
header += ';' + i18n[ 'ValueUnit' ][ memo.lang ]; | |||
header += ';' + i18n[ 'Additionalinfo' ][ memo.lang ]; | |||
header += ';' + i18n[ 'Image' ][ memo.lang ]; | |||
header += ';' + i18n[ 'ObserverStatus' ][ memo.lang ]; | |||
for ( var s in memo.seriesA ) { | |||
for ( var o in memo.seriesA[ s ].obses ) { | |||
obs = memo.seriesA[ s ].obses[ o ]; | |||
csv += '\r\n'; | |||
csv += obs.season + '-' + (obs.season+1); | |||
csv += ';' + i18n[ memo.seriesA[ s ].id ].title[ memo.lang ]; | |||
csv += ';' + obs.value; | |||
csv += ';' + obs.valueUnit; | |||
csv += ';' + obs.addInfo; | |||
csv += ';'; | |||
csv += ';' + obs.maintainer; | |||
} | |||
} | |||
} else if ( i18n[memo.obscode].type == 'cat' ) { | |||
header += 'Päivämäärä'; | |||
header += | header += ';' + 'Kellonaika'; | ||
header += ';' + i18n[memo.obscode].title[memo.lang]; | |||
header += ';' + i18n[memo.obscode].title[memo.lang]; | |||
header += ';' + utf8StringToUtf16String( 'Lisätiedot' ); | |||
header += ';' + 'Valokuva'; | |||
header += ';' + 'Havainnoijan status'; | |||
for ( var o in memo.obses ) { | |||
csv += '\r\n'; | csv += '\r\n'; | ||
csv += | csv += memo.obses[o].obsdatetime.toLocaleDateString(); //.toISOString(); | ||
if ( memo.obses[o].obsdatetime.getUTCHours() == 0 && memo.obses[o].obsdatetime.getUTCMinutes() == 0 && memo.obses[o].obsdatetime.getUTCSeconds() == 0 ) { | |||
csv += ';'; | |||
} else { | |||
csv += ';' + ( "0" + memo.obses[o].obsdatetime.getUTCHours() ).slice(-2) + ':' + ( "0" + memo.obses[o].obsdatetime.getUTCMinutes() ).slice(-2); | |||
} | |||
csv += ';' + i18n[ memo. | csv += ';' + memo.obses[o].value; | ||
csv += ';' + i18n[memo.obscode].catNames[memo.obses[o].value][memo.lang]; | |||
csv += ';' + | csv += ';' + memo.obses[o].addInfo; | ||
csv += ';'; | csv += ';'; | ||
csv += ';' + | csv += ';' + memo.obses[o].maintainer; | ||
} | } | ||
} | } | ||
csv = header + csv; | |||
var exportedFilename = memo.csvfile; | |||
var blob = new Blob( [csv], { type: 'text/csv;charset=utf-16LE;' }); | |||
if (navigator.msSaveBlob) { // IE 10+ | |||
navigator.msSaveBlob(blob, exportedFilename); | |||
} else { | |||
var link = document.createElement("a"); | |||
if (link.download !== undefined) { // feature detection | |||
// Browsers that support HTML5 download attribute | |||
var url = URL.createObjectURL(blob); | |||
link.setAttribute("href", url); | |||
link.setAttribute("download", exportedFilename); | |||
link.style.visibility = 'hidden'; | |||
document.body.appendChild(link); | |||
link.click(); | |||
document.body.removeChild(link); | |||
} | |||
} | |||
}); | |||
} | |||
// add show site link button | |||
if ( memo.showlink ) { | |||
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.on( 'click', function() { | |||
var elem = memo.widgetEl[0]; | |||
window.location.href = 'https://www.jarviwiki.fi/w/index.php?curid=' + memo.siteid; | |||
}); | |||
} | |||
} | |||
memo.loadStarts = 0; | |||
memo.obses = {}; | |||
memo.seriesO = {}; | |||
memo.trendlinesO = {}; | |||
memo.vaxisdir = 1; if (memo.obscode == 'secchi') { memo.vaxisdir = -1; } | |||
memo.showAverage = ( jQuery( this ).attr( 'data-show-average' ) != 'false' ); | |||
memo.showTrend = ( jQuery( this ).attr( 'data-show-trend' ) != 'false' ); | |||
memo.trendType = jQuery( this ).attr( 'data-trend-type' ); if (typeof memo.trendType == 'undefined') { memo.trendType = i18n[memo.obscode]['trend']['type']; } if (typeof memo.trendType == 'undefined') { memo.trendType = 'linear'; } | |||
memo.jw = new jwApi(); | |||
//memo.jwR = new jwApi(); | |||
var so = { 'startdate': memo.startDate, 'custom': '' }; | |||
//var so = { 'custom': '' }; | |||
if ( typeof memo.obscodeParts[1] != 'undefined' ) { | |||
if ( typeof memo.obscodeParts[2] != 'undefined' ) { | |||
so.custom += '[[' + i18n[memo.obscodeParts[0]].catName + '::' + memo.obscodeParts[2].split(',').join('||') +']]'; | |||
} else { | |||
so.custom += '[[' + i18n[memo.obscode].catName + '::>0]]'; | |||
} | |||
} | |||
if ( memo.refcode == '-' ) { | |||
so.obscode = memo.obscodeParts[0]; | |||
} else { | |||
so.custom += '[[ObsCode::' + memo.obscodeParts[0] + ' || ' + memo.refcode + ']]'; | |||
} | |||
} | if ( memo.siteid != '-' ) { | ||
so.siteid = memo.siteid; | |||
} else { | |||
so.waterbody = memo.waterbody; | |||
} | } | ||
if ( memo.siteid == '170072' ) { | |||
if ( memo. | so.test = true; | ||
memo. | } | ||
memo. | |||
memo | memo.jw.loadObses( so, function( o ) { | ||
memo.obses = memo.jw.obs; | |||
drawVisualization(memo); | |||
}); | |||
} else { | |||
if ( typeof window.jwobschart[id] == 'undefined' ) { | |||
hc++; | |||
} | } | ||
} | |||
}); | |||
if ( hc > 0 ) { | |||
setTimeout( loadObservations, 1000 ); | |||
} | |||
} | |||
} | function drawVisualization( memo ) { | ||
if ( typeof i18n[ memo.obscode ].direction != 'undefined' ) { memo.vaxisdir = i18n[ memo.obscode ].direction; } else { memo.vaxisdir = 1; } | |||
memo.options = { | |||
backgroundColor: 'transparent', | |||
chartArea: { backgroundColor: { fill: '#ffffff', stroke: colors['gridlines'], strokeWidth: 1 } }, | |||
legend: { position: 'bottom', textStyle: { color: colors['text'] } }, | |||
crosshair: { trigger: 'both' }, | |||
tooltip: { isHtml: true }, | |||
seriesType: 'scatter', | |||
interpolateNulls: true, | |||
vAxis: { | |||
title: i18n[memo.obscode]['axisTitleV'][memo.lang], | |||
titleTextStyle: { bold: true, italic: false, color: colors['text'] }, | |||
textStyle: { color: colors['text'] }, | |||
slantedText: false, | |||
maxAlternation: 1, | |||
direction: memo.vaxisdir, | |||
baselineColor: colors[ 'text' ], | |||
gridlines: { color: colors[ 'gridlines' ], Xcount: -1 }, | |||
minorGridlines: { count: 0 }, | |||
viewWindow: { } | |||
}, | |||
hAxis: { | |||
title: '', | |||
slantedText: false, | |||
textStyle: { color: colors['text'] }, | |||
maxAlternation: 1, | |||
gridlines: { color: colors[ 'gridlines' ] }, | |||
minorGridlines: { count: 0 }, | |||
viewWindow: { } | |||
}, | |||
series: [ ], | |||
trendlines: [ ], | |||
intervals: { | |||
'style': 'area', | |||
'color': colors['averageare'], | |||
'fillOpacity': 0.33 | |||
}, | |||
annotations: { | |||
textStyle: { | |||
fontName: 'Open sans', | |||
fontSize: 15, | |||
bold: true, | |||
color: colors['text'], | |||
auraColor: 'transparent' | |||
} | |||
} | |||
}; | |||
memo.obsesTotal = 0; | |||
memo.obsMinValue = Infinity; | |||
memo.obsMaxValue = -Infinity; | |||
memo.obsMinDateMs = Infinity; | |||
memo.obsMaxDateMs = -Infinity; | |||
memo.obsMinCompDateMs = Infinity; | |||
memo.obsMaxCompDateMs = -Infinity; | |||
memo.season = i18n[memo.obscode]['season']; | |||
if ( memo.season == 'summer' || today.getMonth() > 7 ) { | |||
memo.curSeason = today.getFullYear(); | |||
} else { | |||
memo.curSeason = today.getFullYear()-1; | |||
} | |||
// first loop | |||
for ( var o in memo.obses ) { | |||
obs = memo.obses[o]; | |||
memo. | memo.obsesTotal++; | ||
// create data | |||
obs.data = JSON.parse( obs.printouts.DataJSON ); | |||
if ( obs.data.unit == 'cm' && i18n[memo.obscode]['unit'] == 'm' ) { | |||
obs.data.val = obs.data.val/100; | |||
obs.value = obs.value/100; | |||
} | } | ||
if ( memo. | // add season | ||
if ( memo.season == 'winter' && obs.obsdatetime.getMonth() > -1 && obs.obsdatetime.getMonth() < 8 ) { | |||
obs.season = obs.obsdatetime.getFullYear()-1; | |||
} else { | } else { | ||
obs.season = obs.obsdatetime.getFullYear(); | |||
} | } | ||
if ( memo.season == 'winter' ) { | |||
if ( memo. | obs.seasonmiddle = new Date( obs.season+1, 0, 1 ); | ||
} else { | } else { | ||
obs.seasonmiddle = new Date( obs.season, 5, 1 ); | |||
} | |||
// create addinfo | |||
obs.addInfo = ""; | |||
if ( !!obs.media_url ) { | |||
obs.img = new Image(); | |||
obs.img.src = obs.media_url; | |||
obs.addInfo = '<img style="object-fit: cover; width: 200px; height: 200px; margin: 5px 0 8px 0;" src="' + obs.media_url + '" />'; | |||
} | } | ||
if ( !!obs.printouts[ 'Lisätiedot' ][0] ) { | |||
obs.addInfo += '<p>' + obs.printouts[ 'Lisätiedot' ][0] + '</p>'; | |||
} | } | ||
memo.obsMinValue = Math.min( memo.obsMinValue, obs.value ); | |||
memo.obsMaxValue = Math.max( memo.obsMaxValue, obs.value ); | |||
memo.obsMinDateMs = Math.min( memo.obsMinDateMs, obs.obsdatetime.getTime() ); | |||
memo.obsMaxDateMs = Math.max( memo.obsMaxDateMs, obs.obsdatetime.getTime() ); | |||
// add compare date to obses | |||
if ( memo.season == 'summer' || obs.obsdatetime.getMonth() > 7 ) { | |||
obs.compareDate = new Date( memo.curSeason, obs.obsdatetime.getMonth(), obs.obsdatetime.getDate() ); | |||
} else { | |||
obs.compareDate = new Date( memo.curSeason+1, obs.obsdatetime.getMonth(), obs.obsdatetime.getDate() ); | |||
} | |||
obs.compareDate.setHours( 12 ); | |||
ms = obs.compareDate.getTime(); | |||
memo.obsMinCompDateMs = Math.min(ms, memo.obsMinCompDateMs); | |||
memo.obsMaxCompDateMs = Math.max(ms, memo.obsMaxCompDateMs); | |||
// add series id | |||
if ( memo.graphType == 'trend' ) { | |||
if ( memo.divide == 'summerwinter' ) { | |||
if ( obs.compareDate.getMonth() > 4 && obs.compareDate.getMonth() < 9 ) { | |||
obs.seriesId = 'summer'; | |||
} else if ( obs.compareDate.getMonth() > -1 && obs.compareDate.getMonth() < 4 ) { | |||
obs.seriesId = 'winter'; | |||
} else { | |||
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 { | |||
obs.seriesId = 0; | |||
} | |||
} else if ( memo.graphType == 'dateofyear' ) { | |||
obs.seriesId = memo.obscodeParts[0] + '_cat_' + obs.data.cat; | |||
} else if ( memo.season == 'summer' || obs.obsdatetime.getMonth() > 7 ) { | |||
obs.seriesId = obs.obsdatetime.getFullYear(); | |||
} else { | |||
obs.seriesId = obs.obsdatetime.getFullYear()-1; | |||
} | |||
// create popup for obs | |||
obs.popup = '<div style="padding: 8px; white-space: normal;">'; | |||
obs.popup += '<div>'; | |||
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') { | |||
obs.popup +='<b>' + i18n[memo.obscode]['title'][memo.lang] + '</b> '; | |||
} 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.obsdatetime.inRelationToToday(memo.lang) + ')'; | |||
obs.popup += '</div>'; | |||
if (!!obs.addInfo) { | |||
obs.popup += '<div style="margin-top: 5px;">' + obs.addInfo + '</div>'; | |||
} | |||
obs.popup += '</div>'; | |||
} | |||
memo.obsMinDate = new Date( memo.obsMinDateMs ); | |||
memo.obsMaxDate = new Date( memo.obsMaxDateMs ); | |||
memo.obsMinYear = memo.obsMinDate.getFullYear(); | |||
memo.obsMaxYear = memo.obsMaxDate.getFullYear(); | |||
memo.obsMinCompDate = new Date( memo.obsMinCompDateMs ); | |||
memo.obsMaxCompDate = new Date( memo.obsMaxCompDateMs ); | |||
memo.obsesA = []; memo.dataA = []; memo.depthsO = {}; | |||
for ( var o in memo.obses ) { | |||
obs = memo.obses[o]; | |||
// style points | |||
if ( obs.seriesId == memo.curSeason ) { | |||
baseSize = 7; | |||
strokeSize = 2; | |||
} else if (memo.obsesTotal < 100) { | |||
baseSize = 6; | |||
strokeSize = 1.25; | |||
} else if (memo.obsesTotal < 200) { | |||
baseSize = 5; | |||
strokeSize = 0.53; | |||
} else { | |||
baseSize = 4; | |||
strokeSize = 0.25; | |||
} | |||
if ( memo.maintainerShow ) { maintcol = maintColors[obs.maintainer]; } | |||
else { maintcol = '#ffffff'; } //'transparent'; } | |||
if (!!obs.addInfo) { | |||
obs.style = 'point { shape-type: star; size: ' + (baseSize+3) + '; shape-dent: 0.5; stroke-width: ' + strokeSize + '; stroke-color: ' + maintcol + '; }'; | |||
} else { | |||
obs.style = 'point { size: ' + baseSize + '; stroke-width: ' + strokeSize + '; stroke-color: ' + maintcol + '; }'; | |||
} | |||
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 ); | |||
} | |||
} | |||
} | } | ||
// | // sort | ||
memo.obsesA.sort( function(a, b) { return a.obsdatetime - b.obsdatetime; }); | |||
// create DataTable | |||
memo.data = new google.visualization.DataTable(); | |||
// col for xAxis values | |||
memo.data.addColumn( 'date', 'time' ); | |||
// | |||
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 ( | |||
if ( depthcats.length == 1 ) { | |||
if ( depthcats[0] == 'surface' ) { | |||
memo.title = memo.title.replace( '[D]', '(' + i18n[ 'surface' ][ memo.lang ] + ')' ); | |||
} else if ( depthcats[0] == 'bottom' ) { | |||
memo.title = memo.title.replace( '[D]', '(' + i18n[ 'bottom' ][ memo.lang ] + ')' ); | |||
} | |||
} else if ( depthcats.length == 2 ) { | |||
} else { | } else { | ||
} | } | ||
// | // make ticks for y axis on cat types | ||
if ( memo.obsesA.length > 0 && memo.graphType != 'current' ) { | |||
if ( i18n[memo.obscode]['type'] == 'cat') { | |||
memo.options.vAxis.format = '0'; | |||
memo.options.vAxis.ticks = []; | |||
for (var c in i18n[memo.obscode]['catNamesShort']) { | |||
memo.options.vAxis.ticks.push({v: parseInt(c), f: i18n[memo.obscode]['catNamesShort'][c][memo.lang] }); | |||
memo.options.vAxis.ticks.push({v: parseInt(c)+0.5, f: '' }); | |||
} | |||
memo.options.vAxis.ticks.sort( function(a, b) { return a.v-b.v } ); | |||
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 = memo.options.vAxis.viewWindow.max; | |||
memo.options.vAxis.gridlines.color = colors['gridlines']; | |||
memo.options.vAxis.baselineColor = colors['text']; | |||
} else { | |||
if ( typeof i18n[memo.obscode]['min'] != 'undefined' ) { | |||
if ( i18n[memo.obscode]['min'] != -999 ) { | |||
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 { | |||
// | |||
} | |||
if ( typeof i18n[memo.obscode]['max'] != 'undefined' ) { | |||
if ( i18n[memo.obscode]['max'] != -999 ) { | |||
memo.options.vAxis.viewWindow.max = i18n[memo.obscode]['max']; | |||
} | |||
} | |||
} | |||
memo.titleEl.html( memo.title ); | |||
if ( typeof i18n[ memo.obscode ].changes != 'undefined' ) { | |||
if ( typeof typeof i18n[ memo.obscode ].changes[ memo.lang ] != 'undefined' ) { | |||
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="' + i18n[ memo.obscode ].changes[ memo.lang ] + '">' + i18n[ 'new' ][ memo.lang ] + '</button>' ); | |||
jQuery( '[data-toggle="tooltip"]' ).tooltip(); | |||
} | |||
} | |||
if ( memo.info == '' ) { | |||
if ( memo.siteid != '-' && memo.addsitetoinfo ) { | |||
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 != '' ) { | |||
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(); | |||
} | |||
} | } | ||
if ( memo.obsesA.length == 0 ) { | |||
console.log( 'No obses' ); | |||
} else if (memo.graphType == 'trend') { | |||
addDataToTrendChart(memo); | |||
} else if (memo.graphType == 'seasonwithrefs') { | |||
addDataToSeasonWithRefsChart(memo); | |||
} else if (memo.graphType == 'trendwithhighlow') { | |||
addDataToTrendWithHighLowChart(memo); | |||
} else if (memo.graphType == 'season') { | |||
addDataToSeasonChart(memo); | |||
if ( memo. | } else if (memo.graphType == 'dateofyear') { | ||
addDataToDateOfYearChart( memo ); | |||
} | |||
} | } | ||
// | function addDataToDateOfYearChart( memo ) { | ||
// do X axis min and max for this chart type | |||
memo.options.hAxis.minValue = new Date( memo.obsMinDateMs ); | |||
if ( memo.season = 'winter' && memo.options.hAxis.minValue.getMonth() < 8 ) { memo.options.hAxis.minValue.setFullYear( memo.options.hAxis.minValue.getFullYear()-1 ); } | |||
memo.options.hAxis.minValue.setMonth(0); | |||
memo.options.hAxis.minValue.setDate(1); | |||
memo.options.hAxis.viewWindow.min = memo.options.hAxis.minValue; | |||
memo.options.hAxis.maxValue = new Date( memo.obsMaxDateMs ); | |||
if ( memo.season = 'winter' && memo.options.hAxis.maxValue.getMonth() > 7 ) { memo.options.hAxis.maxValue.setFullYear( memo.options.hAxis.maxValue.getFullYear()+1 ); } | |||
else { memo.options.hAxis.maxValue.setFullYear( memo.options.hAxis.maxValue.getFullYear()+1 ); } | |||
memo.options.hAxis.maxValue.setMonth(11); | |||
memo.options.hAxis.maxValue.setDate(31); | |||
memo.options.hAxis.viewWindow.max = memo.options.hAxis.maxValue; | |||
// do Y axis min and max for this chart type | |||
memo.options.vAxis.viewWindow.min = new Date( memo.obsMinCompDate.getTime() ); | |||
memo.options.vAxis.viewWindow.min.setDate(1); | |||
memo.options.vAxis.viewWindow.min.setHours( 0, 0, 0 ); | |||
memo.options.vAxis.viewWindow.max = new Date( memo.obsMaxCompDate.getTime() ); | |||
memo.options.vAxis.viewWindow.max.setMonth( memo.options.vAxis.viewWindow.max.getMonth()+1 ); | |||
memo.options.vAxis.viewWindow.max.setDate(0); | |||
memo.options.vAxis.viewWindow.max.setHours( 0, 0, 0 ); | |||
// do Y axis ticks and gridlines | |||
memo.options.vAxis.ticks = []; | |||
memo.vAxisGridlines = []; | |||
memo.options.vAxis.gridlines = { color: 'transparent' }; | |||
memo.options.vAxis.minorGridlines = { color: 'transparent' }; | |||
minM = memo.options.vAxis.viewWindow.min.getMonth(); | |||
maxM = memo.options.vAxis.viewWindow.max.getMonth(); | |||
if ( minM > maxM ) { mc = 13-minM+maxM; } | |||
else { mc = maxM-minM+1; } | |||
for ( mi = 0; mi < mc; mi++ ) { | |||
mx = minM+mi; | |||
yx = memo.options.vAxis.viewWindow.min.getFullYear(); | |||
if ( mx > 11 ) { yx = memo.options.vAxis.viewWindow.max.getFullYear(); mx = mx - 12; } | |||
startOfMonth = new Date( yx, mx, 1 ); | |||
middleOfMonth = new Date( yx, mx, 15 ); | |||
// ticks | |||
memo.options.vAxis.ticks.push( { v: middleOfMonth, f: i18n['months'][mx]['long'][memo.lang] } ); | |||
// gridlines except for first | |||
if (mi > 0) { | |||
memo.vAxisGridlines.push( new Date( startOfMonth.getTime() ) ); | |||
} | |||
} | |||
memo.seriesO = {}; | |||
for ( var o in memo.obsesA ) { | |||
obs = memo.obsesA[ o ]; | |||
s = obs.seriesId; | |||
if ( typeof memo.seriesO[ s ] == 'undefined' ) { | |||
memo.seriesO[ s ] = { 'id': s, 'order': parseInt( obs.data.cat ), 'title': i18n[ s ].title[ memo.lang ], 'type': 'scatter', 'color': i18n[ s ].color, 'obses': [] }; | |||
if ( typeof | |||
} | } | ||
} | obs.xvalue = obs.seasonmiddle; | ||
obs.yvalue = obs.compareDate; | |||
obs.value = obs.obsdatetime.toLocaleDateString( memo.lang ); | |||
obs.valueUnit = i18n[ 'Date' ][ memo.lang ]; | |||
obs.tooltip = '<p><b>' + i18n[ 'season' ][ 'winter' ][ memo.lang ] + ' ' + obs.season + '–' + (obs.season+1) + '</b></p>'; | |||
obs.tooltip += '<p>' + i18n[ s ].title2[ memo.lang ] + ': ' + obs.obsdatetime.toLocaleDateString( memo.lang ) + '</p>'; | |||
obs.tooltip += obs.addInfo; | |||
memo.seriesO[ s ].obses.push( obs ); | |||
} | |||
// create ice cover series | |||
if ( memo.obscode == 'ice_cat_2,5' ) { | |||
// | memo.obsesS = {}; | ||
for ( var o in memo.obsesA ) { | |||
if ( | var obs = memo.obsesA[ o ]; | ||
if ( typeof memo.obsesS[ obs.season ] == 'undefined' ) { | |||
memo.obsesS[ obs.season ] = { 'maintainer': obs.maintainer }; | |||
} | |||
if ( obs.data.cat == '2' ) { | |||
memo.obsesS[ obs.season ][ 'low' ] = obs.compareDate; | |||
} else if ( obs.data.cat == '5' ) { | |||
memo.obsesS[ obs.season ][ 'high' ] = obs.compareDate; | |||
} | |||
if ( memo.obsesS[ obs.season ][ 'maintainer' ] != obs.maintainer ) { memo.obsesS[ obs.season ][ 'maintainer' ] = ''; } | |||
if ( typeof memo.obsesS[ obs.season ][ 'low' ] != 'undefined' && typeof memo.obsesS[ obs.season ][ 'high' ] != 'undefined' ) { | |||
days = Math.round( ( memo.obsesS[ obs.season ][ 'high' ].getTime() - memo.obsesS[ obs.season ][ 'low' ].getTime() ) / ( 1000*60*60*24 ) ); | |||
if ( typeof memo.seriesO[ 'ice_cat_2,5' ] == 'undefined' ) { | |||
memo.seriesO[ 'ice_cat_2,5' ] = { 'id': 'ice_cat_2,5', 'order': 10, 'title': i18n[ 'ice_cat_2,5' ].title[ memo.lang ], 'type': 'candlestick', 'color': i18n[ 'ice_cat_2,5' ].color, obses: [] }; | |||
} | |||
memo.seriesO[ 'ice_cat_2,5' ].obses.push( { 'obsdatetime': obs.obsdatetime, 'season': obs.season, 'value': days, 'valueUnit': i18n[ 'days' ][ memo.lang ], 'addInfo': '', 'maintainer': memo.obsesS[ obs.season ][ 'maintainer' ], 'xvalue': obs.seasonmiddle, 'low': memo.obsesS[ obs.season ][ 'low' ], 'high': memo.obsesS[ obs.season ][ 'high' ], 'tooltip': '<p><b>' + i18n[ 'season' ][ 'winter' ][ memo.lang ] + ' ' + obs.season + '–' + (obs.season+1) + '</b></p><p>' + i18n[ 'ice_cat_2,5' ].title[ memo.lang ] + ': ' + days + ' ' + i18n[ 'days' ][ memo.lang ] + '</p>' } ); | |||
} | |||
} | |||
} | |||
memo.seriesA = []; for ( var s in memo.seriesO ) { memo.seriesA.push( memo.seriesO[s] ) }; | |||
memo.seriesA.sort( function( a, b ) { return a.order-b.order; } ); | |||
for ( var s in memo.seriesA ) { | |||
if ( memo.seriesA[ s ].type == 'scatter' ) { | |||
memo.data.addColumn( 'date', memo.seriesA[ s ].title ); // + ' ' + memo.obsMinYear + '-' + memo.obsMaxYear ); | |||
memo.data.addColumn( { type: 'string', 'role': 'style' } ); | |||
memo.data.addColumn( { type: 'string', role: 'tooltip', 'p': { 'html': true } } ); | |||
memo.data.addColumn( { type: 'string', role: 'annotation' } ); | |||
memo.options.series.push( { type: 'scatter', pointType: 'circle', pointSize: 10, color: memo.seriesA[ s ].color } ); | |||
if ( memo.seriesA[ s ].obses.length > 4 ) { | |||
memo.options.trendlines[ memo.options.series.length - 1 ] = { type: 'linear', title: i18n.trendline, lineWidth: 3, visibleInLegend: false, tooltip: false }; | |||
} else { | |||
memo.options.trendlines[ memo.options.series.length - 1 ] = { type: 'linear', title: i18n.trendline, lineWidth: 0, color: 'transparent', visibleInLegend: false, tooltip: false }; | |||
} | |||
} else if ( memo.seriesA[ s ].type == 'candlestick' ) { | |||
memo.data.addColumn( 'date', memo.seriesA[ s ].title ); | |||
memo.data.addColumn( 'date', '' ); | |||
memo.data.addColumn( 'date', '' ); | |||
memo.data.addColumn( 'date', '' ); | |||
memo.data.addColumn({ role: 'tooltip', 'p': { 'html': true } }); | |||
memo.options.series.push( { type: 'candlesticks', color: memo.seriesA[ s ].color, strokeWidth: 2, stroke: '#cccccc' } ); | |||
} | |||
} | |||
// add data to table | |||
cc = memo.data.getNumberOfColumns(); | |||
var st = 0; | |||
for ( var s in memo.seriesA ) { | |||
for ( var o in memo.seriesA[ s ].obses ) { | |||
obs = memo.seriesA[ s ].obses[ o ]; | |||
dataRow = []; | |||
// fill row with nulls | |||
for ( var i=0; i<cc; i++ ) { dataRow.push( null ); } | |||
// x axis value | |||
dataRow[ 0 ] = obs.xvalue; | |||
if ( memo.seriesA[ s ].type == 'candlestick' ) { | |||
dataRow[ st+1 ] = obs.low; | |||
dataRow[ st+2 ] = obs.low; | |||
dataRow[ st+3 ] = obs.high; | |||
dataRow[ st+4 ] = obs.high; | |||
dataRow[ st+5 ] = obs.tooltip; | |||
} else if ( memo.seriesA[ s ].type == 'scatter' ) { | |||
dataRow[ st+1 ] = obs.yvalue; | |||
dataRow[ st+2 ] = obs.style; | |||
dataRow[ st+3 ] = obs.tooltip; | |||
dataRow[ st+4 ] = null; | |||
} | |||
memo.dataA.push( dataRow ); | |||
} | } | ||
if ( | if ( memo.seriesA[ s ].type == 'candlestick' ) { | ||
st += 5; | |||
} else if ( | } else if ( memo.seriesA[ s ].type == 'scatter' ) { | ||
st += 4; | |||
} | } | ||
} | |||
memo.options.hAxis.ticks = []; | |||
if ( | var years = memo.options.hAxis.maxValue.getFullYear() - memo.options.hAxis.minValue.getFullYear(); | ||
memo. | for (i=memo.options.hAxis.minValue.getFullYear(); i<=memo.options.hAxis.maxValue.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) }); | |||
} | |||
} else if ( years > 11 ) { | |||
if ( i % 5 == 0 ) { | |||
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) }); | |||
} | } | ||
memo. | } else { | ||
memo.options.hAxis.ticks.push({v: middleOfYear, f: String(i) }); | |||
} | |||
} | |||
memo.options.hAxis.gridlines.color = 'transparent'; | |||
memo.options.vAxis.gridlines.color = '#cccccc'; | |||
drawChart(memo); | |||
} | } | ||
memo. | function addDataToSeasonWithRefsChart(memo) { | ||
console.log( 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', '1991-2020' ); | |||
memo.data.addColumn( { id:'i0', type:'number', role:'interval' } ); | |||
memo.data.addColumn( { id:'i0', type:'number', role:'interval' } ); | |||
memo.data.addColumn( { type: 'string', role: 'tooltip', 'p': { 'html': true } } ); | |||
memo.data.addColumn( 'number', memo.curSeason ); | |||
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) { | |||
if ( memo.obsesA[o].printouts.ObsCode == memo.refcode ) { | |||
memo.obsesA[o].compareDate = getDateOfISOWeek( memo.obsesA[o].data.week, memo.curSeason ) | |||
memo.obsesA[o].compareDate.setDate( memo.obsesA[o].compareDate.getDate() + 3 ); | |||
memo.obsesA[o].compareDate.setHours( 12 ); | |||
} | |||
} | |||
var weekdata = []; | |||
for ( var w=1; w<=53; w++ ) { | |||
weekdata.push( { 'week': w, 'val': null, 'mw': null, 'low': null, 'high': null, 'style': null } ); | |||
} | |||
if ( memo. | for (var o in memo.obsesA) { | ||
memo. | if ( memo.obsesA[ o ].printouts.ObsCode == memo.obscode ) { | ||
weekdata[ memo.obsesA[ o ].data.week-1 ].val = memo.obsesA[ o ].data.val; | |||
weekdata[ memo.obsesA[ o ].data.week-1 ].style = memo.obsesA[ o ].style; | |||
} else { | } else { | ||
memo. | weekdata[ memo.obsesA[ o ].data.week-1 ].mw = memo.obsesA[ o ].data.val; | ||
} | weekdata[ memo.obsesA[ o ].data.week-1 ].low = memo.obsesA[ o ].data.low / 100; | ||
weekdata[ memo.obsesA[ o ].data.week-1 ].high = memo.obsesA[ o ].data.high / 100; | |||
} | |||
} | |||
for ( var w in weekdata ) { | |||
mow = getDateOfISOWeek( weekdata[w].week, memo.curSeason ); | |||
mow.setDate( mow.getDate() + 3 ); | |||
memo. | memo.dataA.push( [ | ||
mow, | |||
weekdata[w].mw, | |||
weekdata[w].low, | |||
weekdata[w].high, | |||
'<div style="padding: 5px;"><b>Vertailukauden 1991-2020 havainnot viikolla ' + weekdata[w].week + '</b><br />Suurin arvo (HW): ' + weekdata[w].high + '<br />Keskiarvo (MW): ' + weekdata[w].mw + '<br />Pienin arvo (LW): ' + weekdata[w].low + '</div>', | |||
weekdata[w].val, | |||
weekdata[w].style, | |||
null, | |||
'<div style="padding: 5px;"><b>Kuluvan vuoden vedenkorkeus viikolla ' + weekdata[w].week + '</b><br />Keskiarvo (MW): ' + weekdata[w].val + '</div>', | |||
] ); | |||
} | |||
// make ticks for x axis | |||
memo.options.hAxis.ticks = []; | |||
for (i=0; i<12; i++) { | |||
//m = i+1; | |||
middleOfMonth = new Date( memo.curSeason, i, 16 ); | |||
memo.options.hAxis.ticks.push({v: middleOfMonth, f: i18n.months[i]['roman'] }); | |||
} | } | ||
memo.options.seriesType = 'line'; | |||
memo.options.series[0] = { type: 'line', pointSize: 0, color: colors.average, lineWidth: 2.33 }; | |||
memo.options.curveType = 'function'; | |||
//memo.options.intervals = { 'style': 'area', 'color': colors['averageare'] }; | |||
memo.options.series[1] = { type: 'line', pointSize: 10, color: colors.curObses, lineWidth: 5 }; | |||
//memo.options.vAxis.viewWindow.min = 80.5; | |||
//memo.options.vAxis.viewWindow.max = 81.7; | |||
memo.chart = new google.visualization.LineChart( memo.chartEl[0] ); // document.getElementById(memo.id) | |||
drawChart(memo); | |||
} | |||
function addDataToTrendWithHighLowChart (memo) { | |||
// do axis min and max | |||
memo.axisMinDate = new Date(memo.obsMinDate.getTime()); | |||
memo.axisMaxDate = new Date(memo.obsMaxDate.getTime()); | |||
memo.axisMinDate.setMonth(0); | |||
memo.axisMaxDate.setMonth(11); | |||
memo.axisMinDate.setDate(1); | |||
memo.axisMaxDate.setDate(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: 10, color: colors['curObses'] }; | |||
memo.options.curveType = 'function'; | |||
//memo.options.intervals = { 'style': 'area', 'color': colors['averageare'] }; | |||
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 addDataToTrendChart(memo) { | |||
if ( memo.trendType == 'gaussian' ) { memo.trendType = 'linear'; }; | |||
// do axis min and max | |||
memo.axisMinDate = new Date(memo.obsMinDate.getTime()); | |||
memo.axisMaxDate = new Date(memo.obsMaxDate.getTime()); | |||
memo.axisMinDate.setMonth(0); | |||
memo.axisMaxDate.setMonth(11); | |||
memo.axisMinDate.setDate(1); | |||
memo.axisMaxDate.setDate(31); | |||
memo. | if ( memo.obsesA.length < memo.divideCond ) { memo.divide = '-'; } | ||
if ( memo.divide == 'summerwinter' ) { | |||
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', 'Kevät/syksy' ); | |||
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', '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 } } ); | |||
memo.data.addColumn( 'number', 'Talvi (tammi-huhtikuu)' ); | |||
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 == 'summerother' ) { | |||
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', 'Muu vuodenaika' ); | |||
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', '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. | 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) { | |||
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.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 { | |||
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) }); | |||
} | |||
} else if ( years > 11 ) { | |||
if ( i % 5 == 0 ) { | |||
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 { | |||
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 = []; | |||
for (var o in memo.obsesA) { | |||
s = memo.obsesA[o].seriesId; | |||
if (typeof memo.seasonsO[s] == 'undefined' ) { memo.seasonsO[s] = { 'obses': [] }; } | |||
for (var | 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' ) { | |||
if ( memo. | memo.data.addColumn( 'number', memo.seasonsA[s].toString() ); | ||
memo. | |||
} else { | } else { | ||
if ( memo. | memo.data.addColumn( 'number', memo.seasonsA[s].toString() + '-' + (parseInt(memo.seasonsA[s])+1).toString() ); | ||
memo.options.series[sc++] = { type: ' | } | ||
// 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 }; | |||
} else { | } else { | ||
memo.options.series[sc++] = { type: 'scatter', curveType: 'function', color: colors['curObses'], | 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 { | } else { | ||
memo.options.series[sc++] = { type: ' | 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 }; | |||
memo.options.series[sc++] = { type: ' | |||
// do average | |||
if (memo.trendType == 'gaussian') { | |||
memo.gSmoothing = 4; | |||
if ( i18n[memo.obscode]['type'] == 'cat') { | |||
memo.distF = 0.1; | |||
} else { | |||
memo.distF = 0; | |||
} | |||
// 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.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 ( memo.season == 'winter' && w == 1 && y == memo.curSeason ) { y++; } | |||
if ( typeof memo.avgW[y] == 'undefined' ) { memo.avgW[y] = {}; } | |||
if ( typeof memo.avgW[y][w] == 'undefined' ) { | |||
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; | |||
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 ); | |||
memo. | |||
} | } | ||
} | } | ||
} | |||
for ( var i=0; i<memo.avgMlist.length; i++ ) { | |||
if ( memo.avgMlist[i] === null ) { | |||
lastM = memo.avgMlist[i-1]; | |||
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 | |||
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 ); | |||
if ( xdate.getTime() < memo.axisMinDate.getTime() ) { | |||
dataRow[0] = memo.axisMinDate; | |||
} else if ( xdate.getTime() > memo.axisMaxDate.getTime() ) { | |||
dataRow[0] = memo.axisMaxDate; | |||
} else { | |||
dataRow[0] = xdate; //new Date( memo.avgW[firstY][firstW].cDate.getTime() + ( i + 1 - memo.gSmoothing/2 ) * msW ); | |||
} | |||
dataRow[cc-4] = memo.avgMsmooth[i]; | |||
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 ); | |||
} | |||
} 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 ) ) { | |||
y = obs.mwDate.getFullYear(); | |||
w = obs.mwDate.getWeek(); | |||
if ( memo.season == 'winter' && w == 1 && y == memo.curSeason ) { y++; } | |||
var diff = obs.value - memo.avgW[ y ][ w ].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 ); | |||
} | } | ||
} | |||
// 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) { | |||
m | memo.options.hAxis.ticks.push({v: middleOfMonth, f: i18n.months[m]['long'][memo.lang] }); | ||
} else if ( mCount < 10 ) { | |||
memo.options.hAxis.ticks.push({v: middleOfMonth, f: i18n.months[m]['short'][memo.lang] }); | |||
} else { | |||
memo.options.hAxis.ticks.push({v: middleOfMonth, f: i18n.months[m]['roman'] }); | |||
} | |||
} | } | ||
if ( memo.obscode == 'level' ) { | |||
memo.options.vAxis.viewWindow.min = Math.floor( memo.obsMinValue * 10 ) / 10; | |||
memo.options.vAxis.viewWindow.max = Math.ceil( memo.obsMaxValue * 10 ) / 10 ; | |||
} | |||
//console.log( memo ); | |||
drawChart( memo ); | |||
} | } | ||
drawChart(memo) | function drawChart(memo) { | ||
memo.loaderEl.fadeOut( "slow", function() { memo.loaderEl.remove(); } ); | |||
if (memo.dataA.length > 0) { | |||
memo.data.addRows(memo.dataA); | |||
if ( typeof memo.chart == 'undefined' ) { | |||
memo.chart = new google.visualization.ComboChart( memo.chartEl[0] ); // document.getElementById(memo.id) | |||
} | |||
memo.fullscreenEl.fadeIn( "slow" ); | |||
if ( memo.download) { memo.downloadEl.fadeIn( "slow" ); } | |||
if ( memo.showlink ) { memo.sitelinkEl.fadeIn( "slow" ); } | |||
memo.selectedCol = 0; | |||
google.visualization.events.addListener( memo.chart, 'select', function () { | |||
var selection = memo.chart.getSelection(); | |||
if (selection.length > 0) { | |||
var col = selection[0].column; | |||
for (var c in memo.options.series) { | |||
if (memo.options.series[c].hideThis) { | |||
memo.options.series[c].lineWidth = 0; | |||
memo.options.series[c].color = colors['obses']; | |||
memo.options.series[c].visibleInLegend = false; | |||
} | |||
} | |||
if (col != memo.selectedCol && memo.options.series[(col-1)/4].hideThis) { | |||
memo.selectedCol = col; | |||
memo.options.series[(col-1)/4].lineWidth = 3; | |||
memo.options.series[(col-1)/4].color = colors['selObses']; | |||
memo. | memo.options.series[(col-1)/4].visibleInLegend = true; | ||
} else { | |||
memo.options.series[ | memo.selectedCol = 0; | ||
memo.options.series[ | |||
} | } | ||
} else { | } else { | ||
memo.selectedCol = 0; | memo.selectedCol = 0; | ||
for (var c in memo.options.series) { | |||
if (memo.options.series[c].hideThis) { | |||
memo.options.series[c].lineWidth = 0; | |||
memo.options.series[c].color = colors['obses']; | |||
memo.options.series[c].visibleInLegend = false; | |||
} | |||
} | |||
} | } | ||
doResize( memo, true ); | |||
}); | |||
google.visualization.events.addListener( memo.chart, 'ready', function () { | |||
// hide every second vaxis gridline on cat charts | |||
if ( i18n[memo.obscode]['type'] == 'cat') { | |||
var glc = 0; | |||
jQuery( document.getElementById(memo.id) ).find( 'rect[height="1"]' ).each( function() { | |||
} | if ( ( glc++ % 2 ) == 0 ) { | ||
jQuery( this ).attr( 'fill', 'none' ); | |||
} | |||
}); | |||
} | } | ||
// add dash to trendlines | |||
jQuery( document.getElementById(memo.id) ).find( 'path[stroke-width="2.33"]' ).each( function() { | |||
jQuery( this ).attr('stroke-dasharray', '5, 5'); | |||
}); | |||
// move current observations to top | |||
gEl = jQuery( document.getElementById(memo.id) ).find( 'svg' ).append( 'g' ); | |||
jQuery( document.getElementById(memo.id) ).find( 'path[stroke="' + colors['curObses'] + '"]' ).detach().appendTo( gEl ); | |||
jQuery( document.getElementById(memo.id) ).find( 'circle[fill="' + colors['curObses'] + '"]' ).detach().appendTo( gEl ); | |||
jQuery( document.getElementById(memo.id) ).find( 'path[fill="' + colors['curObses'] + '"]' ).detach().appendTo( gEl ); | |||
// move selected observations to top | |||
jQuery( document.getElementById(memo.id) ).find( 'path[stroke="' + colors['selObses'] + '"]' ).detach().appendTo( gEl ); | |||
jQuery( document.getElementById(memo.id) ).find( 'circle[fill="' + colors['selObses'] + '"]' ).detach().appendTo( gEl ); | |||
}); | |||
} else { | |||
jQuery( jQuery( document.getElementById(memo.id) ) ).hide(); | |||
} | |||
doResize( memo ); | |||
} | |||
var doResize = function( memo, force = false ) { | |||
console.log( 'reize'); | |||
function wait() { | |||
memo. | if ( typeof memo.chartEl != 'undefined' && typeof memo.options != 'undefined' ) { | ||
var w = memo.chartEl.width(); | var w = memo.chartEl.width(); | ||
var h = memo.chartEl.height(); | var h = memo.chartEl.height(); | ||
if ( typeof memo.oldW == 'undefined' ) { memo.oldW = 1; } | |||
if ( typeof memo.oldH == 'undefined' ) { memo.oldH = 1; } | |||
if ( ( w != memo.oldW || h != memo.oldH ) && w*h != 0 || force ) { | |||
memo.oldW = w; memo.oldH = h; | |||
memo.margins = { top: 10, right: 10, bottom: 80, left: 80 }; | |||
var w = memo.chartEl.width(); | |||
var h = memo.chartEl.height(); | |||
var l = Math.max( memo.margins.left, 0.1*w ); | |||
var r = Math.max( memo.margins.right, 0.02*w ); | |||
var t = Math.max( memo.margins.top, 0.02*h ); | |||
var b = Math.max( memo.margins.bottom, 0.15*h ); | |||
memo.options.chartArea.top = t; | |||
memo.options.chartArea.left = l; | |||
memo.options.chartArea.width = (w - l - r); | |||
memo.options.chartArea.height = (h - t - b); | |||
for ( var o in memo.data.Wf ) { | |||
for ( var i in memo.data.Wf[ o ].c ) { | |||
v = memo.data.Wf[ o ].c[ i ].v; | |||
if ( typeof v == 'string' ) { | |||
if ( v.indexOf( 'point {' ) == 0 ) { | |||
oldsize = parseInt( v.match( / size: .+;/g )[0].replace( ' size: ', '' ).replace( ';', '') ); | |||
oldstroke = parseFloat( v.match( / stroke-width: .+;/g )[0].replace( ' stroke-width: ', '' ).replace( ';', '') ); | |||
if ( v.indexOf( 'original-size:' ) == -1 ) { | |||
v = v.replace( '{', '{ original-size: ' + oldsize.toString() + ';' ); | |||
} | |||
if ( v.indexOf( 'original-stroke-size:' ) == -1 ) { | |||
v = v.replace( '{', '{ original-stroke-size: ' + oldstroke.toString() + ';' ); | |||
} | |||
orgsize = parseInt( v.match( /original-size: .+;/g )[0].replace( 'original-size: ', '' ).replace( ';', '') ); | |||
orgstroke = parseFloat( v.match( /original-stroke-size: .+;/g )[0].replace( 'original-stroke-size: ', '' ).replace( ';', '') ); | |||
newsize = Math.round( Math.sqrt( Math.sqrt( ( w / 500 ) ) ) * orgsize ); | |||
newstroke = Math.sqrt( ( w / 500 ) ) * orgstroke; | |||
if ( w > 500 ) { | |||
v = v.replace( ' size: ' + oldsize.toString(), ' size: ' + newsize.toString() ); | |||
v = v.replace( ' stroke-width: ' + oldstroke.toString(), ' stroke-width: ' + newstroke.toString() ); | |||
for ( var t in memo.options.trendlines ) { | |||
memo.options.trendlines[t].lineWidth = Math.sqrt( (w/500) ) * memo.options.trendlines[t].originalLineWidth; | |||
} | |||
} else { | |||
v = v.replace( ' size: ' + oldsize.toString(), ' size: ' + orgsize.toString() ); | |||
v = v.replace( ' stroke-width: ' + oldstroke.toString(), ' stroke-width: ' + orgstroke.toString() ); | |||
for ( var t in memo.options.trendlines ) { | |||
memo.options.trendlines[t].lineWidth = memo.options.trendlines[t].originalLineWidth; | |||
} | |||
} | |||
memo.data.Wf[ o ].c[ i ].v = v; | |||
break; | |||
} | |||
} | |||
} | } | ||
}); | s1 = memo.data.Wf[ o ].c[ 2 ]; | ||
s2 = memo.data.Wf[ o ].c[ 6 ]; | |||
} | |||
memo.chart.draw( memo.data, memo.options ); | |||
} | |||
} else { | |||
setTimeout( wait, 500 ); | |||
} | } | ||
} | |||
//wait(); | |||
if ( typeof memo.chartEl != 'undefined' ) { | |||
setTimeout( wait, 100 ); | |||
} | |||
} | |||
window.jwobschartresize = doResize; | |||
function smooth( list, degree ) { | |||
var win = degree*2-1; | |||
weight = _.range(0, win).map(function (x) { return 1.0; }); | |||
weightGauss = []; | |||
for (i in _.range(0, win)) { | |||
i = i-degree+1; | |||
frac = i/win; | |||
gauss = 1 / Math.exp((4*(frac))*(4*(frac))); | |||
weightGauss.push(gauss); | |||
} | } | ||
weight = _(weightGauss).zip(weight).map(function (x) { return x[0]*x[1]; }); | |||
smoothed = _.range(0, (list.length+1)-win).map(function (x) { return 0.0; }); | |||
for (i=0; i < smoothed.length; i++) { | |||
smoothed[i] = _(list.slice(i, i+win)).zip(weight).map(function (x) { return x[0]*x[1]; }).reduce(function (memo, num){ return memo + num; }, 0) / _(weight).reduce(function (memo, num){ return memo + num; }, 0); | |||
} | |||
return smoothed; | |||
} | } | ||
function dec2hex( dec, padding ) { | |||
return parseInt( dec, 10 ).toString( 16 ).padStart( padding, '0' ); | |||
} | } | ||
function utf8StringToUtf16String( str ) { | |||
var utf16 = []; | |||
for (var i=0, strLen=str.length; i < strLen; i++) { | |||
utf16.push(dec2hex(str.charCodeAt(i), 4)); | |||
} | |||
return utf16.join(); | |||
} | } | ||
Date.prototype.getWeek = function() { | |||
var date = new Date(this.getTime()); | |||
date.setHours(0, 0, 0, 0); | |||
// Thursday in current week decides the year. | |||
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7); | |||
// January 4 is always in week 1. | |||
var week1 = new Date(date.getFullYear(), 0, 4); | |||
// Adjust to Thursday in week 1 and count number of weeks from date to week1. | |||
return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000 - 3 + (week1.getDay() + 6) % 7) / 7); | |||
} | } | ||
function getDateOfISOWeek(w, y) { | |||
var simple = new Date(y, 0, 1 + (w - 1) * 7); | |||
var dow = simple.getDay(); | |||
var ISOweekStart = simple; | |||
if (dow <= 4) { | |||
ISOweekStart.setDate(simple.getDate() - simple.getDay() + 1); | |||
} else { | |||
ISOweekStart.setDate(simple.getDate() + 8 - simple.getDay()); | |||
} | |||
return ISOweekStart; | |||
} | |||
var maintColors = { 'authority': '#bb1111', 'expert': '#ff9933', 'experienced': '#666666', 'user': '#aaaaaa'}; | |||
//var seriesC = [ '#e4e3de', '#006085', '#f3a44c' ]; | |||
//var colors = { 'text': '#005854', 'average': '#f3a44c', 'averageare': '#fed992', 'trend': '#ff4500', 'obses': '#cfe9ea', 'x': '#e4e3de', 'curObses': '#005854', 'selObses': 'gold', 'noticeObses': 'tan', 'summer': '#84c497', 'winter': '#006085', 'spring-autumn': '#fed992', 'allyear': '#005854' }; | |||
var colors = { 'text': '#005854', 'gridlines': '#e4e3de', 'average': '#f3a44c', 'averageare': '#cfe9ea', 'trend': '#ff4500', 'obses': '#cfe9ea', 'curObses': '#006085', 'selObses': '#f28e77', 'noticeObses': '#64c1cb', 'summer': '#f3a44c', 'winter': '#64c1cb', 'spring-autumn': '#ccccca', 'allyear': '#64c1cb' }; | |||
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' }, | |||
'fullscreen': { 'fi': 'Ota käyttöön/poista kokoruututila', 'en': 'Toggle fullscreen mode', 'sv': 'Växla helskärmsläge' }, | |||
'sitelink': { 'fi': 'Mene havaintopaikan sivulle', 'en': "Go to the observation site's page", 'sv': 'Gå till observationsplatsen.' }, | |||
'edit': { 'fi': 'Lisää/muokkaa havaintoja', 'en': 'Add/edit observations', 'sv': 'Lägg till/redigera observationer' }, | |||
'season': { 'winter': { 'fi': 'Talvi', 'en': 'Winter', 'sv': 'Vintern' } }, | |||
'dec': { 'fi': ',', 'en': '.', 'sv': ',' }, | |||
'sep': { 'fi': '\t', 'en': ' ', 'sv': ' ' }, | |||
'alg': { | |||
'type': 'cat', | |||
'min': -0.5, | |||
'season': 'summer', | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'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' } }, | |||
'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' } }, | |||
'unit': '', | |||
'axisTitleV': { 'fi': '', 'en': '', 'sv': '', 'ru': '' } | |||
}, | }, | ||
'elodea': { | |||
'type': 'cat', | |||
'min': -0.5, | |||
'season': 'summer', | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'title': { 'fi': 'Vesirutto', 'en': 'Elodea canadensis', 'sv': 'Vattenpest' }, | |||
'catNames': { | |||
' | 0: { 'fi': 'Ei vesiruttoa', 'en': 'No E. canadensis', 'sv': 'Ingen vattenpest' }, | ||
1: { 'fi': 'Hieman vesiruttoa', 'en': 'Some E. canadensis', 'sv': 'Lite med vattenpest' }, | |||
2: { 'fi': 'Runsaasti vesiruttoa', 'en': 'Abundant with E. canadensis', 'sv': 'Rikligt med vattenpest' }, | |||
3: { 'fi': 'Erittäin runsaasti vesiruttoa', 'en': 'Very abundant with E. canadensis', 'sv': 'Ytterst rikligt med vattenpest' } | |||
}, | |||
'catNamesShort': { | |||
0: { 'fi': 'Ei yhtään', 'en': 'None', 'sv': 'Ingen' }, | |||
1: { 'fi': 'Hieman', 'en': 'Some', 'sv': 'Lite' }, | |||
2: { 'fi': 'Runsaasti', 'en': 'Abundant', 'sv': 'Rikligt' }, | |||
3: { 'fi': 'Erit. runsaasti', 'en': 'Very abundant', 'sv': 'Ytterst rikligt' } | |||
}, | |||
'unit': '', | |||
'axisTitleV': { 'fi': '', 'en': '', 'sv': '', 'ru': '' } | |||
}, | |||
'jelly': { | |||
'type': 'cat', | |||
'min': -0.5, | |||
'season': 'summer', | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'title': { 'fi': 'Meduusat', 'en': 'Jelly fish', 'sv': 'Maneter' }, | |||
'catNames': { | |||
0: { 'fi': 'Ei meduusoja', 'en': 'No jelly fish', 'sv': 'Inga maneter' }, | |||
1: { 'fi': 'Vähän meduusoja', 'en': 'Some jelly fish', 'sv': 'Lite med maneter' }, | |||
2: { 'fi': 'Runsaasti meduusoja', 'en': 'Abundant with jelly fish', 'sv': 'Rikligt med maneter' } | |||
}, | |||
'catNamesShort': { | |||
0: { 'fi': 'Ei yhtään', 'en': 'None', 'sv': 'Inga' }, | |||
1: { 'fi': 'Vähän', 'en': 'Some', 'sv': 'Lite' }, | |||
2: { 'fi': 'Runsaasti', 'en': 'Abundant', 'sv': 'Rikligt' } | |||
}, | |||
'unit': '', | |||
'axisTitleV': { 'fi': '', 'en': '', 'sv': '', 'ru': '' } | |||
' | |||
' | |||
' | |||
}, | }, | ||
1: { | 'trash': { | ||
' | 'type': 'cat', | ||
' | 'min': -0.5, | ||
' | 'season': 'summer', | ||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'title': { 'fi': 'Roskaisuus', 'en': 'Litter', 'sv': 'Rosk' }, | |||
'catNames': { | |||
0: { 'fi': 'Ei roskia', 'en': 'No litter', 'sv': 'Ingen rosk' }, | |||
1: { 'fi': 'Vähän roskia', 'en': 'Some litter', 'sv': 'Lite med rosk' }, | |||
2: { 'fi': 'Paljon roskia', 'en': 'Abundant with litter', 'sv': 'Rikligt med rosk' }, | |||
3: { 'fi': 'Erittäin paljon roskia', 'en': 'Very abundant with litter', 'sv': 'Ytterst rikligt med rosk' }, | |||
}, | |||
'catNamesShort': { | |||
0: { 'fi': 'Ei yhtään', 'en': 'None', 'sv': 'Inga' }, | |||
1: { 'fi': 'Vähän', 'en': 'Some', 'sv': 'Lite' }, | |||
2: { 'fi': 'Paljon', 'en': 'Abundant', 'sv': 'Rikligt' }, | |||
3: { 'fi': 'Erit. paljon', 'en': 'Very abundant', 'sv': 'Ytterst rikligt' }, | |||
}, | |||
'unit': '', | |||
'axisTitleV': { 'fi': '', 'en': '', 'sv': '', 'ru': '' } | |||
}, | |||
'temp': { | |||
'type': 'num', | |||
'season': 'summer', | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'title': { 'fi': 'Pintaveden lämpötila', 'en': 'Surface water temperature', 'sv': 'Ytvattentemperatur', 'ru': '???' }, | |||
'unit': '°C', | |||
'axisTitleV': { 'fi': 'Lämpötila, °C', 'en': 'Temperature, °C', 'sv': 'Temperatur, °C', 'ru': '°C' } | |||
}, | }, | ||
'ice': { | |||
' | 'catName': 'Jäätilanne', | ||
' | 'type': 'num', | ||
' | 'season': 'winter', | ||
'min': 0, | |||
//'direction': -1, | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'title': { 'fi': 'Jään paksuus', 'en': 'Ice thickness', 'sv': 'Isens tjocklek', 'ru': '???' }, | |||
'unit': 'cm', | |||
'axisTitleV': { 'fi': 'Jääpeite, cm', 'en': 'Ice cover, cm', 'sv': 'Istäcket, cm', 'ru': 'm' } | |||
}, | }, | ||
'ice_cat': { | |||
'catName': 'Jäätilanne', | |||
' | |||
}, | }, | ||
'ice_cat_2': { 'title': { 'fi': 'Jäätyminen', 'en': 'Freeze-up', 'sv': 'Förfrysning', 'ru': '???' }, 'title2': { 'fi': 'Pysyvä jääpeite', 'en': 'Permanent ice cover', 'sv': 'Permanent istäcke', 'ru': '???' }, color: colors[ 'winter' ] }, | |||
'ice_cat_5': { 'title': { 'fi': 'Jäänlähtö', 'en': 'Ice break-up', 'sv': 'Islossning', 'ru': '???' }, 'title2': { 'fi': 'Jäätön kausi alkoi', 'en': 'Beginning of ice-free season', 'sv': 'Början av den isfria säsongen', 'ru': '???' }, color: '#006085' }, | |||
'ice_cat_2,5': { | |||
' | 'type': 'date', | ||
'season': 'winter', | |||
'direction': -1, | |||
'trend': { 'type': 'regression', 'layout': 'line' }, | |||
'title': { 'fi': 'Jääpeitekauden kesto', 'en': 'Duration of ice cover', 'sv': 'Längden på istäckesperioden', 'ru': '' }, | |||
'color': '#c1e7f7', | |||
'unit': { 'fi': 'päivää', 'en': 'days', 'sv': 'dagar', 'ru': '' }, | |||
'axisTitleV': { 'fi': '', 'en': '', 'sv': '', 'ru': '' }, | |||
'xchanges': { | |||
'fi': '', | |||
'en': '', | |||
'sv': '', | |||
'ru': '' | |||
}, | |||
}, | }, | ||
'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': { | |||
'catName': 'Lumikuorma', | |||
'type': 'num', | |||
'season': 'winter', | |||
'min': 0, | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'title': { 'fi': 'Lumikuorma', 'en': 'Snow load', 'sv': 'Snöbelastning', 'ru': '???' }, | |||
'unit': 'kg/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': { | |||
'type': 'num', | |||
'season': 'summer', | |||
'min': 0, | |||
'direction': 1, | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'title': { 'fi': 'Kokonaisfosfori', 'en': 'Total phosphorus', 'sv': 'Totalfosfor', 'ru': '???' }, | |||
'unit': 'µg/l', | |||
'axisTitleV': { 'fi': 'Pitoisuus, µg/l', 'en': 'Concentration, µg/l', 'sv': 'Koncentration, µg/l', 'ru': 'm' }, | |||
'depths': true | |||
}, | }, | ||
'ntot': { | |||
' | 'type': 'num', | ||
' | 'season': 'summer', | ||
' | 'min': 0, | ||
'direction': 1, | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'title': { 'fi': 'Kokonaistyppi', 'en': 'Total nitrogen', 'sv': 'Totalkväve', 'ru': '???' }, | |||
'unit': 'µg/l', | |||
'axisTitleV': { 'fi': 'Pitoisuus, µg/l', 'en': 'Concentration, µg/l', 'sv': 'Koncentration, µg/l', 'ru': 'm' } | |||
}, | }, | ||
'o2': { | |||
' | 'type': 'num', | ||
' | 'season': 'summer', | ||
' | 'min': 0, | ||
'direction': 1, | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'title': { 'fi': 'Happipitoisuus', 'en': 'Dissolved oxygen', 'sv': 'Syrehalt', 'ru': '???' }, | |||
'unit': 'mg/l', | |||
'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': { | |||
'title': { 'fi': 'Vedenkorkeus', 'en': 'Water level', 'sv': 'Vattenståndpunkt', 'ru': '???' }, | |||
'title2': { 'fi': 'Vedenkorkeus', 'en': '???', 'sv': '???', 'ru': '???' }, | |||
'type': 'num', | |||
'season': 'summer', | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'unit': 'm', | |||
'axisTitleV': { 'fi': 'Vedenpinnan korkeus, m', 'en': 'Water level, m', 'sv': 'Vattennivå, m', 'ru': 'm' } | |||
}, | |||
'avglevelsy': { | |||
'title': { 'fi': 'Keskivedenkorkeus', 'en': '', 'sv': '', 'ru': '???' }, | |||
'title2': { 'fi': 'Vedenkorkeus', 'en': '???', 'sv': '???', 'ru': '???' }, | |||
'type': 'num', | |||
'season': 'summer', | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'unit': 'm', | |||
'axisTitleV': { 'fi': 'Vuosikeskiarvo, m', 'en': 'Water level, m', 'sv': 'Vattennivå, m', 'ru': 'm' } | |||
}, | }, | ||
10: { | 'avglevelsw': { | ||
'title': { 'fi': 'Keskivedenkorkeus', 'en': '', 'sv': '', 'ru': '???' }, | |||
'title2': { 'fi': 'Vedenkorkeus', 'en': '???', 'sv': '???', 'ru': '???' }, | |||
'type': 'num', | |||
'season': 'summer', | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'unit': 'm', | |||
'axisTitleV': { 'fi': 'Vuosikeskiarvo, m', 'en': 'Water level, m', 'sv': 'Vattennivå, m', 'ru': 'm' } | |||
}, | |||
'ski': { | |||
'title': { 'fi': 'Hiihto', 'en': 'Skiing', 'sv': '', 'ru': '???' }, | |||
'title2': { 'fi': 'Hiihtolatu', 'en': '???', 'sv': '???', 'ru': '???' }, | |||
'type': 'cat', | |||
'season': 'winter', | |||
'trend': { 'type': 'gaussian', 'layout': 'line' }, | |||
'unit': '', | |||
'axisTitleV': { 'fi': 'Korkeus merenpinnasta, m', 'en': 'Above sea level, m', 'sv': 'Över havsytan, m', 'ru': 'cm' } | |||
}, | |||
'Observation': { 'fi': 'Havainto', 'en': 'Observation', 'sv': 'Observation', 'ru': '???' }, | |||
'new': { 'fi': 'Uusi', 'en': 'New', 'sv': 'Nytt', 'ru': '???' }, | |||
'Value': { 'fi': 'Arvo', 'en': 'Value', 'sv': 'Värde', 'ru': '???' }, | |||
'ValueUnit': { 'fi': 'Arvon tyyppi', 'en': 'Value type', 'sv': 'Värdes typ', 'ru': '???' }, | |||
'Date': { 'fi': 'Päivämäärä', 'en': 'Date', 'sv': 'Datum', 'ru': '???' }, | |||
'Additionalinfo': { 'fi': 'Lisätiedot', 'en': 'Additional info', 'sv': 'Tillägsinformation', 'ru': '???' }, | |||
'Image': { 'fi': 'Valokuva', 'en': 'Image', 'sv': 'Bild', 'ru': '???' }, | |||
'ObserverStatus': { 'fi': 'Havainnoijan status', 'en': 'Observer status', 'sv': 'Observatörens status', 'ru': '???' }, | |||
'average': { 'fi': 'Keskimäärin', 'en': 'Average', 'sv': 'Genomsnitt', 'ru': '???' }, | |||
'trendline': { 'fi': 'Trendiviiva', 'en': 'Trend line', 'sv': 'Trendlinje', 'ru': '???' }, | |||
'days': { 'fi': 'päivää', 'en': 'days', 'sv': 'dygn', 'ru': '???' }, | |||
'month': { 'fi': 'Kuukausi', 'en': 'Month', 'sv': 'Månad', 'ru': '???' }, | |||
'months': { | |||
0: { | |||
'long': { 'fi': 'Tammikuu', 'en': 'January', 'sv': 'Januari', 'ru': '???' }, | |||
'short': { 'fi': 'Tammi', 'en': 'Jan', 'sv': 'Jan', 'ru': '???' }, | |||
'roman': 'I' | |||
}, | |||
1: { | |||
'long': { 'fi': 'Helmikuu', 'en': 'Febryary', 'sv': 'Februari', 'ru': '???' }, | |||
'short': { 'fi': 'Helmi', 'en': 'Feb', 'sv': 'Feb', 'ru': '???' }, | |||
'roman': 'II' | |||
}, | |||
2: { | |||
'long': { 'fi': 'Maaliskuu', 'en': 'March', 'sv': 'Mars', 'ru': '???' }, | |||
'short': { 'fi': 'Maalis', 'en': 'Mar', 'sv': 'Mar', 'ru': '???' }, | |||
'roman': 'III' | |||
}, | |||
3: { | |||
'long': { 'fi': 'Huhtikuu', 'en': 'April', 'sv': 'April', 'ru': '???' }, | |||
'short': { 'fi': 'Huhti', 'en': 'Apr', 'sv': 'Apr', 'ru': '???' }, | |||
'roman': 'IV' | |||
}, | |||
4: { | |||
'long': { 'fi': 'Toukokuu', 'en': 'May', 'sv': 'Maj', 'ru': '???' }, | |||
'short': { 'fi': 'Touko', 'en': 'May', 'sv': 'Maj', 'ru': '???' }, | |||
'roman': 'V' | |||
}, | |||
5: { | |||
'long': { 'fi': 'Kesäkuu', 'en': 'June', 'sv': 'Juni', 'ru': '???' }, | |||
'short': { 'fi': 'Kesä', 'en': 'Jun', 'sv': 'Jun', 'ru': '???' }, | |||
'roman': 'VI' | |||
}, | |||
6: { | |||
'long': { 'fi': 'Heinäkuu', 'en': 'July', 'sv': 'Juli', 'ru': '???' }, | |||
'short': { 'fi': 'Heinä', 'en': 'Jul', 'sv': 'Jul', 'ru': '???' }, | |||
'roman': 'VII' | |||
}, | |||
7: { | |||
'long': { 'fi': 'Elokuu', 'en': 'August', 'sv': 'Augusti', 'ru': '???' }, | |||
'short': { 'fi': 'Elo', 'en': 'Aug', 'sv': 'Aug', 'ru': '???' }, | |||
'roman': 'VIII' | |||
}, | |||
8: { | |||
'long': { 'fi': 'Syyskuu', 'en': 'September', 'sv': 'September', 'ru': '???' }, | |||
'short': { 'fi': 'Syys', 'en': 'Sep', 'sv': 'Sep', 'ru': '???' }, | |||
'roman': 'IX' | |||
}, | |||
9: { | |||
'long': { 'fi': 'Lokakuu', 'en': 'October', 'sv': 'Oktober', 'ru': '???' }, | |||
'short': { 'fi': 'Loka', 'en': 'Oct', 'sv': 'Okt', 'ru': '???' }, | |||
'roman': 'X' | |||
}, | |||
10: { | |||
'long': { 'fi': 'Marraskuu', 'en': 'November', 'sv': 'November', 'ru': '???' }, | |||
'short': { 'fi': 'Marras', 'en': 'Nov', 'sv': 'Nov', 'ru': '???' }, | |||
'roman': 'XI' | |||
}, | |||
11: { | |||
'long': { 'fi': 'Joulukuu', 'en': 'December', 'sv': 'December', 'ru': '???' }, | |||
'short': { 'fi': 'Joulu', 'en': 'Dec', 'sv': 'Dec', 'ru': '???' }, | |||
'roman': 'XII' | |||
} | |||
} | } | ||
}; | |||
})(); // We call our anonymous function immediately | |||
</script> | |||
</includeonly> | </includeonly> | ||


