From: Ben McCann Date: Tue, 8 Aug 2017 21:39:19 +0000 (-0700) Subject: Document new time options (#4592) X-Git-Tag: v2.7.0~1^2~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4697226c8c932e69087c2fef109e5dcd0b671348;p=thirdparty%2FChart.js.git Document new time options (#4592) --- diff --git a/docs/axes/cartesian/time.md b/docs/axes/cartesian/time.md index 6e107d515..e087d1868 100644 --- a/docs/axes/cartesian/time.md +++ b/docs/axes/cartesian/time.md @@ -23,20 +23,23 @@ When providing data for the time scale, Chart.js supports all of the formats tha ## Configuration Options -The following options are provided by the time scale. They are all located in the `time` sub options. These options extend the [common tick configuration](README.md#tick-configuration). +The following options are provided by the time scale. You may also set options provided by the [common tick configuration](README.md#tick-configuration). | Name | Type | Default | Description | -----| ---- | --------| ----------- -| `displayFormats` | `Object` | | Sets how different time units are displayed. [more...](#display-formats) -| `isoWeekday` | `Boolean` | `false` | If true and the unit is set to 'week', iso weekdays will be used. -| `max` | [Time](#date-formats) | | If defined, this will override the data maximum -| `min` | [Time](#date-formats) | | If defined, this will override the data minimum -| `parser` | `String` or `Function` | | Custom parser for dates. [more...](#parser) -| `round` | `String` | `false` | If defined, dates will be rounded to the start of this unit. See [Time Units](#time-units) below for the allowed units. -| `tooltipFormat` | `String` | | The moment js format string to use for the tooltip. -| `unit` | `String` | `false` | If defined, will force the unit to be a certain type. See [Time Units](#time-units) section below for details. -| `stepSize` | `Number` | `1` | The number of units between grid lines. -| `minUnit` | `String` | `'millisecond'` | The minimum display format to be used for a time unit. +| `distribution` | `String` | `linear` | How data is plotted. [more...](#scale-distribution) +| `bounds` | `String` | `data` | Determines the scale bounds. [more...](#scale-bounds) +| `ticks.source` | `String` | `auto` | How ticks are generated. [more...](#ticks-source) +| `time.displayFormats` | `Object` | | Sets how different time units are displayed. [more...](#display-formats) +| `time.isoWeekday` | `Boolean` | `false` | If true and the unit is set to 'week', then the first day of the week will be Monday. Otherwise, it will be Sunday. +| `time.max` | [Time](#date-formats) | | If defined, this will override the data maximum +| `time.min` | [Time](#date-formats) | | If defined, this will override the data minimum +| `time.parser` | `String` or `Function` | | Custom parser for dates. [more...](#parser) +| `time.round` | `String` | `false` | If defined, dates will be rounded to the start of this unit. See [Time Units](#time-units) below for the allowed units. +| `time.tooltipFormat` | `String` | | The moment js format string to use for the tooltip. +| `time.unit` | `String` | `false` | If defined, will force the unit to be a certain type. See [Time Units](#time-units) section below for details. +| `time.stepSize` | `Number` | `1` | The number of units between grid lines. +| `time.minUnit` | `String` | `'millisecond'` | The minimum display format to be used for a time unit. ### Time Units @@ -106,6 +109,43 @@ var chart = new Chart(ctx, { }) ``` +### Scale Distribution + +The `distribution` property controls the data distribution along the scale: + + * `'linear'`: data are spread according to their time (distances can vary) + * `'series'`: data are spread at the same distance from each other + +```javascript +var chart = new Chart(ctx, { + type: 'line', + data: data, + options: { + scales: { + xAxes: [{ + type: 'time', + distribution: 'series' + }] + } + } +}) +``` + +### Scale Bounds + +The `bounds` property controls the scale boundary strategy (bypassed by min/max time options) + +* `'data'`: make sure data are fully visible, labels outside are removed +* `'ticks'`: make sure ticks are fully visible, data outside are truncated + +### Ticks Source + +The `ticks.source` property controls the ticks generation + +* `'auto'`: generates "optimal" ticks based on scale size and time options. +* `'data'`: generates ticks from data (including labels from data `{t|x|y}` objects) +* `'labels'`: generates ticks from user given `data.labels` values ONLY + ### Parser If this property is defined as a string, it is interpreted as a custom format to be used by moment to parse the date.