We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
import { Chart } from '@antv/g2';
const chart = new Chart({ container: 'container', height: 350 }); const shapeList = ['bowtie', 'smooth', 'hv', 'rect', 'hollowPoint']; const data = [ { genre: 'Sports', sold: 50 }, { genre: 'Strategy', sold: 115 }, { genre: 'Action', sold: 120 }, { genre: 'Shooter', sold: 350 }, { genre: 'Other', sold: 150 }, { genre: 'Sp34orts', sold: 50 }, { genre: 'Stra2tegy', sold: 115 }, { genre: 'Action', sold: 120 }, { genre: 'Shoo5ter', sold: 350 }, { genre: 'Othe4r', sold: 150 }, { genre: 'Sports', sold: 50 }, { genre: 'Strat22egy', sold: 115 }, { genre: 'Acti2on', sold: 120 }, { genre: 'Sho23oter', sold: 350 }, { genre: 'Oth3er', sold: 150 }, { genre: 'S35ports', sold: 50 }, { genre: 'Strat44egy', sold: 115 }, { genre: 'Action', sold: 120 }, { genre: 'Shooter', sold: 350 }, { genre: 'Othe5r', sold: 150 }, { genre: 'S8ports', sold: 50 }, { genre: 'Str7ategy', sold: 115 }, { genre: 'Act7ion', sold: 120 }, { genre: 'Shoo2ter', sold: 350 }, { genre: 'Oth4er', sold: 150 },
]; chart.options({ type: 'interval', data, encode: { x: 'genre', y: 'sold', color: 'genre' }, legend: { color: { size: 100, itemWidth: 120, position:'left', // itemMarker itemMarker: (d, index) => shapeList[index], // itemLabel itemLabelFill: 'red', // itemValue itemValueText: (d, index) => data[index]['sold'], // itemBackground itemBackgroundFill: (d) => d.color, itemBackgroundFillOpacity: 0.2, }, }, });
chart.render();
No response
Please select / 请选择
The text was updated successfully, but these errors were encountered:
未配置size的时候会自动计算size的大小,当指定size后,需要自己指定布局,这里就需要增加marginLeft外边距,这部分我后面加到legend size的文档里
size
marginLeft
Sorry, something went wrong.
No branches or pull requests
Describe the bug / 问题描述
import { Chart } from '@antv/g2';
const chart = new Chart({ container: 'container', height: 350 });
const shapeList = ['bowtie', 'smooth', 'hv', 'rect', 'hollowPoint'];
const data = [
{ genre: 'Sports', sold: 50 },
{ genre: 'Strategy', sold: 115 },
{ genre: 'Action', sold: 120 },
{ genre: 'Shooter', sold: 350 },
{ genre: 'Other', sold: 150 },
{ genre: 'Sp34orts', sold: 50 },
{ genre: 'Stra2tegy', sold: 115 },
{ genre: 'Action', sold: 120 },
{ genre: 'Shoo5ter', sold: 350 },
{ genre: 'Othe4r', sold: 150 },
{ genre: 'Sports', sold: 50 },
{ genre: 'Strat22egy', sold: 115 },
{ genre: 'Acti2on', sold: 120 },
{ genre: 'Sho23oter', sold: 350 },
{ genre: 'Oth3er', sold: 150 },
{ genre: 'S35ports', sold: 50 },
{ genre: 'Strat44egy', sold: 115 },
{ genre: 'Action', sold: 120 },
{ genre: 'Shooter', sold: 350 },
{ genre: 'Othe5r', sold: 150 },
{ genre: 'S8ports', sold: 50 },
{ genre: 'Str7ategy', sold: 115 },
{ genre: 'Act7ion', sold: 120 },
{ genre: 'Shoo2ter', sold: 350 },
{ genre: 'Oth4er', sold: 150 },
];
chart.options({
type: 'interval',
data,
encode: { x: 'genre', y: 'sold', color: 'genre' },
legend: {
color: {
size: 100,
itemWidth: 120,
position:'left',
// itemMarker
itemMarker: (d, index) => shapeList[index],
// itemLabel
itemLabelFill: 'red',
// itemValue
itemValueText: (d, index) => data[index]['sold'],
// itemBackground
itemBackgroundFill: (d) => d.color,
itemBackgroundFillOpacity: 0.2,
},
},
});
chart.render();
Reproduction link / 复现链接
No response
Steps to Reproduce the Bug or Issue / 重现步骤
Version / 版本
Please select / 请选择
OS / 操作系统
Browser / 浏览器
The text was updated successfully, but these errors were encountered: