如何更改图表.NET C#的视角和标签值

时间:2011-02-22 15:09:42

标签: c# 3d angle pie-chart

简短说明

我正在使用特定应用程序的图表,我需要将渲染的3D饼图的视角和饼图标签名称中的自动标签值更改为相应的饼图值。

图表如下所示: Pie Chart


初始化

这是我初始化它的方式:

    Dictionary<string, decimal> secondPersonsWithValues = HistoryModel.getSecondPersonWithValues();
    decimal[] yValues = new decimal[secondPersonsWithValues.Values.Count]; //VALUES
    string[] xValues = new string[secondPersonsWithValues.Keys.Count]; //LABELS
    secondPersonsWithValues.Keys.CopyTo(xValues, 0);
    secondPersonsWithValues.Values.CopyTo(yValues, 0);
    incomeExpenseChart.Series["Default"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Pie;
    incomeExpenseChart.Series["Default"].Points.DataBindXY(xValues, yValues);
    incomeExpenseChart.ChartAreas["Default"].Area3DStyle.Enable3D = true;
    incomeExpenseChart.Series["Default"].CustomProperties = "PieLabelStyle=Outside";
    incomeExpenseChart.Legends["Default"].Enabled = true;
    incomeExpenseChart.ChartAreas["Default"].Area3DStyle.LightStyle = System.Windows.Forms.DataVisualization.Charting.LightStyle.Realistic;
    incomeExpenseChart.Series["Default"]["PieDrawingStyle"] = "SoftEdge";

基本上我使用HistoryModel.getSecondPersonWithValues();从数据库中查询数据,以获得Dictionary<string, decimal>对,其中 key person ammount


问题#1

我需要的是能够将标记的标签从人名更改为 ammounts ,或添加另一个具有相同颜色的ammounts标签(参见图片)。 enter image description here


问题#2

另一个问题是我需要改变3D饼图的视角。也许这很简单,我只是不知道所需的属性或者我可能需要覆盖一些绘制事件。无论哪种方式都会受到影响。

先谢谢乔治。

2 个答案:

答案 0 :(得分:1)

问题#1的解决方案

添加新标签并填充自定义值有帮助。 另外我更改了Series.IsValueShownAsLabel = true;


问题#2的解决方案

我应该设置ChartArea.Area3DStyle.IsClustered = true;,然后设置ChartArea.Area3DStyle.Inclination;

答案 1 :(得分:0)

使用xlhart.Rotationxlchart.Elevation