Skip to content

Commit 77c785f

Browse files
committed
[dev] update scales article
Modernize code example and normalize formatting
1 parent c3ee357 commit 77c785f

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

docs/api/config/scales.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,27 @@ description: "defines configuration settings of the time scale"
1616

1717
~~~jsx
1818
gantt.config.scales = [
19-
{unit: "month", step: 1, format: "%F, %Y"},
20-
{unit: "week", step: 1, format: function (date) {
21-
return "Week #" + gantt.date.getWeek(date);
22-
}},
23-
{unit: "day", step: 1, format: "%D", css: function(date) {
24-
if(!gantt.isWorkTime({ date: date, unit: "day"})){
25-
return "weekend"
26-
}
27-
}}
19+
{ unit: "month", step: 1, format: "%F, %Y" },
20+
{
21+
unit: "week",
22+
step: 1,
23+
format: (date) => `Week #${gantt.date.getWeek(date)}`
24+
},
25+
{
26+
unit: "day",
27+
step: 1,
28+
format: "%D",
29+
css: (date) => !gantt.isWorkTime({ date, unit: "day" }) ? "weekend" : ""
30+
}
2831
];
2932
~~~
3033

3134
### Details
3235

3336
Each object in the array specifies a single scale. An object can take the following attributes:
3437

35-
- **unit** - (*string*) - the name of the scale unit. The available values are: "minute", "hour", "day" (default), "week", "quarter", "month", "year".
36-
There is also a possiblity to set a custom unit. Read more on the topic [here](guides/configuring-time-scale.md#customtimeunits).
38+
- **unit** - (*string*) - the name of the scale unit. The available values are: "minute", "hour", "day" (default), "week", "quarter", "month", "year".
39+
There is also a possibility to set a custom unit. Read more on the topic [here](guides/configuring-time-scale.md#customtimeunits).
3740
- **step?** - (*number*) - the step of the time scale (X-Axis), 1 by default.
3841
- **format? (date): any** - (*string | Function*) - the format of the scale's labels. If set as a function, expects a date object as a parameter.
3942
- **_date_** - (*Date*) - a date that will be converted

0 commit comments

Comments
 (0)