Replies: 7 comments 4 replies
-
我顺便补充一个点,line + point 这种组合图,我看某图表库对于 point 的抽样展示处理(因为 point 只是辅助),是会根据像素距离情况来定,这种情况我们会怎么处理? |
Beta Was this translation helpful? Give feedback.
-
有两点需要提一下:
|
Beta Was this translation helpful? Give feedback.
-
还有一个点就是 G2 里面可能还有一些其他和 |
Beta Was this translation helpful? Give feedback.
-
最新更新:
|
Beta Was this translation helpful? Give feedback.
-
sampling -> sample |
Beta Was this translation helpful? Give feedback.
-
{
type: 'sample',
y: 'min',
opacity: 'mean'
} 但是抽样,需要的是保留原始数据中 x y 等通道的对应关系。而当前实现比如对 y 进行 max 后,x 实际是取的那一组数据的第一个,组合出来的数据,实际上并不存在。见问题:#4505 而一旦设置两个以上通道的 reducer,大概率是无法保持数据一致的。
|
Beta Was this translation helpful? Give feedback.
-
const options = {
type: 'view',
children: [
{
type: 'line',
data,
encode: { x: 'date', y: 'value' },
transform: [{ type: 'sample' }],
},
{
type: 'point',
data,
encode: { x: 'date', y: 'value' },
transform: [{ type: 'sample' }],
},
],
}; 但是之后 G2 会支持在 view 处理数据,vega-lite 也有同样的设计,之后的声明会如下。 const options = {
type: 'view',
data,
encode: { x: 'date', y: 'value' },
transform: [{ type: 'sample' }],
children: [{ type: 'line' }, { type: 'point' }],
}; 注意这里不是语法糖!而是数据会在 view 层面处理,然后传递给 mark,实际的列处理还是执行了1次。
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
transform.sample
针对线、柱、条、散点类图表,当数据量远大于屏幕像素的时候,开启一些内置的采样策略,可以有效的优化图表的绘制效率,默认关闭,也就是按照原始数据全部渲染。
开始
这是使用
sample
的示例选项
string
|string[]
number
2000
Strategy
strategy
内置有 6 种策略,分别为:lttb
- 采用 Largest-Triangle-Three-Bucket 算法,可以最大程度保证采样后线条的趋势,形状和极值。mean
- 取过滤点的平均值median
- 取过滤点的中位数max
- 取过滤点的最大值min
- 取过滤点的最小值sum
- 取过滤点的和(I: number[], V: number[]) => number
- 使用自定义的函数进行采样FAQ
Beta Was this translation helpful? Give feedback.
All reactions