饼图显示成员 [英] Pie Chart Display member

查看:74
本文介绍了饼图显示成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Visual Studio 2010 中使用饼图,但我不知道如何设置显示值(每个切片上显示的值).我需要使用与 X 和 Y 值不同的值成员.

I'm using a pie chart in visual studio 2010 but I don't know how to set the values on display (the values that showed on each slice). I need to use a different value member that the X and Y values.

推荐答案

饼图中,您只需要使用Y-Values.

因此,如果您有一个 DataSource data 和一个名为 "value" 的 Y 值,您可以使用它来绑定:

So if you have a DataSource data with a Y-Value called "value" you can use this to bind:

 yourSeries.Points.DataBindY(data,  "value");

您也可以使用这种更通用的绑定方法:

You can also use this, more general binding method:

 yourSeries.Points.DataBind(data, "", "value", "");

注意第一个,即 X-Value 是如何留空的;无论如何,所有点总是被添加索引.最后一个字符串 otherfields 用于扩展属性.

Note how the first, i.e. the X-Value is left empty; all points are always added indexed anyway. The last string otherfields would be for extended properties.

还有另外一种方法来绑定 SeriesPoints :

And there is even another way to bind the Points of a Series:

 yourSeries.Points.DataBindXY(data, "somePropery", data, "value");

请注意,此处您可以使用两种不同的数据源.但是您不能将第一个的名称字符串留空,即使实际值将像任何饼图一样被再次忽略..

Note that here you can use two different data sources. But you can't leave the name string of the first one empty, even though the actual values will be ignored againm as with any Pie chart..

除了绑定Points,您还可以使用其他绑定方法,请参阅此处进行讨论 或利弊..!

Besides binding the the Points you could also use other binding methods, see here for a discussion or the pros and cons..!

还要注意第一个 DataPoint,即第一个切片从 0° 开始.如果你想从顶部开始设置 '自定义属性':PieStartAngle :

Also note that the first DataPoint, i.e. the first slice starts at 0°. If you want to start it at the top set a 'Custom attribute' : PieStartAngle :

yourSeries["PieStartAngle"] = "270";

要显示您可以设置的值:

To display the values you can set this:

yourSeries.IsValueShownAsLabel = true;

要将标签从切片上移开,请使用:

To move the labels off the slices use this:

yourSeries["PieLabelStyle"] = "Outside";

这篇关于饼图显示成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆