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 属性后失效 #5085

Closed
YangShuqing opened this issue May 24, 2023 · 8 comments
Closed

V5版本 图例样式 在增加shape 属性后失效 #5085

YangShuqing opened this issue May 24, 2023 · 8 comments

Comments

@YangShuqing
Copy link

YangShuqing commented May 24, 2023

版本:5.0.8
示例

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

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

chart
  .line()
  .data({
    type: 'fetch',
    value: 'https://assets.antv.antgroup.com/g2/temperatures1.json',
  })
  .scale('y', { nice: true })
  .scale('color', {
    domain: ['CLR', 'FEW', 'SCT', 'BKN', 'OVC', 'VV '],
    range: [
      'deepskyblue',
      'lightskyblue',
      'lightblue',
      '#aaaaaa',
      '#666666',
      '#666666',
    ],
  })
  .encode('x', (d) => new Date(d.date))
  .encode('y', 'value')
  //.encode('shape', 'smooth') // 圆角 增加该项后 legend 所有设置 失效
  .legend({
    color: {
      itemMarkerSize: 40,
      // 只有写在这里才生效 issue 5082
      itemLabelFontSize: 30,
      itemLabelFill: 'red',
      style:{
       //style 中的设置未生效
        itemLabelFontSize: 50,
        itemLabelFill: '#fff',
      }
    },
  })
  .encode('color', 'condition')
  .encode('series', () => 'a')
  .style('gradient', 'x')
  .style('lineWidth', 2)
  .axis('x', { title: 'date' });

chart.render();
@YangShuqing
Copy link
Author

@pearmini

@hustcc
Copy link
Member

hustcc commented May 24, 2023

当前 legend 没有根据 shape 来处理样式,line 只有一种 marker 类型。

@YangShuqing
Copy link
Author

当前 legend 没有根据 shape 来处理样式,line 只有一种 marker 类型。

@hustcc 按照我的理解,按照代码中的写法 shape 是控制折线图的样式和legend并没有关系吧,并不应该设置后影响到legend的显示。如果想实现 折线图 圆角过度,且图例的lable 字体为红色 应该怎样写呢?

@hustcc
Copy link
Member

hustcc commented May 24, 2023

不好意思,我刚理解错了,这个 bug 已知了,在修复中了!

@YangShuqing
Copy link
Author

@hustcc @pearmini 这个bug 多久能修复啊?比较着急用两个功能

@pearmini
Copy link
Member

@hustcc @pearmini 这个bug 多久能修复啊?比较着急用两个功能

这两周会修复。

@pearmini
Copy link
Member

目前有个简单的解决办法:

chart.line().encode('shape', 'smooth');

// 改成下面
chart.line().style('shape', 'smooth');

@pearmini
Copy link
Member

这个问题已经修复了。

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

No branches or pull requests

3 participants