Ei muokkausyhteenvetoa |
Ei muokkausyhteenvetoa |
||
| Rivi 9: | Rivi 9: | ||
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> | <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
function <!--{$id|default:algalbarochart|escape:'html'}-->_jQueryTest() { | |||
if ( typeof window.jQuery == 'undefined' || typeof queryApi == 'undefined' ) { | |||
setTimeout( function(){ <!--{$id|default:algalbarochart|escape:'html'}-->_jQueryTest() }, 300); | |||
} else { | |||
google.load('visualization', '1.0', {'packages':['corechart']}); | |||
google.setOnLoadCallback(<!--{$id|default:algalbarochart|escape:'html'}-->_func); | |||
} | |||
} | |||
setTimeout( function(){ <!--{$id|default:algalbarochart|escape:'html'}-->_jQueryTest() }, 300); | |||
function <!--{$id|default:algalbarochart|escape:'html'}-->_func() { | |||
// Load the Visualization API and the corechart package. | |||
google.charts.load('current', {'packages':['corechart']}); | |||
// Set a callback to run when the Google Visualization API is loaded. | |||
google.charts.setOnLoadCallback( <!--{$id|default:algalbarochart|escape:'html'}-->_init ); | |||
} | |||
function <!--{$id|default: | function <!--{$id|default:algalbarochart|escape:'html'}-->_init() { | ||
console.log( 'init' ); | |||
var today = new Date(); | var today = new Date(); | ||
var vuosi = <!--{$vuosi|default:0|escape:'html'}-->; | var vuosi = <!--{$vuosi|default:0|escape:'html'}-->; | ||
| Rivi 32: | Rivi 45: | ||
//elySearch= elySearch.split('ö').join('%C3%B6'); | //elySearch= elySearch.split('ö').join('%C3%B6'); | ||
var elySearch = encodeURI(ely); | var elySearch = encodeURI(ely); | ||
var minweek = <!--{$minweek|default:23|escape:'html'}-->; | |||
var maxweek = <!--{$maxweek|default:39|escape:'html'}-->; | |||
if (ely == "xxx") { ely = undefined; } | if (ely == "xxx") { ely = undefined; } | ||
| Rivi 48: | Rivi 63: | ||
var Rdata2 = new Array(); | var Rdata2 = new Array(); | ||
for (i= | for (i=minweek; i<=maxweek; i++) { | ||
Rdata1[(i- | Rdata1[(i-minweek)] = [i.toString(), null, "", null, "", null, "", null, "", null, ""]; | ||
Rdata2[(i- | Rdata2[(i-minweek)] = [i.toString(), null, "", null, "", null, "", null, "", null, ""]; | ||
} | } | ||
| Rivi 66: | Rivi 81: | ||
searchStr += "[[Tyyppi::Viikkoarvo]]"; | searchStr += "[[Tyyppi::Viikkoarvo]]"; | ||
searchStr += "[[Vuosi::" + vuosi + "]]"; | searchStr += "[[Vuosi::" + vuosi + "]]"; | ||
searchStr += "[[Viikko::% | searchStr += "[[Viikko::%3E" + minweek.toString() + "]][[Viikko::%3C" + maxweek.toString() + "]]"; | ||
searchStr += encodeURI('|?Viikko|?Leväbarometri|?Vesistö|limit=100'); | searchStr += encodeURI('|?Viikko|?Leväbarometri|?Vesistö|limit=100'); | ||
searchStr += '&format=json | searchStr += '&format=json'; | ||
jQuery.ajax({ | jQuery.ajax({ | ||
| Rivi 94: | Rivi 109: | ||
searchStr2 += "[[Tyyppi::Viikkoarvo]][[Vuosi::" + vertaa + "]]"; | searchStr2 += "[[Tyyppi::Viikkoarvo]][[Vuosi::" + vertaa + "]]"; | ||
} | } | ||
searchStr2 += "[[Viikko::% | searchStr2 += "[[Viikko::%3E" + minweek.toString() + "]][[Viikko::%3C" + maxweek.toString() + "]]"; | ||
searchStr2 += encodeURI('|?Viikko|?Tyyppi|?Leväbarometri|?Vesistö|limit=100'); | searchStr2 += encodeURI('|?Viikko|?Tyyppi|?Leväbarometri|?Vesistö|limit=100'); | ||
searchStr2 += '&format=json'; | searchStr2 += '&format=json'; | ||
| Rivi 106: | Rivi 121: | ||
function success(request) { | function success(request) { | ||
console.log(request); | |||
if (request.query.results != undefined) { | |||
zi = -1; | zi = -1; | ||
for (var i in request.query.results) { | for (var i in request.query.results) { | ||
| Rivi 128: | Rivi 145: | ||
weekSpan = printWeekSpan(vuosi, resultItem.Viikko[0]); | weekSpan = printWeekSpan(vuosi, resultItem.Viikko[0]); | ||
if (resultBaroVal < 0) { | if (resultBaroVal < 0) { | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][5] = 0; | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][6] = weekSpan; | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][6] += '\nLiian vähän havaintoja'; | ||
} else if (resultBaroVal == 0) { | } else if (resultBaroVal == 0) { | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][9] = 0; | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][10] = weekSpan; | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][10] += '\n0 - Ei levähavaintoja'; | ||
} else { | } else { | ||
if (resultItem.Viikko[0] == viikko) { | if (resultItem.Viikko[0] == viikko) { | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][7] = resultBaroVal; | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][8] = weekSpan; | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][8] += '\n' + resultBaroStr; | ||
} else { | } else { | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][1] = resultBaroVal; | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][2] = weekSpan; | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][2] += '\n' + resultBaroStr; | ||
} | } | ||
} | } | ||
} else { | } else { | ||
if (resultBaroVal < 0) { | if (resultBaroVal < 0) { | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][3] = 0; | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][4] = 'Liukuva keskiarvo\n1998-'; | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][4] += '\nLiian vähän havaintoja'; | ||
} else { | } else { | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][3] = resultBaroVal; | ||
if (vertaa == undefined) { | if (vertaa == undefined) { | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][4] = 'Liukuva keskiarvo\n1998-'; | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][4] += (today.getFullYear()-1).toString(); | ||
} else { | } else { | ||
date1 = getDateFromYWD(vertaa, resultItem.Viikko[0], 0); | date1 = getDateFromYWD(vertaa, resultItem.Viikko[0], 0); | ||
| Rivi 162: | Rivi 179: | ||
date2Str = date2.getDate() + "." + (date2.getMonth()+1) + "."; | date2Str = date2.getDate() + "." + (date2.getMonth()+1) + "."; | ||
weekSpan = printWeekSpan(vertaa, resultItem.Viikko[0]); | weekSpan = printWeekSpan(vertaa, resultItem.Viikko[0]); | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][4] = weekSpan; //date1Str + '-' + date2Str; | ||
Rdata1[resultItem.Viikko[0]- | Rdata1[resultItem.Viikko[0]-minweek][4] += '\n' + resultBaroStr; | ||
} | } | ||
} | } | ||
} | } | ||
} else { | } else { | ||
if (resultItem.Tyyppi == undefined) { | if (resultItem.Tyyppi == undefined) { | ||
| Rivi 175: | Rivi 193: | ||
weekSpan = printWeekSpan(vuosi, resultItem.Viikko[0]); | weekSpan = printWeekSpan(vuosi, resultItem.Viikko[0]); | ||
if (resultBaroVal < 0) { | if (resultBaroVal < 0) { | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][5] = 0; | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][6] = weekSpan; | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][6] += '\nLiian vähän havaintoja'; | ||
} else if (resultBaroVal == 0) { | } else if (resultBaroVal == 0) { | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][9] = 0; | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][10] = weekSpan; | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][10] += '\n0 - Ei levähavaintoja'; | ||
} else { | } else { | ||
if (resultItem.Viikko[0] == viikko) { | if (resultItem.Viikko[0] == viikko) { | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][7] = resultBaroVal; | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][8] = weekSpan; //date1Str + '-' + date2Str + vuosi; | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][8] += '\n' + resultBaroStr; | ||
} else { | } else { | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][1] = resultBaroVal; | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][2] = weekSpan; | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][2] += '\n' + resultBaroStr; | ||
} | } | ||
} | } | ||
} else { | } else { | ||
if (resultBaroVal < 0) { | if (resultBaroVal < 0) { | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][3] = 0; | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][4] = 'Liukuva keskiarvo\n1998-'; | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][4] += '\nLiian vähän havaintoja'; | ||
} else { | } else { | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][3] = resultBaroVal; | ||
if (vertaa == undefined) { | if (vertaa == undefined) { | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][4] = 'Liukuva keskiarvo\n1998-'; | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][4] += (today.getFullYear()-1).toString(); | ||
} else { | } else { | ||
date1 = getDateFromYWD(vertaa, resultItem.Viikko[0], 0); | date1 = getDateFromYWD(vertaa, resultItem.Viikko[0], 0); | ||
| Rivi 209: | Rivi 227: | ||
date2Str = date2.getDate() + "." + (date2.getMonth()+1) + "."; | date2Str = date2.getDate() + "." + (date2.getMonth()+1) + "."; | ||
weekSpan = printWeekSpan(vertaa, resultItem.Viikko[0]); | weekSpan = printWeekSpan(vertaa, resultItem.Viikko[0]); | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][4] = weekSpan; //date1Str + '-' + date2Str; | ||
//Rdata2[resultItem.Viikko[0]- | //Rdata2[resultItem.Viikko[0]-minweek][4] += (vertaa).toString(); | ||
Rdata2[resultItem.Viikko[0]- | Rdata2[resultItem.Viikko[0]-minweek][4] += '\n' + resultBaroStr; | ||
} | } | ||
} | } | ||
| Rivi 262: | Rivi 280: | ||
titlePosition: 'out', | titlePosition: 'out', | ||
titleTextStyle: { fontName: '"Arial"', fontSize: 14 }, | titleTextStyle: { fontName: '"Arial"', fontSize: 14 }, | ||
vAxis: { viewWindowMode:'explicit', viewWindow:{ max:0.8, min:0}, gridlines: { color: '#c1e7f7' }}, | vAxis: { viewWindowMode:'explicit', viewWindow:{ max:0.8, min:0}, gridlines: { count: '4', color: '#c1e7f7' }}, | ||
//{maxValue: 0.8}, | //{maxValue: 0.8}, | ||
hAxis: {title: "Viikko", slantedText: false, maxAlternation: 1, titleTextStyle: { fontName: '"Arial"' } }, | hAxis: {title: "Viikko", slantedText: false, maxAlternation: 1, titleTextStyle: { fontName: '"Arial"' } }, | ||
backgroundColor: { fill: "#<!--{$bgcolor|default:ffffff|escape:'html'}-->", stroke: "#c1e7f7", strokeWidth: 0 }, | backgroundColor: { fill: "#<!--{$bgcolor|default:ffffff|escape:'html'}-->", stroke: "#c1e7f7", strokeWidth: 0 }, | ||
chartArea: { top: 20, left: | chartArea: { top: 20, left: 30, backgroundColor: "#<!--{$bgcolor|default:ffffff|escape:'html'}-->" }, | ||
series: { | series: { | ||
0: {type: "bars", color: '#59B500' }, | 0: {type: "bars", color: '#59B500' }, | ||
| Rivi 319: | Rivi 337: | ||
titleTextStyle: { fontName: '"Arial"', fontSize: 14 }, | titleTextStyle: { fontName: '"Arial"', fontSize: 14 }, | ||
fontSize: 12, | fontSize: 12, | ||
vAxis: { viewWindowMode:'explicit', viewWindow:{ max:0.8, min:0}, gridlines: { color: '#c1e7f7' }}, | vAxis: { viewWindowMode:'explicit', viewWindow:{ max: 0.8, min:0 }, gridlines: { count: 4, color: '#c1e7f7' }}, | ||
//{maxValue: 0.8}, | //{maxValue: 0.8}, | ||
hAxis: {title: "Viikko", slantedText: false, maxAlternation: 1, titleTextStyle: { fontName: '"Arial"' } }, | hAxis: {title: "Viikko", slantedText: false, maxAlternation: 1, titleTextStyle: { fontName: '"Arial"' } }, | ||
backgroundColor: { fill: "#<!--{$bgcolor|default:ffffff|escape:'html'}-->", stroke: "#c1e7f7" }, | backgroundColor: { fill: "#<!--{$bgcolor|default:ffffff|escape:'html'}-->", stroke: "#c1e7f7" }, | ||
chartArea: { top: 20, left: | chartArea: { top: 20, left: 30, backgroundColor: "#<!--{$bgcolor|default:ffffff|escape:'html'}-->" }, | ||
series: { | series: { | ||
0: {type: "bars", color: '#59B500' }, | 0: {type: "bars", color: '#59B500' }, | ||


