Ei muokkausyhteenvetoa |
Ei muokkausyhteenvetoa |
||
| Rivi 658: | Rivi 658: | ||
// legend entry for timespan | // legend entry for timespan | ||
memo.data.addColumn( 'number', memo.obsMinDate.getFullYear() + '-' + memo.obsMaxDate.getFullYear() ); | memo.data.addColumn( 'number', memo.obsMinDate.getFullYear() + '-' + memo.obsMaxDate.getFullYear() ); | ||
memo.options.trendlines = {}; | //memo.options.trendlines = {}; | ||
memo.options.trendlines[ sc ] = { type: 'polynomial' }; | //memo.options.trendlines[ sc ] = { type: 'polynomial' }; | ||
memo.options.series[sc++] = { type: 'scatter', color: colors['obses'], pointSize: 5, visibleInLegend: true, hideThis: false }; | memo.options.series[sc++] = { type: 'scatter', color: colors['obses'], pointSize: 5, visibleInLegend: true, hideThis: false }; | ||
| Rivi 681: | Rivi 681: | ||
if ( memo.seasonsA[s] == memo.curSeason ) { | if ( memo.seasonsA[s] == memo.curSeason ) { | ||
dataRow[s*4+1] = obs.value; | dataRow[s*4+1] = obs.value; | ||
dataRow[ cc-1 ] = obs.value; | //dataRow[ cc-1 ] = obs.value; | ||
} else { | } else { | ||
dataRow[s*4+1] = obs.value + memo.distF*Math.random() - memo.distF*Math.random(); | dataRow[s*4+1] = obs.value + memo.distF*Math.random() - memo.distF*Math.random(); | ||
dataRow[ cc-1 ] = obs.value; | //dataRow[ cc-1 ] = obs.value; | ||
} | } | ||
dataRow[s*4+2] = obs.style; | dataRow[s*4+2] = obs.style; | ||
| Rivi 695: | Rivi 695: | ||
} | } | ||
// make week averages | |||
memo.avgW = {}; | |||
for (var o in memo.obsesA) { | |||
mwDate = new Date( memo.obsesA[o].compareDate.getFullYear(), memo.obsesA[o].compareDate.getMonth(), memo.obsesA[o].compareDate.getDate() ); | |||
y = mwDate.getFullYear(); | |||
w = mwDate.getWeek(); | |||
v = memo.obsesA[o].value + memo.distF*Math.random() - memo.distF*Math.random(); | |||
if ( typeof memo.avgW[y] == 'undefined' ) { memo.avgW[y] = {}; } | |||
if ( typeof memo.avgW[y][w] == 'undefined' ) { | |||
mwDate.setDate( mwDate.getDate() - mwDate.getDay() + 3 ) | |||
memo.avgW[y][w] = { cDate: mwDate, values: [ v ], sum: v, count: 1, avg: v }; | |||
} else { | |||
memo.avgW[y][w].values.push( v ); | |||
memo.avgW[y][w].sum += v; | |||
memo.avgW[y][w].count++; | |||
memo.avgW[y][w].avg = memo.avgW[y][w].sum / memo.avgW[y][w].count; | |||
} | |||
} | |||
console.log(memo.avgW); | |||
// make ticks for x axis | // make ticks for x axis | ||


