[英]ReCharts - not able to see label when right aligned for stacked bar chart
I am creating an example of StackBarChart
using Recharts
library but I am not able to see the label when it's position is set to "right"
though I am able to show the other label positions. 我正在使用
Recharts
库创建StackBarChart
的示例,但是当它的位置设置为"right"
虽然我能够显示其他标签的位置,但我看不到标签。
<BarChart width={400} height={300} data={data} layout="vertical">
...
<Bar dataKey="pv" stackId="a" barSize={15} radius={[20,20,20,20]} fill="#8884d8" background={{fill: "#ddd", radius: [20,20,20,20]}} tick={false} />
<Bar dataKey="uv" stackId="a" barSize={15} radius={[20,20,20,20]} fill="#aaa" >
<LabelList dataKey="name" position="right" />
{/* works fine <LabelList dataKey="name" position="top" /> */}
</Bar>
</BarChart>
I have updated your fiddle script here . 我在这里更新了你的小提琴脚本。
You have to provide a correct dataKey
field to LabelList
, and put LabelList
as a child of Bar
component 你必须提供正确的
dataKey
场LabelList
,并把LabelList
作为一个孩子Bar
成分
UPDATED: 更新:
New jsfiddle , you need margin
in your case. 新的jsfiddle ,您需要
margin
。 So that the SVG reserved some spaces aside of the chart for additional text. 因此,SVG在图表旁边保留了一些空格以用于其他文本。 NOTE that it is the
margin
props of the chart, not the margin
from CSS style. 请注意,它是图表的
margin
道具 ,而不是CSS样式的margin
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.