]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix type definitions for `getPixelForValue` (#9263)
authorJosh Kelley <joshkel@gmail.com>
Mon, 14 Jun 2021 04:49:27 +0000 (00:49 -0400)
committerGitHub <noreply@github.com>
Mon, 14 Jun 2021 04:49:27 +0000 (07:49 +0300)
Update docs: From what I can tell, the `index` parameter was re-introduced as part of the new `normalized` option.

docs/developers/axes.md
docs/getting-started/v3-migration.md
types/index.esm.d.ts

index 01917928947fea11020e154f3102348e9a12c0fd..6bc4507126c9f2c0ac6f8f4bc194f9c8e239f3d7 100644 (file)
@@ -90,9 +90,8 @@ To work with Chart.js, custom scale types must implement the following interface
 
     // Get the pixel (x coordinate for horizontal axis, y coordinate for vertical axis) for a given value
     // @param value : the value to get the pixel for
-    // @param index : index into the data array of the value
-    // @param datasetIndex : index of the dataset the value comes from
-    getPixelForValue: function(value, index, datasetIndex) {},
+    // @param [index] : index into the data array of the value
+    getPixelForValue: function(value, index) {},
 
     // Get the value for a given pixel (x coordinate for horizontal axis, y coordinate for vertical axis)
     // @param pixel : pixel value
index 9372488bce432e5bc47c7b9a45e08618953997b7..7e4ba2ad0e0102b0cb70ab9cb41dd6eee4b0e766 100644 (file)
@@ -467,7 +467,7 @@ The APIs listed in this section have changed in signature or behaviour from vers
 #### Changed in Scales
 
 * `Scale.getLabelForIndex` was replaced by `scale.getLabelForValue`
-* `Scale.getPixelForValue` now has only one parameter. For the `TimeScale` that parameter must be millis since the epoch
+* `Scale.getPixelForValue` now only requires one parameter. For the `TimeScale` that parameter must be millis since the epoch. As a performance optimization, it may take an optional second parameter, giving the index of the data point.
 
 ##### Changed in Ticks
 
index 9043ac851a4dc35d3af802115a404390eceb984e..fd5c53848e539f22a8250a317a18fcbd207ad014 100644 (file)
@@ -1219,7 +1219,7 @@ export interface Scale<O extends CoreScaleOptions = CoreScaleOptions> extends El
    * @param {number} [index]
    * @return {number}
    */
-  getPixelForValue(value: number, index: number): number;
+  getPixelForValue(value: number, index?: number): number;
 
   /**
    * Used to get the data value from a given pixel. This is the inverse of getPixelForValue