# 数据抽取
抽取插件可与折线图一起使用,以在图表生命周期开始时自动抽取数据。 在启用此插件之前,请查看 requirements 以确保它适用于你要创建的图表。
英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 to ensure that it will work with the chart you want to create.
# 配置选项
命名空间: options.plugins.decimation
,插件的全局选项在 Chart.defaults.plugins.decimation
中定义。
英Namespace: options.plugins.decimation
, the global options for the plugin are defined in Chart.defaults.plugins.decimation
.
名称 | 类型 | 默认 | 描述 |
---|---|---|---|
enabled | boolean | false | 是否启用抽取? |
algorithm | string | 'min-max' | 要使用的抽取算法。 见 more... |
samples | number | 如果使用 'lttb' 算法,则这是输出数据集中的样本数。 默认为画布宽度,每个像素选取 1 个样本。 | |
threshold | number | 如果当前坐标轴范围内的样本数量高于此值,将触发抽取。 默认为画布宽度的 4 倍。 抽取后的点数可以高于 threshold 值。 |
# 抽取算法
用于数据的抽取算法。 选项是:
英Decimation algorithm to use for data. Options are:
'lttb'
'min-max'
# 最大三角三桶 (LTTB) 抽取
LTTB (opens new window) 抽取显着减少了数据点的数量。 这对于仅使用少数数据点显示数据趋势最为有用。
英LTTB (opens new window) decimation reduces the number of data points significantly. This is most useful for showing trends in data using only a few data points.
# 最小/最大抽取
Min/max (opens new window) 抽取将保留数据中的峰值,但每个像素最多可能需要 4 个点。 这种类型的抽取适用于需要查看数据峰值的非常嘈杂的信号。
英Min/max (opens new window) 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.
# 要求
要使用抽取插件,必须满足以下要求:
英To use the decimation plugin, the following requirements must be met:
- 数据集必须具有
'x'
的indexAxis
- 数据集必须是一条线
- 数据集的 X 轴必须是
'linear'
或'time'
类型的轴 - 数据必须不需要解析,即
parsing
必须是false
- 数据集对象必须是可变的。 该插件将原始数据存储为
dataset._data
,然后在数据集上定义一个新的data
属性。 - 图表上的点数必须多于阈值。 查看配置选项以获取更多信息。