Open 97702573 opened 10 months ago
图例在右侧展示时,并且图例的字数比较多。当下次数据导入时图例的字数较少,会导致饼图往右偏移。这个能否优化一下呢。不管字数多少都不影响饼图的位置。 代码: import { Pie } from '@antv/g2plot';
const data =[ { "type": "分类一", "value": 10, "colorField": "JASJA难道你" }, { "type": "分类二", "value": 20, "colorField": "ASSJAJSJAJSJASJAJSJ" }, { "type": "分类三", "value": 30, "colorField": "JAJDSJAJD" }, { "type": "分类四", "value": 40, "colorField": "JAJSJA29392" }, { "type": "分类五", "value": 50, "colorField": 500 }, { "type": "分类六", "value": 60, "colorField": 600 }, { "type": "分类七", "value": 70, "colorField": 700 } ];
const piePlot = new Pie('container', { appendPadding: 10, data, angleField: 'value', colorField: 'colorField', radius: 0.9, label: { type: 'inner', offset: '-30%', content: ({ percent }) => ${(percent * 100).toFixed(0)}%, style: { fontSize: 14, textAlign: 'center', }, }, interactions: [{ type: 'element-active' }], });
${(percent * 100).toFixed(0)}%
piePlot.render();
No response
g2plot 暂时不会去维护了,可以使用 G2 试试:https://g2.antv.antgroup.com/examples/general/pie/#pie-base
问题描述
图例在右侧展示时,并且图例的字数比较多。当下次数据导入时图例的字数较少,会导致饼图往右偏移。这个能否优化一下呢。不管字数多少都不影响饼图的位置。 代码: import { Pie } from '@antv/g2plot';
const data =[ { "type": "分类一", "value": 10, "colorField": "JASJA难道你" }, { "type": "分类二", "value": 20, "colorField": "ASSJAJSJAJSJASJAJSJ" }, { "type": "分类三", "value": 30, "colorField": "JAJDSJAJD" }, { "type": "分类四", "value": 40, "colorField": "JAJSJA29392" }, { "type": "分类五", "value": 50, "colorField": 500 }, { "type": "分类六", "value": 60, "colorField": 600 }, { "type": "分类七", "value": 70, "colorField": 700 } ];
const piePlot = new Pie('container', { appendPadding: 10, data, angleField: 'value', colorField: 'colorField', radius: 0.9, label: { type: 'inner', offset: '-30%', content: ({ percent }) =>
${(percent * 100).toFixed(0)}%
, style: { fontSize: 14, textAlign: 'center', }, }, interactions: [{ type: 'element-active' }], });piePlot.render();
重现链接
No response
重现步骤
No response
预期行为
No response
平台
屏幕截图或视频(可选)
No response
补充说明(可选)
No response