Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small chores #8408

Merged
merged 1 commit into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,9 @@
root = true

[*]
indent_style = tab
indent_size = 4
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.yml]
indent_style = space
indent_size = 2

[*.json]
indent_style = space
indent_size = 2

[*.mdx]
indent_style = space
indent_size = 2
48 changes: 24 additions & 24 deletions docs/docs/general/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,54 +41,54 @@ The object is preserved, so it can be used to store and pass information between

There are multiple levels of context objects:

- `chart`
- `dataset`
- `data`
- `scale`
- `tick`
* `chart`
* `dataset`
* `data`
* `scale`
* `tick`

Each level inherits its parent(s) and any contextual information stored in the parent is available through the child.

The context object contains the following properties:

### chart

- `chart`: the associated chart
- `type`: `'chart'`
* `chart`: the associated chart
* `type`: `'chart'`

### dataset

In addition to [chart](#chart)

- `active`: true if element is active (hovered)
- `dataset`: dataset at index `datasetIndex`
- `datasetIndex`: index of the current dataset
- `index`: getter for `datasetIndex`
- `type`: `'dataset'`
* `active`: true if element is active (hovered)
* `dataset`: dataset at index `datasetIndex`
* `datasetIndex`: index of the current dataset
* `index`: getter for `datasetIndex`
* `type`: `'dataset'`

### data

In addition to [dataset](#dataset)

- `active`: true if element is active (hovered)
- `dataIndex`: index of the current data
- `parsed`: the parsed data values for the given `dataIndex` and `datasetIndex`
- `raw`: the raw data values for the given `dataIndex` and `datasetIndex`
- `element`: the element (point, arc, bar, etc.) for this data
- `index`: getter for `dataIndex`
- `type`: `'data'`
* `active`: true if element is active (hovered)
* `dataIndex`: index of the current data
* `parsed`: the parsed data values for the given `dataIndex` and `datasetIndex`
* `raw`: the raw data values for the given `dataIndex` and `datasetIndex`
* `element`: the element (point, arc, bar, etc.) for this data
* `index`: getter for `dataIndex`
* `type`: `'data'`

### scale

In addition to [chart](#chart)

- `scale`: the associated scale
- `type`: `'scale'`
* `scale`: the associated scale
* `type`: `'scale'`

### tick

In addition to [scale](#scale)

- `tick`: the associated tick object
- `index`: tick index
- `type`: `'tick'`
* `tick`: the associated tick object
* `index`: tick index
* `type`: `'tick'`
4 changes: 1 addition & 3 deletions src/controllers/controller.polarArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ PolarAreaController.defaults = {
animateScale: true
},
aspectRatio: 1,
datasets: {
indexAxis: 'r'
},
indexAxis: 'r',
scales: {
r: {
type: 'radialLinear',
Expand Down
4 changes: 1 addition & 3 deletions src/controllers/controller.radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ RadarController.defaults = {
type: 'radialLinear',
}
},
datasets: {
indexAxis: 'r'
},
indexAxis: 'r',
elements: {
line: {
fill: 'start',
Expand Down
14 changes: 3 additions & 11 deletions src/core/core.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,10 @@ class Chart {
ensureScalesHaveIDs() {
const options = this.options;
const scalesOptions = options.scales || {};
const scaleOptions = options.scale;

each(scalesOptions, (axisOptions, axisID) => {
axisOptions.id = axisID;
});

if (scaleOptions) {
scaleOptions.id = scaleOptions.id || 'scale';
}
}

/**
Expand All @@ -256,7 +251,7 @@ class Chart {
const me = this;
const options = me.options;
const scaleOpts = options.scales;
const scales = me.scales || {};
const scales = me.scales;
const updated = Object.keys(scales).reduce((obj, id) => {
obj[id] = false;
return obj;
Expand Down Expand Up @@ -313,8 +308,6 @@ class Chart {
}
});

me.scales = scales;

each(scales, (scale) => {
layouts.configure(me, scale, scale.options);
layouts.addBox(me, scale);
Expand Down Expand Up @@ -435,7 +428,6 @@ class Chart {

update(mode) {
const me = this;
let i, ilen;

each(me.scales, (scale) => {
layouts.removeBox(me, scale);
Expand All @@ -462,7 +454,7 @@ class Chart {
me.notifyPlugins('beforeElementsUpdate');

// Make sure all dataset controllers have correct meta data counts
for (i = 0, ilen = me.data.datasets.length; i < ilen; i++) {
for (let i = 0, ilen = me.data.datasets.length; i < ilen; i++) {
const {controller} = me.getDatasetMeta(i);
const reset = !animsDisabled && newControllers.indexOf(controller) === -1;
// New controllers will be reset after the layout pass, so we only want to modify
Expand Down Expand Up @@ -1078,7 +1070,7 @@ class Chart {
}

// Invoke onHover hook
callCallback(options.onHover || options.hover.onHover, [e, active, me], me);
callCallback(options.onHover || hoverOptions.onHover, [e, active, me], me);

if (e.type === 'mouseup' || e.type === 'click' || e.type === 'contextmenu') {
if (_isPointInArea(e, me.chartArea)) {
Expand Down