Open tclxzz08514 opened 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();
使用不同的seriesField,显示两个图例又会不同行,也无法控制图例样式
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();