Ero sivun ”Widget:JwObsCharts2” versioiden välillä
Järvi-meriwikistä
Rivi 1 091: | Rivi 1 091: | ||
// series for trend line | // 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' }; | //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.printouts.ObsCode == memo.refcode ) { | ||
+ | memo.obsesA[o].compareDate = getDateOfISOWeek( memo.obsesA.printouts.DataJSON.week, memo.curYear ); | ||
+ | } | ||
+ | } | ||
+ | |||
console.log( memo.obsesA ); | console.log( memo.obsesA ); | ||
for (var o in memo.obsesA) { | for (var o in memo.obsesA) { | ||
Rivi 1 788: | Rivi 1 795: | ||
var week1 = new Date(date.getFullYear(), 0, 4); | var week1 = new Date(date.getFullYear(), 0, 4); | ||
// Adjust to Thursday in week 1 and count number of weeks from date to week1. | // Adjust to Thursday in week 1 and count number of weeks from date to week1. | ||
− | return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000 | + | 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 maintColors = { 'authority': '#bb1111', 'expert': '#ff9933', 'experienced': '#666666', 'user': '#aaaaaa'}; |