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】shape 通道指定后,legend 位置设置失效 #5015

Closed
Deathsteps opened this issue May 12, 2023 · 4 comments
Closed

【v5】shape 通道指定后,legend 位置设置失效 #5015

Deathsteps opened this issue May 12, 2023 · 4 comments
Assignees
Labels

Comments

@Deathsteps
Copy link
Contributor

问题描述

image image

期望结果

shape encode 不影响图例位置设置

如何重现

官方示例修改

/**
 * A recreation of this demo: https://observablehq.com/@d3/stacked-bar-chart
 */
import { Chart } from '@antv/g2';

const chart = new Chart({
  container: 'container',
  theme: 'classic',
  autoFit: true,
});

chart
  .interval()
  .data({
    type: 'fetch',
    value:
      'https://gw.alipayobjects.com/os/bmw-prod/f129b517-158d-41a9-83a3-3294d639b39e.csv',
    format: 'csv',
  })
  .transform({ type: 'stackY' })
  .transform({ type: 'sortX', by: 'y', reverse: true })
  .encode('x', 'state')
  .encode('y', 'population')
  .encode('color', 'age')
  .axis('x', {
    labelSpacing: 4,
    style: {
      labelTransform: 'rotate(90)',
    },
  })
  .encode('shape', 'hollow')
  .legend('color', {
    position: 'bottom',
  })
  .axis('y', { labelFormatter: '~s' });

chart.render();

额外信息

G2 5.0.4

@pearmini pearmini added the V5 label May 12, 2023
@pearmini pearmini self-assigned this May 12, 2023
@pearmini pearmini added the Bug label May 12, 2023
@pearmini
Copy link
Member

这确实是一个问题,应该是现在的 legend 是和 color 和 shape 同时绑定了,所以导致配置失效。

@hustcc
Copy link
Member

hustcc commented May 16, 2023

看了代码,当前获取 legend 数据的方式,基本无解,一定会触发 bug。

@Deathsteps
Copy link
Contributor Author

喵喵叹气

@pearmini
Copy link
Member

pearmini commented Jun 2, 2023

喵喵叹气

暂时可以这样解决:

// 用 mark.style 代替 mark.shape
chart.interval().style('shape', 'hollow');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants