在 WPF 中的饼图上显示百分比

发布于 2024-09-05 16:22:12 字数 82 浏览 2 评论 0原文

Hii

谁能告诉我如何在饼图上显示百分比...... 在鼠标悬停事件上可以看到百分比,但我不知道如何显示 饼图切片的百分比......

Hii

Can anyone tell me how can I show percentage on the piechart....
The percentage is seen on mouseover event but I dont know how to show
the percentage on the piechart's slices....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

暮年 2024-09-12 16:22:12

如果您想在图表本身上添加标签(而不是工具提示),请查看 WPF 大师 Bea Stollnitz 撰写的这篇精彩博客文章

它展示了如何以多种不同的模式做到这一点,并不仅解释了如何做到这一点,还解释了原因。

If you are looking to put labels on the chart itself (instead of tooltip), take a look at this great blog post by WPF guru Bea Stollnitz.

It shows how to do this, in many different modes, and explains not only how, but why.

一个人的旅程 2024-09-12 16:22:12

查看WPF 的 amCharts 捆绑包。饼图支持切片上的标签、外部连接的标签,并包含防止标签重叠的算法。

Take a look at amCharts Bundle for WPF. Pie chart supports labels on the slices, outside connected labels and includes an algorithm to prevent label overlapping.

相思故 2024-09-12 16:22:12

我刚刚遵循了本教程(只是为了确保),默认情况下,我会在鼠标悬停时将每个切片的百分比作为工具提示。

如果您发布代码,我们也许能够发现它是否有问题。

I've just followed this tutorial (just to make sure) and I get the percentages of each slice as tooltip on mouse over by default.

If you post your code we might be able to spot if there's a problem with it.

空心空情空意 2024-09-12 16:22:12

您可以在 mx:PieSeries 中使用 labelFunction,并且 lableFunction 看起来像这样,

private function pieSeries_labelFunc(item:Object, field:String, index:Number, percentValue:Number):String 
{
    return StringUtil.substitute("{0} ({1}%)",item.description,percentValue.toFixed(1));
}

其中描述是您想要查看的标签。
如有任何问题,请随时提出。

You can use labelFunction in mx:PieSeries, and lableFunction look like that

private function pieSeries_labelFunc(item:Object, field:String, index:Number, percentValue:Number):String 
{
    return StringUtil.substitute("{0} ({1}%)",item.description,percentValue.toFixed(1));
}

Where description is the label that you want to see.
feel free to ask any question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文