Ero sivun ”Widget:JwCurrentCharts” versioiden välillä
Järvi-meriwikistä
(11 välissä olevaa versiota samalta käyttäjältä ei näytetä) | |||
Rivi 516: | Rivi 516: | ||
} | } | ||
− | obs = memo.obsesA[0]; | + | if ( memo.obsesA.length > 0 ) { |
− | + | obs = memo.obsesA[0]; | |
− | + | for (var r in memo.refs) { | |
− | + | ref = memo.refs[r]; | |
+ | break; | ||
+ | } | ||
+ | |||
+ | refdata = JSON.parse( ref.printouts.DataJSON ); | ||
+ | refn = refdata.val/100; | ||
+ | |||
+ | diff = obs.value - refn; | ||
+ | diff = Math.round( diff*100 ); | ||
+ | diffStr = diff.toString() + ' cm'; | ||
+ | if ( diff > 0 ) { diffStr = '+' + diffStr; } | ||
+ | } else { | ||
+ | diff = -999; | ||
+ | diffStr = ''; | ||
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
var levelsvg = '<?xml version="1.0" encoding="utf-8"?><svg role="img" aria-label="XXX" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 100 100" style="enable-background:new 0 0 100 99.6;" xml:space="preserve"><style type="text/css">.st0{fill:#ccc;} .st1{fill:#0076B0;}</style>'; | var levelsvg = '<?xml version="1.0" encoding="utf-8"?><svg role="img" aria-label="XXX" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 100 100" style="enable-background:new 0 0 100 99.6;" xml:space="preserve"><style type="text/css">.st0{fill:#ccc;} .st1{fill:#0076B0;}</style>'; | ||
var levelclass = 'st0'; | var levelclass = 'st0'; | ||
+ | |||
if ( diff > 20 ) { levelclass = "st1"; } | if ( diff > 20 ) { levelclass = "st1"; } | ||
levelsvg += '<path class="' + levelclass + '" d="M46.8,1.2c1.9-1.5,4.5-1.5,6.4,0c3.9,3,8.7,5.1,13.5,5.1c4.7,0,9.6-2.1,13.4-5.1l0,0c2.1-1.7,4.9-1.5,6.8,0.3c2.5,2.3,5.6,4.1,8.8,4.9c3,0.8,4.8,4.1,4.2,7.5s-3.7,5.4-6.7,4.7c-4.3-1.1-7.8-3.2-10.1-4.9c-5,3-10.7,5.1-16.4,5.1c-5.5,0-10.5-1.9-14-3.7c-1-0.5-1.9-1-2.7-1.5c-0.8,0.5-1.7,1-2.7,1.5c-3.4,1.8-8.4,3.7-14,3.7c-5.7,0-11.4-2-16.4-5c-2.3,1.6-5.9,3.8-10.1,4.9c-3,0.8-6-1.3-6.7-4.7s1.2-6.7,4.2-7.5c3.1-0.8,6.3-2.6,8.8-4.9c1.9-1.9,4.7-2,6.8-0.3l0,0c3.9,3,8.8,5.1,13.5,5.1C38.1,6.3,42.9,4.2,46.8,1.2z"/>'; | levelsvg += '<path class="' + levelclass + '" d="M46.8,1.2c1.9-1.5,4.5-1.5,6.4,0c3.9,3,8.7,5.1,13.5,5.1c4.7,0,9.6-2.1,13.4-5.1l0,0c2.1-1.7,4.9-1.5,6.8,0.3c2.5,2.3,5.6,4.1,8.8,4.9c3,0.8,4.8,4.1,4.2,7.5s-3.7,5.4-6.7,4.7c-4.3-1.1-7.8-3.2-10.1-4.9c-5,3-10.7,5.1-16.4,5.1c-5.5,0-10.5-1.9-14-3.7c-1-0.5-1.9-1-2.7-1.5c-0.8,0.5-1.7,1-2.7,1.5c-3.4,1.8-8.4,3.7-14,3.7c-5.7,0-11.4-2-16.4-5c-2.3,1.6-5.9,3.8-10.1,4.9c-3,0.8-6-1.3-6.7-4.7s1.2-6.7,4.2-7.5c3.1-0.8,6.3-2.6,8.8-4.9c1.9-1.9,4.7-2,6.8-0.3l0,0c3.9,3,8.8,5.1,13.5,5.1C38.1,6.3,42.9,4.2,46.8,1.2z"/>'; | ||
Rivi 560: | Rivi 566: | ||
} else if ( diff > -20 ) { | } else if ( diff > -20 ) { | ||
levelsvg.replace( 'XXX', 'Vedenpinta matala' ); | levelsvg.replace( 'XXX', 'Vedenpinta matala' ); | ||
+ | } else if ( diff > -100 ) { | ||
+ | levelsvg.replace( 'XXX', 'Vedenpinta erittäin matala' ); | ||
} else { | } else { | ||
− | levelsvg.replace( 'XXX', ' | + | levelsvg.replace( 'XXX', 'Ei tuloksia' ); |
} | } | ||
Rivi 633: | Rivi 641: | ||
ivalmin = Math.round( ivalmin ); | ivalmin = Math.round( ivalmin ); | ||
ivalmax = Math.round( ivalmax ); | ivalmax = Math.round( ivalmax ); | ||
− | + | //console.log( ivalavg ); | |
if ( ivalmax > ivalmin ) { | if ( ivalmax > ivalmin ) { | ||
istr = ivalmin + '–' + ivalmax + ' cm'; | istr = ivalmin + '–' + ivalmax + ' cm'; | ||
Rivi 645: | Rivi 653: | ||
istr += '<br /><span class="smaller">('; | istr += '<br /><span class="smaller">('; | ||
istr += '<button style="margin-left: -1px; padding: 0; font-size: 13px; margin-bottom: 3px; color: #59B500;" type="button" class="btn Xbtn-secondary Xbtn-info" data-toggle="tooltip" data-placement="top" title="" data-original-title="Perustuu yhteensä ' + icount + ' havaintoon ajanjaksolla: ' + memo.obsesA[ memo.obsesA.length-1 ].obsdatetime.toLocaleDateString() + '-' + memo.obsesA[0].obsdatetime.toLocaleDateString() + '."><span class="fontawesome"></span></button>'; | istr += '<button style="margin-left: -1px; padding: 0; font-size: 13px; margin-bottom: 3px; color: #59B500;" type="button" class="btn Xbtn-secondary Xbtn-info" data-toggle="tooltip" data-placement="top" title="" data-original-title="Perustuu yhteensä ' + icount + ' havaintoon ajanjaksolla: ' + memo.obsesA[ memo.obsesA.length-1 ].obsdatetime.toLocaleDateString() + '-' + memo.obsesA[0].obsdatetime.toLocaleDateString() + '."><span class="fontawesome"></span></button>'; | ||
− | istr += ' &# | + | istr += ' ⋯' + memo.obsesA[0].obsdatetime.inRelationToToday(memo.lang).toLowerCase() + ')</span>'; |
} | } | ||
Rivi 681: | Rivi 689: | ||
x = col * 10 + 1; | x = col * 10 + 1; | ||
y = row * 10 + 1; | y = row * 10 + 1; | ||
+ | //console.log( 1 + ivalavg/10 ); | ||
if ( icount > 0 ) { | if ( icount > 0 ) { | ||
if ( ivalavg > 0 ) { | if ( ivalavg > 0 ) { | ||
− | if ( | + | if ( row < ivalavg/10 ) { |
aclass = 'ice1'; | aclass = 'ice1'; | ||
} else { | } else { | ||
Rivi 732: | Rivi 741: | ||
} | } | ||
− | if ( | + | if ( tcsum > 0 ) { |
tavg = Math.round( tsum/tcsum*10 ) / 10; | tavg = Math.round( tsum/tcsum*10 ) / 10; | ||
tstr = tavg.toString().replace( '.', ',' ) + ' °C'; | tstr = tavg.toString().replace( '.', ',' ) + ' °C'; | ||
Rivi 804: | Rivi 813: | ||
for ( var o in memo.obsesA ) { | for ( var o in memo.obsesA ) { | ||
aw = ( 7 - Math.round( ( today.getTime() - memo.obsesA[o].obsdatetime.getTime() ) / ( 24*60*60*1000 ) ) ); | aw = ( 7 - Math.round( ( today.getTime() - memo.obsesA[o].obsdatetime.getTime() ) / ( 24*60*60*1000 ) ) ); | ||
− | asum += memo.obsesA[o].data.val * aw; | + | asum += memo.obsesA[o].data.val * aw; |
acsum = acsum + aw; | acsum = acsum + aw; | ||
ac++; | ac++; | ||
} | } | ||
− | if ( | + | if ( acsum > 0 ) { |
− | var aavg = asum/acsum; | + | |
+ | var aavg = asum/acsum; | ||
if ( aavg < 0.25 ) { astr = 'Ei sinilevää'; } | if ( aavg < 0.25 ) { astr = 'Ei sinilevää'; } | ||
else if ( aavg < 1.25 ) { astr = 'Hieman sinilevää'; } | else if ( aavg < 1.25 ) { astr = 'Hieman sinilevää'; } |