mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-11 10:46:52 +01:00
Add type to context objects (#8007)
This commit is contained in:
@@ -54,6 +54,7 @@ The context object contains the following properties:
|
||||
### chart
|
||||
|
||||
- `chart`: the associated chart
|
||||
- `type`: `'chart'`
|
||||
|
||||
### dataset
|
||||
|
||||
@@ -63,6 +64,7 @@ In addition to [chart](#chart)
|
||||
- `dataset`: dataset at index `datasetIndex`
|
||||
- `datasetIndex`: index of the current dataset
|
||||
- `index`: getter for `datasetIndex`
|
||||
- `type`: `'dataset'`
|
||||
|
||||
### data
|
||||
|
||||
@@ -73,12 +75,14 @@ In addition to [dataset](#dataset)
|
||||
- `dataPoint`: the parsed 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'`
|
||||
|
||||
### tick
|
||||
|
||||
@@ -86,3 +90,4 @@ In addition to [scale](#scale)
|
||||
|
||||
- `tick`: the associated tick object
|
||||
- `index`: tick index
|
||||
- `type`: `'tick'`
|
||||
|
||||
@@ -735,6 +735,9 @@ class Chart {
|
||||
return this.$context || (this.$context = Object.create(null, {
|
||||
chart: {
|
||||
value: this
|
||||
},
|
||||
type: {
|
||||
value: 'chart'
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -164,6 +164,9 @@ function createDatasetContext(parent, index, dataset) {
|
||||
get() {
|
||||
return this.datasetIndex;
|
||||
}
|
||||
},
|
||||
type: {
|
||||
value: 'dataset'
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -187,6 +190,9 @@ function createDataContext(parent, index, point, element) {
|
||||
get() {
|
||||
return this.dataIndex;
|
||||
}
|
||||
},
|
||||
type: {
|
||||
value: 'data',
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -274,6 +274,9 @@ function createScaleContext(parent, scale) {
|
||||
scale: {
|
||||
value: scale
|
||||
},
|
||||
type: {
|
||||
value: 'scale'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -284,6 +287,9 @@ function createTickContext(parent, index, tick) {
|
||||
},
|
||||
index: {
|
||||
value: index
|
||||
},
|
||||
type: {
|
||||
value: 'tick'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user