You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a new hook to enable data decimation (#8255)
* Create a new hook to enable data decimation
The `beforeElementUpdate` hook can be used to decimate data. The chart
elements will not be created until after this hook has fired ensuring that
if decimation occurs, only the needed elements will be created.
* Address code review feedback
* Rename hook to beforeElementsUpdate
* Simplify parsing logic
* Add decimation plugin to the core
* Allow a dataset to specify a different data key
* Decimation plugin uses the dataKey feature
* Refactor the decimation plugin to support configurable algorithms
* Lint the plugin changes
* Tests for the dataKey feature
* Convert test files to tabs
* Standardize on tabs in ts files
* Remove the dataKey feature
* Replace dataKey usage in decimation plugin
We define a new descriptor for the `data` key allowing the
plugin to be simpler.
* Disable decimation when indexAxis is Y
* Simplify the decimation width approximation
* Resolve the indexAxis correctly in all cases
* Initial documentation
* Reverse check
* Update TS definitions for new plugin options
* Move defineProperty after bailouts
* Add destroy hook
The decimation plugin can be used with line charts to automatically decimate data at the start of the chart lifecycle. Before enabling this plugin, review the [requirements](#requirements) to ensure that it will work with the chart you want to create.
6
+
7
+
## Configuration Options
8
+
9
+
The decimation plugin configuration is passed into the `options.plugins.decimation` namespace. The global options for the plugin are defined in `Chart.defaults.plugins.decimation`.
10
+
11
+
| Name | Type | Default | Description
12
+
| ---- | ---- | ------- | -----------
13
+
| `enabled` | `boolean` | `true` | Is decimation enabled?
14
+
| `algorithm` | `string` | `'min-max'` | Decimation algorithm to use. See the [more...](#decimation-algorithms)
15
+
16
+
## Decimation Algorithms
17
+
18
+
Decimation algorithm to use for data. Options are:
19
+
20
+
*`'min-max'`
21
+
22
+
### Min/Max Decimation
23
+
24
+
[Min/max](https://digital.ni.com/public.nsf/allkb/F694FFEEA0ACF282862576020075F784) decimation will preserve peaks in your data but could require up to 4 points for each pixel. This type of decimation would work well for a very noisy signal where you need to see data peaks.
25
+
26
+
## Requirements
27
+
28
+
To use the decimation plugin, the following requirements must be met:
29
+
30
+
1. The dataset must have an `indexAxis` of `'x'`
31
+
2. The dataset must be a line
32
+
3. The X axis for the dataset must be either a `'linear'` or `'time'` type axis
33
+
4. The dataset object must be mutable. The plugin stores the original data as `dataset._data` and then defines a new `data` property on the dataset.
Copy file name to clipboardExpand all lines: docs/docs/general/performance.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ Chart.js is fastest if you provide data with indices that are unique, sorted, an
18
18
19
19
Decimating your data will achieve the best results. When there is a lot of data to display on the graph, it doesn't make sense to show tens of thousands of data points on a graph that is only a few hundred pixels wide.
20
20
21
-
There are many approaches to data decimation and selection of an algorithm will depend on your data and the results you want to achieve. For instance, [min/max](https://digital.ni.com/public.nsf/allkb/F694FFEEA0ACF282862576020075F784) decimation will preserve peaks in your data but could require up to 4 points for each pixel. This type of decimation would work well for a very noisy signal where you need to see data peaks.
21
+
The [decimation plugin](./configuration/decimation.md) can be used with line charts to decimate data before the chart is rendered. This will provide the best performance since it will reduce the memory needed to render the chart.
22
22
23
23
Line charts are able to do [automatic data decimation during draw](#automatic-data-decimation-during-draw), when certain conditions are met. You should still consider decimating data yourself before passing it in for maximum performance since the automatic decimation occurs late in the chart life cycle.
0 commit comments