]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Update context documentation (#8626)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Sat, 13 Mar 2021 13:05:57 +0000 (15:05 +0200)
committerGitHub <noreply@github.com>
Sat, 13 Mar 2021 13:05:57 +0000 (08:05 -0500)
docs/docs/general/options.md
src/core/core.datasetController.js

index 7591b933c89634620e7a0b017dfa4c9cc9d231d9..ab51010531c13f290140e7bdd6eb6024731752a8 100644 (file)
@@ -70,6 +70,8 @@ A plugin can provide `additionalOptionScopes` array of paths to additionally loo
 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)).
 A resolver is passed as second parameter, that can be used to access other options in the same context.
 
+> **Note:** the `context` argument should be validated in the scriptable function, because the function can be invoked in different contexts. The `type` field is a good candidate for this validation.
+
 Example:
 
 ```javascript
@@ -132,7 +134,7 @@ 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`
+* `index`: same as `datasetIndex`
 * `mode`: the update mode
 * `type`: `'dataset'`
 
@@ -145,8 +147,7 @@ In addition to [dataset](#dataset)
 * `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`
-* `mode`: the update mode
+* `index`: same as `dataIndex`
 * `type`: `'data'`
 
 ### scale
index c02f90cc43f90306dbe2cd33070040789dd98a3c..bc72ff7191bf1f9c716d59f429f40c7f8fc492d0 100644 (file)
@@ -158,6 +158,7 @@ function createDatasetContext(parent, index, dataset) {
       dataset,
       datasetIndex: index,
       index,
+      mode: 'default',
       type: 'dataset'
     }
   );