开发者

How to change the view angle and label value of a chart .NET C#

Short Description

I am using charts for a specific application where i need to change the view angle of the rendered 3D Pie chart and value of automatic labels from pie label names to corresponding pie values.

This how the chart looks:

How to change the view angle and label value of a chart .NET C#


Initialization

This is how i initialize it:

    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";

Basically i am querying data from database using the HistoryModel.getSecondPersonWithValues(); to get pairs as Dictionary<string, decimal> where key is the person and value is ammount.


Problem #1

What i need is to be able to change the marked labels from person names to the ammounts or add another label of ammounts with the same colors (See Image).

How to change the view angle and label value of a chart .NET C#


Problem #2

Another problem is that i need to change the view angle of 3D Pie chart. Maybe it's very simple and I just don't know the needed property or maybe i need to override some paint event. Either ways any kind of开发者_StackOverflow社区 ways would be appriciated.

Thanks in advance George.


Solution for Problem #1

Adding new Label and filling with custom values helped. In addition i changed the Series.IsValueShownAsLabel = true;


Solution for Problem #2

I should have set the ChartArea.Area3DStyle.IsClustered = true; and then set the ChartArea.Area3DStyle.Inclination;


Use xlhart.Rotation and xlchart.Elevation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜