Ero sivun ”Widget:JwCurrentCharts” versioiden välillä
Järvi-meriwikistä
Rivi 573: | Rivi 573: | ||
var ivalsum = 0; | var ivalsum = 0; | ||
+ | var ivalcount = 0; | ||
+ | var ivc = 0; | ||
var icatsum = 0; | var icatsum = 0; | ||
Rivi 582: | Rivi 584: | ||
obs = memo.obsesA[o]; | obs = memo.obsesA[o]; | ||
iw = ( 7 - Math.round( ( today.getTime() - memo.obsesA[o].obsdatetime.getTime() ) / ( 24*60*60*1000 ) ) ); | iw = ( 7 - Math.round( ( today.getTime() - memo.obsesA[o].obsdatetime.getTime() ) / ( 24*60*60*1000 ) ) ); | ||
+ | |||
if ( obs.data.cat == '0' || obs.data.cat == '5' ) { | if ( obs.data.cat == '0' || obs.data.cat == '5' ) { | ||
icat = 0; | icat = 0; | ||
Rivi 589: | Rivi 592: | ||
icat = 1; | icat = 1; | ||
} | } | ||
− | + | ||
+ | if ( obs.data.val > 0 ) { | ||
+ | ivc++; | ||
+ | ivalsum += iw * obs.data.val; | ||
+ | ivalcount += iw; | ||
+ | } | ||
icatsum += icat * iw; | icatsum += icat * iw; | ||
Rivi 602: | Rivi 610: | ||
console.log( iavg ); | console.log( iavg ); | ||
+ | |||
+ | if ( iavg > 0.9 && ivc > 0 ) { | ||
+ | |||
+ | ivalavg = ( ivalsum/ivalcount ); | ||
+ | console.log( ivalavg ); | ||
+ | |||
+ | } | ||
if ( iavg < 0.25 || memo.obsesA[0].data.cat == '5' ) { istr = 'Ei jäätä'; } | if ( iavg < 0.25 || memo.obsesA[0].data.cat == '5' ) { istr = 'Ei jäätä'; } |