Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v5] 期望可以通过设置 zIndex 来调整 mark 的顺序 #4571

Closed
visiky opened this issue Jan 11, 2023 · 1 comment
Closed

[v5] 期望可以通过设置 zIndex 来调整 mark 的顺序 #4571

visiky opened this issue Jan 11, 2023 · 1 comment
Assignees
Labels
Milestone

Comments

@visiky
Copy link
Member

visiky commented Jan 11, 2023

描述

image

如图所示,期望结果是标注线可以在折线下层,使用方式通过 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();
@pearmini
Copy link
Member

pearmini commented Jan 12, 2023

@Aarebecca

这里 zIndex 直接设置在 mark 上,而不是 mark.style。因为 mark.style 其实设置的是每个 G 元素的样式,但是这里是需要设置 mark 容器 G 的样式 zIndex。

// Spec 描述如下
const options = {
  children: [
    { type: 'line' },
    { type: 'lineX', zIndex: -1 }
  ]
}
// API 描述如下
chart.line();
chart.lineX().attr('zIndex', -1);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

No branches or pull requests

3 participants