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] 图例 marker 的使用方式 #4517

Closed
visiky opened this issue Dec 24, 2022 · 0 comments · Fixed by #4607
Closed

[v5] 图例 marker 的使用方式 #4517

visiky opened this issue Dec 24, 2022 · 0 comments · Fixed by #4607
Assignees

Comments

@visiky
Copy link
Member

visiky commented Dec 24, 2022

现状

image

期望

{
   legend: {
     color: {
        itemMarker: 'hyphen',
        itemMarkerStroke: (d) => d.color || '#dfdfdf',
        itemMarkerLineWidth: 2
    }
  }
}

代码

import { Chart } from '@antv/g2';

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

chart
  .line()
  .data({
    type: 'fetch',
    value: 'https://assets.antv.antgroup.com/g2/indices.json',
  })
  .transform({ type: 'normalizeY', basis: 'first', groupBy: 'color' })
  .encode('x', (d) => new Date(d.Date))
  .encode('y', 'Close')
  .encode('color', 'Symbol')
  .scale('y', { type: 'log' })
  .axis('y', { title: '↑ Change in price (%)' })
  .label({
    text: 'Symbol',
    selector: 'last',
    fontSize: 10,
  })
  .legend('color',{
    itemMarker: 'hyphen',
    itemMarkerLineWidth:2,
    itemMarkerStroke: d => d.color || '#dfdfdf'
  })

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

Successfully merging a pull request may close this issue.

3 participants