You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/configuration/index.md
+8-16Lines changed: 8 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,23 +10,23 @@ This concept was introduced in Chart.js 1.0 to keep configuration [DRY](https://
10
10
11
11
Chart.js merges the options object passed to the chart with the global configuration using chart type defaults and scales defaults appropriately. This way you can be as specific as you would like in your individual chart configuration, while still changing the defaults for all chart types where applicable. The global general options are defined in `Chart.defaults`. The defaults for each chart type are discussed in the documentation for that chart type.
12
12
13
-
The following example would set the hover mode to 'nearest' for all charts where this was not overridden by the chart type defaults or the options passed to the constructor on creation.
13
+
The following example would set the interaction mode to 'nearest' for all charts where this was not overridden by the chart type defaults or the options passed to the constructor on creation.
14
14
15
15
```javascript
16
-
Chart.defaults.hover.mode='nearest';
16
+
Chart.defaults.interaction.mode='nearest';
17
17
18
-
//Hover mode is set to nearest because it was not overridden here
19
-
varchartHoverModeNearest=newChart(ctx, {
18
+
//Interaction mode is set to nearest because it was not overridden here
19
+
varchartInteractionModeNearest=newChart(ctx, {
20
20
type:'line',
21
21
data: data
22
22
});
23
23
24
-
// This chart would have the hover mode that was passed in
25
-
varchartDifferentHoverMode=newChart(ctx, {
24
+
// This chart would have the interaction mode that was passed in
25
+
varchartDifferentInteractionMode=newChart(ctx, {
26
26
type:'line',
27
27
data: data,
28
28
options: {
29
-
hover: {
29
+
interaction: {
30
30
// Overrides the global setting
31
31
mode:'index'
32
32
}
@@ -36,15 +36,7 @@ var chartDifferentHoverMode = new Chart(ctx, {
36
36
37
37
## Dataset Configuration
38
38
39
-
Options may be configured directly on the dataset. The dataset options can be changed at 3 different levels and are evaluated with the following priority:
40
-
41
-
- per dataset: dataset.*
42
-
- per chart: options.datasets[type].*
43
-
- or globally: Chart.defaults.controllers[type].datasets.*
44
-
45
-
where type corresponds to the dataset type.
46
-
47
-
*Note:* dataset options take precedence over element options.
39
+
Options may be configured directly on the dataset. The dataset options can be changed at multiple different levels. See [options](../general/options.md#dataset-level-options) for details on how the options are resolved.
48
40
49
41
The following example would set the `showLine` option to 'false' for all line datasets except for those overridden by options passed to the dataset on creation.
Copy file name to clipboardExpand all lines: docs/docs/configuration/interactions/index.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,3 +9,5 @@ The interaction configuration can be adjusted in the `options.interaction` names
9
9
| `mode` | `string` | `'nearest'` | Sets which elements appear in the tooltip. See [Interaction Modes](modes.md#interaction-modes) for details.
10
10
| `intersect` | `boolean` | `true` | if true, the hover mode only applies when the mouse position intersects an item on the chart.
11
11
| `axis` | `string` | `'x'` | Can be set to `'x'`, `'y'`, or `'xy'` to define which directions are used in calculating distances. Defaults to `'x'` for `'index'` mode and `'xy'` in `dataset` and `'nearest'` modes.
12
+
13
+
The same options can be set into the `options.hover` namespace, in which case they will only affect the hover effect and the tooltip configuration will be kept independent.
Each scope is looked up with `elementType` prefix in the option name first, then wihtout the prefix. For example, `radius` for `point` element is looked up using `pointRadius` and if that does not hit, then `radius`.
A plugin can provide `additionalOptionScopes` array of paths to additionally look for its options in. For root scope, use empty string: `''`. Most core plugins also take options from root scope.
Scriptable options also accept a function which is called for each of the underlying data values and that takes the unique argument `context` representing contextual information (see [option context](options.md#option-context)).
72
+
A resolver is passed as second parameter, that can be used to access other options in the same context.
8
73
9
74
Example:
10
75
@@ -15,6 +80,10 @@ color: function(context) {
15
80
return value <0?'red':// draw negative values in red
16
81
index %2?'blue':// else, alternate values in blue and green
17
82
'green';
83
+
},
84
+
borderColor:function(context, options) {
85
+
var color =options.color; // resolve the value of another scriptable option: 'red', 'blue' or 'green'
86
+
returnChart.helpers.color(color).lighten(0.2);
18
87
}
19
88
```
20
89
@@ -64,6 +133,7 @@ In addition to [chart](#chart)
64
133
*`dataset`: dataset at index `datasetIndex`
65
134
*`datasetIndex`: index of the current dataset
66
135
*`index`: getter for `datasetIndex`
136
+
*`mode`: the update mode
67
137
*`type`: `'dataset'`
68
138
69
139
### data
@@ -76,6 +146,7 @@ In addition to [dataset](#dataset)
76
146
*`raw`: the raw data values for the given `dataIndex` and `datasetIndex`
77
147
*`element`: the element (point, arc, bar, etc.) for this data
Copy file name to clipboardExpand all lines: docs/docs/getting-started/integration.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,6 +46,7 @@ import {
46
46
RadialLinearScale,
47
47
TimeScale,
48
48
TimeSeriesScale,
49
+
Decimation,
49
50
Filler,
50
51
Legend,
51
52
Title,
@@ -71,6 +72,7 @@ Chart.register(
71
72
RadialLinearScale,
72
73
TimeScale,
73
74
TimeSeriesScale,
75
+
Decimation,
74
76
Filler,
75
77
Legend,
76
78
Title,
@@ -80,6 +82,13 @@ Chart.register(
80
82
var myChart =newChart(ctx, {...});
81
83
```
82
84
85
+
A short registration format is also available to quickly register everything.
86
+
87
+
```javascript
88
+
import { Chart, registerables } from'chart.js';
89
+
Chart.register(...registerables);
90
+
```
91
+
83
92
## Require JS
84
93
85
94
**Important:** RequireJS [can **not** load CommonJS module as is](https://requirejs.org/docs/commonjs.html#intro), so be sure to require one of the UMD builds instead (i.e. `dist/chart.js`, `dist/chart.min.js`, etc.).
Copy file name to clipboardExpand all lines: docs/docs/getting-started/v3-migration.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,6 +63,10 @@ A number of changes were made to the configuration options passed to the `Chart`
63
63
64
64
* Indexable options are now looping. `backgroundColor: ['red', 'green']` will result in alternating `'red'` / `'green'` if there are more than 2 data points.
65
65
* The input properties of object data can now be freely specified, see [data structures](../general/data-structures.md) for details.
66
+
* Most options are resolved utilizing proxies, instead merging with defaults. In addition to easily enabling different resolution routes for different contexts, it allows using other resolved options in scriptable options.
67
+
* Options are by default scriptable and indexable, unless disabled for some reason.
68
+
* Scriptable options receive a option reolver as second parameter for accessing other options in same context.
69
+
* Resolution falls to upper scopes, if no match is found earlier. See [options](./general/options.md) for details.
66
70
67
71
#### Specific changes
68
72
@@ -492,6 +496,7 @@ All helpers are now exposed in a flat hierarchy, e.g., `Chart.helpers.canvas.cli
492
496
*`helpers.getMaximumHeight` was replaced by `helpers.dom.getMaximumSize`
493
497
*`helpers.getMaximumWidth` was replaced by `helpers.dom.getMaximumSize`
494
498
*`helpers.clear` was renamed to `helpers.clearCanvas` and now takes `canvas` and optionally `ctx` as parameter(s).
499
+
*`helpers.retinaScale` accepts optional third parameter `forceStyle`, which forces overriding current canvas style. `forceRatio` no longer falls back to `window.devicePixelRatio`, instead it defaults to `1`.
0 commit comments