antvis / G2Plot

:dango: An interactive and responsive charting library based on G2.
https://g2plot.antv.antgroup.com
MIT License
2.55k stars 605 forks source link

🐛 [BUG] 混合图,柱状折线组合图表,只显示一个图例 #3784

Open tclxzz08514 opened 4 months ago

tclxzz08514 commented 4 months ago

import { Mix } from '@antv/g2plot';

const data = [ { year: '1991', value: 3, category: '销量' }, { year: '1992', value: 4, category: '销量' }, { year: '1991', value: 2, category: '利润' }, { year: '1992', value: 3, category: '利润' }, ];

const mixPlot = new Mix('container', { appendPadding: 8, data, plots: [ { type: 'column', options: { data: data.filter((d) => d.category === '销量'), xField: 'year', yField: 'value', seriesField: 'category', }, }, { type: 'line', options: { data: data.filter((d) => d.category === '利润'), xField: 'year', yField: 'value', seriesField: 'category', }, }, ], legend: {} });

mixPlot.render();

tclxzz08514 commented 4 months ago

使用不同的seriesField,显示两个图例又会不同行,也无法控制图例样式