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

Fix type definitions and docs for getPixelForValue #9263

Merged
merged 1 commit into from Jun 14, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions docs/developers/axes.md
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/v3-migration.md
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion types/index.esm.d.ts
Expand Up @@ -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
Expand Down