如何避免饼图中的标签重叠?
How do you avoid labels overlapping in a Pie chart?
我想避免在我绘制的饼图中出现文本标签重叠的情况:
有'recognised'方法吗?即特定的文本放置算法?
如果没有,那么如何有效地做到这一点?
编辑:因此它看起来类似于这种类型的标签放置:
Overlapping Labels in Pie-Chart
更新:
我有一个更好的系统来组织标签,它只列出相关侧的标签,然后将每个标签的行添加到适当的段。
你可以在这里看到一个例子:
https://www.rgraph.net/demos/pie-basic.html
创建该图表的代码是:
<script src="RGraph.common.core.js"></script>
<script src="RGraph.pie.js"></script>
<canvas id="cvs" width="350" height="250">
[No canvas support]
</canvas>
<script>
// A basic configuration for a Pie chart with just the labels
// separated out into their own array. This is because the same
// array is used for both the labels and the tooltips so
// doing this makes for less upkeep when the time comes to
// change things around.
//
// Also note that the stroke color has been set to transparent so
// that there's no separation between the segments
//
labels = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
new RGraph.Pie({
id: 'cvs',
data: [20,1,1,1,1,1,1],
options: {
// This is the tooltip property using formatted tooltips
tooltips: '%{property:myDaynames[%{index}]}<br /><span style="font-weight: bold; font-size:26pt">%{value_formatted}</span>',
// The units that are appended to the %{value_formatted} value
tooltipsFormattedUnitsPost: '%',
// Some CSS values that are set on the tooltips so that you can customise them
tooltipsCss: {
backgroundColor: 'white',
border: '3px solid black'
},
// A custom property - the formatted tooltips can then
// access this to use the data inside the tooltip
myDaynames: labels,
shadow: false,
colorsStroke: 'transparent',
keyPositionGraphBoxed: false,
}
// Draw the chart
}).draw();
</script>
我想避免在我绘制的饼图中出现文本标签重叠的情况:
有'recognised'方法吗?即特定的文本放置算法?
如果没有,那么如何有效地做到这一点?
编辑:因此它看起来类似于这种类型的标签放置:
Overlapping Labels in Pie-Chart
更新:
我有一个更好的系统来组织标签,它只列出相关侧的标签,然后将每个标签的行添加到适当的段。
你可以在这里看到一个例子:
https://www.rgraph.net/demos/pie-basic.html
创建该图表的代码是:
<script src="RGraph.common.core.js"></script>
<script src="RGraph.pie.js"></script>
<canvas id="cvs" width="350" height="250">
[No canvas support]
</canvas>
<script>
// A basic configuration for a Pie chart with just the labels
// separated out into their own array. This is because the same
// array is used for both the labels and the tooltips so
// doing this makes for less upkeep when the time comes to
// change things around.
//
// Also note that the stroke color has been set to transparent so
// that there's no separation between the segments
//
labels = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
new RGraph.Pie({
id: 'cvs',
data: [20,1,1,1,1,1,1],
options: {
// This is the tooltip property using formatted tooltips
tooltips: '%{property:myDaynames[%{index}]}<br /><span style="font-weight: bold; font-size:26pt">%{value_formatted}</span>',
// The units that are appended to the %{value_formatted} value
tooltipsFormattedUnitsPost: '%',
// Some CSS values that are set on the tooltips so that you can customise them
tooltipsCss: {
backgroundColor: 'white',
border: '3px solid black'
},
// A custom property - the formatted tooltips can then
// access this to use the data inside the tooltip
myDaynames: labels,
shadow: false,
colorsStroke: 'transparent',
keyPositionGraphBoxed: false,
}
// Draw the chart
}).draw();
</script>