antvis/G2

The issue has been closed
折线图和面积图的颜色渐变需要考虑坐标系 #5361
pearmini posted onGitHub
AntV Open Source Contribution Plan(可选)
- 我同意将这个 Issue 参与 OSCP 计划
Issue 类型
中级任务
任务介绍
保证折线图和面积图颜色渐变在 transpose 的情况下正常。下图中颜色从上到下渐变,期望效果是从左到右渐变。
<img src="https://github.com/antvis/G2/assets/49330279/74e00efb-7c92-4ec8-b100-0953796ae70c" height=640 />
/**
* A recreation of this demo: https://observablehq.com/@d3/gradient-encoding
*/
import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
theme: 'classic',
padding: 'auto',
height: 640,
width: 480,
});
chart
.line()
.coordinate({transform:[{type:'transpose'}]})
.data({
type: 'fetch',
value: 'https://assets.antv.antgroup.com/g2/temperatures2.json',
})
.scale('x', { utc: true })
.scale('y', { nice: true })
.scale('color', { palette: 'turbo' })
.encode('x', (d) => new Date(d.date))
.encode('y', 'value')
.encode('shape', 'hvh')
.encode('color', 'value')
.encode('series', () => undefined)
.style('gradient', 'y')
.style('lineWidth', 2)
.style('lineJoin', 'round')
.axis('x', { title: 'date' });
chart.render();