]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Add type to context objects (#8007)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Sun, 8 Nov 2020 13:43:55 +0000 (15:43 +0200)
committerGitHub <noreply@github.com>
Sun, 8 Nov 2020 13:43:55 +0000 (08:43 -0500)
docs/docs/general/options.md
src/core/core.controller.js
src/core/core.datasetController.js
src/core/core.scale.js

index 399c1d43cfac947d1f5fd12af20f5c990bfd6902..695f1ba3e4bfd7a066c58ac241d2f1acc4281ac7 100644 (file)
@@ -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'`
index 6ff953addd4bf89674c3a064329199ca8cc9a490..fa160c6ed4947e7c06e5252fb58739ad4d125854 100644 (file)
@@ -735,6 +735,9 @@ class Chart {
                return this.$context || (this.$context = Object.create(null, {
                        chart: {
                                value: this
+                       },
+                       type: {
+                               value: 'chart'
                        }
                }));
        }
index 83566956d1e270c7b1e1861157c0233977c8f1c8..d7bfab12b469d0e1d87df64b1810de1a82f54d76 100644 (file)
@@ -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',
                }
        });
 }
index 84cd4e3d57e7b09158d6d630678e5f2c4870cc31..eac35448a4261f8257414859404c6266f41b801b 100644 (file)
@@ -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'
                }
        });
 }