Skip to content

Commit

Permalink
Document new time options
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Aug 1, 2017
1 parent 97e2373 commit 8def8c5
Showing 1 changed file with 51 additions and 11 deletions.
62 changes: 51 additions & 11 deletions docs/axes/cartesian/time.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
| `scales.distribution` | `String` | `linear` | How data is plotted. Valid options are `linear` and `series`. [more...](#scale-distribution)
| `ticks.bounds` | `String` | `data` | Determines the scale bounds. Valid options are `data` and `labels`. [more...](#scale-bounds)
| `ticks.source` | `String` | `auto` | How ticks are generated. Valid options are `auto`, `data, and `labels`. [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

Expand Down Expand Up @@ -106,6 +109,43 @@ var chart = new Chart(ctx, {
})
```

### Scale Distribution

This 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

This property controls the ticks boundary strategy (bypassed by min/max time options)

* `data`: make sure data are fully visible, labels outside are removed
* `labels`: make sure labels are fully visible, data outside are truncated

### Ticks Source

This 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.

Expand Down

0 comments on commit 8def8c5

Please sign in to comment.