antvis/G2

The issue has been closed
[v5] 期望可以通过设置 zIndex 来调整 mark 的顺序 #4571
visiky posted onGitHub
描述
<img width="701" alt="image" src="https://user-images.githubusercontent.com/15646325/211768921-994b7fe7-0269-4f85-9f0b-34b22d585552.png">
如图所示,期望结果是标注线可以在折线下层,使用方式通过 style('zIndex', -1)
或者 attr('zIndex', -1)
都可以接受
import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
autoFit: true,
});
chart
.line()
.data({
type: 'fetch',
value:
'https://gw.alipayobjects.com/os/bmw-prod/551d80c6-a6be-4f3c-a82a-abd739e12977.csv',
})
.encode('x', 'date')
.encode('y', 'close');
chart.lineY()
.data([400])
.style('lineWidth', 4)
.style('strokeOpacity', 1)
.style('stroke', 'red')
// 通过设置 style.zIndex 或者 直接设置 zIndex 属性都可以接受
.style('zIndex', -1)
.attr('zIndex', -1)
chart.render();