Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4bd8cf4

Browse filesBrowse files
authored
Update docs for Developers API (#12082)
- .update(): add documentation for function argument support - isDatasetVisible(): add missing method documentation with example - getDataVisibility(): fix anchor link for toggleDataVisibility - Static: unregister(): add example
1 parent 8ea47ca commit 4bd8cf4
Copy full SHA for 4bd8cf4

File tree

Expand file treeCollapse file tree

1 file changed

+24
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+24
-3
lines changed

‎docs/developers/api.md

Copy file name to clipboardExpand all lines: docs/developers/api.md
+24-3Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,19 @@ Triggers an update of the chart. This can be safely called after updating the da
2525
myLineChart.data.datasets[0].data[2] = 50; // Would update the first dataset's value of 'March' to be 50
2626
myLineChart.update(); // Calling update now animates the position of March from 90 to 50.
2727
```
28+
A `mode` can be provided to indicate transition configuration should be used. This can be either:
2829

29-
A `mode` string can be provided to indicate transition configuration should be used. Core calls this method using any of `'active'`, `'hide'`, `'reset'`, `'resize'`, `'show'` or `undefined`. `'none'` is also a supported mode for skipping animations for single update. Please see [animations](../configuration/animations.md) docs for more details.
30+
- **string value**: Core calls this method using any of `'active'`, `'hide'`, `'reset'`, `'resize'`, `'show'` or `undefined`. `'none'` is also supported for skipping animations for single update. Please see [animations](../configuration/animations.md) docs for more details.
3031

31-
Example:
32+
- **function**: that receives a context object `{ datasetIndex: number }` and returns a mode string, allowing different modes per dataset.
3233

34+
Examples:
3335
```javascript
36+
// Using string mode
3437
myChart.update('active');
38+
39+
// Using function mode for dataset-specific animations
40+
myChart.update(ctx => ctx.datasetIndex === 0 ? 'active' : 'none');
3541
```
3642

3743
See [Updating Charts](updates.md) for more details.
@@ -141,6 +147,15 @@ Returns the number of datasets that are currently not hidden.
141147
```javascript
142148
const numberOfVisibleDatasets = chart.getVisibleDatasetCount();
143149
```
150+
## isDatasetVisible(datasetIndex)
151+
152+
Returns a boolean if a dataset at the given index is currently visible.
153+
154+
The visibility is determined by first checking the hidden property in the dataset metadata (set via [`setDatasetVisibility()`](#setdatasetvisibility-datasetindex-visibility) and accessible through [`getDatasetMeta()`](#getdatasetmeta-index)). If this is not set, the hidden property of the dataset object itself (`chart.data.datasets[n].hidden`) is returned.
155+
156+
```javascript
157+
chart.isDatasetVisible(1);
158+
```
144159

145160
## setDatasetVisibility(datasetIndex, visibility)
146161

@@ -162,7 +177,7 @@ chart.update(); // chart now renders with item hidden
162177

163178
## getDataVisibility(index)
164179

165-
Returns the stored visibility state of a data index for all datasets. Set by [toggleDataVisibility](#toggleDataVisibility). A dataset controller should use this method to determine if an item should not be visible.
180+
Returns the stored visibility state of a data index for all datasets. Set by [toggleDataVisibility](#toggledatavisibility-index). A dataset controller should use this method to determine if an item should not be visible.
166181

167182
```javascript
168183
const visible = chart.getDataVisibility(2);
@@ -229,3 +244,9 @@ Chart.register(Tooltip, LinearScale, PointElement, BubbleController);
229244
## Static: unregister(chartComponentLike)
230245

231246
Used to unregister plugins, axis types or chart types globally from all your charts.
247+
248+
```javascript
249+
import { Chart, Tooltip, LinearScale, PointElement, BubbleController } from 'chart.js';
250+
251+
Chart.unregister(Tooltip, LinearScale, PointElement, BubbleController);
252+
```

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.