Skip to content

Commit 500530d

Browse files
committed
fix merge conflict
2 parents d4a8f31 + b468bff commit 500530d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+7032
-1242
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ end_of_line = lf
88
charset = utf-8
99
trim_trailing_whitespace = true
1010
insert_final_newline = true
11+
12+
[*.html]
13+
indent_style = tab
14+
indent_size = 4

.eslintrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
extends:
22
- chartjs
3-
- plugin:es/no-2019
3+
- plugin:es/no-new-in-es2019
44

55
env:
66
es6: true

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,27 @@ jobs:
2626
- uses: actions/checkout@v2
2727
- name: Use Node.js
2828
uses: actions/setup-node@v1
29+
with:
30+
node-version: '14'
2931
- uses: dorny/paths-filter@v2
3032
id: changes
3133
with:
3234
filters: |
3335
docs:
3436
- 'docs/**'
37+
- 'package.json'
38+
- 'tsconfig.json'
3539
src:
3640
- 'src/**'
41+
- 'package.json'
3742
test:
3843
- 'test/**'
3944
- 'karma.conf.js'
45+
- 'package.json'
4046
types:
4147
- 'types/**'
48+
- 'package.json'
49+
- 'tsconfig.json'
4250
- name: Install
4351
run: npm ci
4452
- name: Build

.github/workflows/compressed-size.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Compressed Size
22

3-
on: [pull_request]
3+
on: [pull_request_target]
44

55
jobs:
66
build:

docs/docs/configuration/index.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ This concept was introduced in Chart.js 1.0 to keep configuration [DRY](https://
1010

1111
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.
1212

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

1515
```javascript
16-
Chart.defaults.hover.mode = 'nearest';
16+
Chart.defaults.interaction.mode = 'nearest';
1717

18-
// Hover mode is set to nearest because it was not overridden here
19-
var chartHoverModeNearest = new Chart(ctx, {
18+
// Interaction mode is set to nearest because it was not overridden here
19+
var chartInteractionModeNearest = new Chart(ctx, {
2020
type: 'line',
2121
data: data
2222
});
2323

24-
// This chart would have the hover mode that was passed in
25-
var chartDifferentHoverMode = new Chart(ctx, {
24+
// This chart would have the interaction mode that was passed in
25+
var chartDifferentInteractionMode = new Chart(ctx, {
2626
type: 'line',
2727
data: data,
2828
options: {
29-
hover: {
29+
interaction: {
3030
// Overrides the global setting
3131
mode: 'index'
3232
}
@@ -36,15 +36,7 @@ var chartDifferentHoverMode = new Chart(ctx, {
3636

3737
## Dataset Configuration
3838

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

4941
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.
5042

docs/docs/configuration/interactions/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ The interaction configuration can be adjusted in the `options.interaction` names
99
| `mode` | `string` | `'nearest'` | Sets which elements appear in the tooltip. See [Interaction Modes](modes.md#interaction-modes) for details.
1010
| `intersect` | `boolean` | `true` | if true, the hover mode only applies when the mouse position intersects an item on the chart.
1111
| `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.

docs/docs/general/options.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,74 @@
22
title: Options
33
---
44

5+
## Option resolution
6+
7+
Options are resolved from top to bottom, using a context dependent route.
8+
9+
### Chart level options
10+
11+
* options
12+
* defaults.controllers[`config.type`]
13+
* defaults
14+
15+
### Dataset level options
16+
17+
`dataset.type` defaults to `config.type`, if not specified.
18+
19+
* dataset
20+
* options.datasets[`dataset.type`]
21+
* options.controllers[`dataset.type`].datasets
22+
* options
23+
* defaults.datasets[`dataset.type`]
24+
* defaults.controllers[`dataset.type`].datasets
25+
* defaults
26+
27+
### Dataset animation options
28+
29+
* dataset.animation
30+
* options.controllers[`dataset.type`].datasets.animation
31+
* options.animation
32+
* defaults.controllers[`dataset.type`].datasets.animation
33+
* defaults.animation
34+
35+
### Dataset element level options
36+
37+
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`.
38+
39+
* dataset
40+
* options.datasets[`dataset.type`]
41+
* options.controllers[`dataset.type`].datasets
42+
* options.controllers[`dataset.type`].elements[`elementType`]
43+
* options.elements[`elementType`]
44+
* options
45+
* defaults.datasets[`dataset.type`]
46+
* defaults.controllers[`dataset.type`].datasets
47+
* defaults.controllers[`dataset.type`].elements[`elementType`]
48+
* defaults.elements[`elementType`]
49+
* defaults
50+
51+
### Scale options
52+
53+
* options.scales
54+
* defaults.controllers[`config.type`].scales
55+
* defaults.controllers[`dataset.type`].scales
56+
* defaults.scales
57+
58+
### Plugin options
59+
60+
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.
61+
62+
* options.plugins[`plugin.id`]
63+
* options.controllers[`config.type`].plugins[`plugin.id`]
64+
* (options.[`...plugin.additionalOptionScopes`])
65+
* defaults.controllers[`config.type`].plugins[`plugin.id`]
66+
* defaults.plugins[`plugin.id`]
67+
* (defaults.[`...plugin.additionalOptionScopes`])
68+
569
## Scriptable Options
670

771
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.
873

974
Example:
1075

@@ -15,6 +80,10 @@ color: function(context) {
1580
return value < 0 ? 'red' : // draw negative values in red
1681
index % 2 ? 'blue' : // else, alternate values in blue and green
1782
'green';
83+
},
84+
borderColor: function(context, options) {
85+
var color = options.color; // resolve the value of another scriptable option: 'red', 'blue' or 'green'
86+
return Chart.helpers.color(color).lighten(0.2);
1887
}
1988
```
2089

@@ -64,6 +133,7 @@ In addition to [chart](#chart)
64133
* `dataset`: dataset at index `datasetIndex`
65134
* `datasetIndex`: index of the current dataset
66135
* `index`: getter for `datasetIndex`
136+
* `mode`: the update mode
67137
* `type`: `'dataset'`
68138

69139
### data
@@ -76,6 +146,7 @@ In addition to [dataset](#dataset)
76146
* `raw`: the raw data values for the given `dataIndex` and `datasetIndex`
77147
* `element`: the element (point, arc, bar, etc.) for this data
78148
* `index`: getter for `dataIndex`
149+
* `mode`: the update mode
79150
* `type`: `'data'`
80151

81152
### scale

docs/docs/getting-started/integration.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import {
4646
RadialLinearScale,
4747
TimeScale,
4848
TimeSeriesScale,
49+
Decimation,
4950
Filler,
5051
Legend,
5152
Title,
@@ -71,6 +72,7 @@ Chart.register(
7172
RadialLinearScale,
7273
TimeScale,
7374
TimeSeriesScale,
75+
Decimation,
7476
Filler,
7577
Legend,
7678
Title,
@@ -80,6 +82,13 @@ Chart.register(
8082
var myChart = new Chart(ctx, {...});
8183
```
8284

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+
8392
## Require JS
8493

8594
**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.).

docs/docs/getting-started/v3-migration.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ A number of changes were made to the configuration options passed to the `Chart`
6363

6464
* Indexable options are now looping. `backgroundColor: ['red', 'green']` will result in alternating `'red'` / `'green'` if there are more than 2 data points.
6565
* 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.
6670

6771
#### Specific changes
6872

@@ -492,6 +496,7 @@ All helpers are now exposed in a flat hierarchy, e.g., `Chart.helpers.canvas.cli
492496
* `helpers.getMaximumHeight` was replaced by `helpers.dom.getMaximumSize`
493497
* `helpers.getMaximumWidth` was replaced by `helpers.dom.getMaximumSize`
494498
* `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`.
495500

496501
#### Platform
497502

0 commit comments

Comments
 (0)