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:
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.
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).
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 ways would be appriciated.
Thanks in advance George.
To format data labels, select your chart, and then in the Chart Design tab, click Add Chart Element > Data Labels > More Data Label Options. Click Label Options and under Label Contains, pick the options you want.
Add data labelsClick the chart, and then click the Chart Design tab. Click Add Chart Element and select Data Labels, and then select a location for the data label option. Note: The options will differ depending on your chart type.
On the Layout tab, in the Labels group, click Data Labels, and then click the option that you want. For additional data label options, click More Data Label Options, click Label Options if it's not selected, and then select the options that you want.
Adding new Label and filling with custom values helped.
In addition i changed the Series.IsValueShownAsLabel = true;
I should have set the ChartArea.Area3DStyle.IsClustered = true;
and then set the ChartArea.Area3DStyle.Inclination;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With