]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
clarify api docs (#10392)
authorJacco van den Berg <39033624+LeeLenaleee@users.noreply.github.com>
Wed, 1 Jun 2022 18:38:39 +0000 (20:38 +0200)
committerGitHub <noreply@github.com>
Wed, 1 Jun 2022 18:38:39 +0000 (14:38 -0400)
docs/developers/api.md
docs/developers/updates.md

index beec9fdaa05b94b9cf4c2736733dde821cf27d6b..12b78663128fa2e3d12fd8d9264e6046e1a111fd 100644 (file)
@@ -113,6 +113,14 @@ function clickHandler(evt) {
 }
 ```
 
+## .getSortedVisibleDatasetMetas()
+
+Returns an array of all the dataset meta's in the order that they are drawn on the canvas that are not hidden.
+
+```javascript
+const visibleMetas = chart.getSortedVisibleDatasetMetas();
+```
+
 ## .getDatasetMeta(index)
 
 Looks for the dataset that matches the current index and returns that metadata. This returned data has all of the metadata that is used to construct the chart.
@@ -126,6 +134,14 @@ const meta = myChart.getDatasetMeta(0);
 const x = meta.data[0].x;
 ```
 
+## getVisibleDatasetCount
+
+Returns the amount of datasets that are currently not hidden.
+
+```javascript
+const numberOfVisibleDatasets = chart.getVisibleDatasetCount();
+```
+
 ## setDatasetVisibility(datasetIndex, visibility)
 
 Sets the visibility for a given dataset. This can be used to build a chart legend in HTML. During click on one of the HTML items, you can call `setDatasetVisibility` to change the appropriate dataset.
@@ -191,3 +207,17 @@ Finds the chart instance from the given key. If the key is a `string`, it is int
 ```javascript
 const chart = Chart.getChart("canvas-id");
 ```
+
+## Static: register(chartComponentLike)
+
+Used to register plugins, axis types or chart types globally to all your charts.
+
+```javascript
+import { Chart, Tooltip, LinearScale, PointElement, BubbleController } from 'chart.js';
+
+Chart.register(Tooltip, LinearScale, PointElement, BubbleController);
+```
+
+## Static: unregister(chartComponentLike)
+
+Used to unregister plugins, axis types or chart types globally from all your charts.
index 76aac266e2f88438e0db013ed06e526b72a26b06..abacad4db06b10cde517a4da13edd4997dc1554e 100644 (file)
@@ -100,3 +100,7 @@ Code sample for updating options can be found in [toggle-scale-type.html](https:
 ## Preventing Animations
 
 Sometimes when a chart updates, you may not want an animation. To achieve this you can call `update` with `'none'` as mode.
+
+```javascript
+myChart.update('none');
+```