diff --git a/examples/timeline/styling/weekStyling.html b/examples/timeline/styling/weekStyling.html index 9a3a919e5..53663ac0c 100644 --- a/examples/timeline/styling/weekStyling.html +++ b/examples/timeline/styling/weekStyling.html @@ -26,7 +26,21 @@ of moment.js including locales.

To set a locale for the timeline, specify the option {locale: STRING}.

-

To set the scale to use week numbers, use for example {scale: 'week', step: 1}.

+

+ To set the scale to use week numbers, use the following options: + + { + timeAxis: { + scale: 'week', + step: 1 + }, + format: { + minorLabels: {week: 'w'} + } + } + +

+

The following timeline is initialized with the 'de' locale and items are added with locally localized moment.js objects. The timeline locale can be switched to another locale at runtime. If you choose the 'en' locale, the week numbers will be calculated according to the US week calendar numbering scheme.

@@ -93,7 +107,16 @@ } // Configuration for the Timeline - var options = {timeAxis: {scale: 'week', step: 1}, locale: 'de'}; + var options = { + locale: 'de', + timeAxis: { + scale: 'week', + step: 1 + }, + format: { + minorLabels: {week: 'w'} + } + }; // Create a Timeline var timeline = new vis.Timeline(container, items, groups, options); @@ -108,4 +131,4 @@ select.onchange(); - \ No newline at end of file + diff --git a/lib/timeline/TimeStep.js b/lib/timeline/TimeStep.js index f72fd1c08..1b3c11112 100644 --- a/lib/timeline/TimeStep.js +++ b/lib/timeline/TimeStep.js @@ -73,7 +73,7 @@ TimeStep.FORMAT = { hour: 'HH:mm', weekday: 'ddd D', day: 'D', - week: 'w', + week: 'D', month: 'MMM', year: 'YYYY' }, @@ -340,7 +340,7 @@ TimeStep.prototype.setMinimumStep = function(minimumStep) { if (stepYear > minimumStep) {this.scale = 'year'; this.step = 1;} if (stepMonth*3 > minimumStep) {this.scale = 'month'; this.step = 3;} if (stepMonth > minimumStep) {this.scale = 'month'; this.step = 1;} - if (stepDay*5 > minimumStep) {this.scale = 'day'; this.step = 5;} + if (stepDay*7 > minimumStep) {this.scale = 'week'; this.step = 1;} if (stepDay*2 > minimumStep) {this.scale = 'day'; this.step = 2;} if (stepDay > minimumStep) {this.scale = 'day'; this.step = 1;} if (stepDay/2 > minimumStep) {this.scale = 'weekday'; this.step = 1;}