Applies to: Nevron Chart for .NET
How to control the colors that are used for each Pie Chart segment?
Usually there are standard colors recognized for each category (company, country etc.) that are displayed with the Pie Chat slices. You can easily specify the Pie Chart colors in Nevron Chart. Except solid color, for the chart fill style, you can also have Gradient, Image, Hatch or Advanced Gradient fill styles. You can also use Image Filters for the 2D charts.
Take a look at the following Help Documentation topics: http://helpdotnetvision.nevron.com/
Framework > Presentation Layer > Graphics > Appearance Styles > Fill Styles
The following code snippet shows how to create a simple pie chart that has three slices with different color, value and label:
[C#]
using
System;
using
System.Drawing;
using
System.Windows.Forms;
using
Nevron.Chart;
using
Nevron.Chart.WinForm;
using
Nevron.GraphicsCore;
...
nChartControl1.Controller.Tools.Add(
new
NSelectorTool());
nChartControl1.Controller.Tools.Add(
new
NTrackballTool());
nChartControl1.Settings.JitterMode = JitterMode.Auto;
nChartControl1.Settings.JitteringSteps = 8;
nChartControl1.Panels.Clear();
NPieChart chart =
new
NPieChart();
nChartControl1.Panels.Add(chart);
chart.Enable3D =
true
;
chart.Width = 70;
chart.Depth = 10;
chart.Height = 100;
chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated);
chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyCameraLight);
NPieSeries pie =
new
NPieSeries();
chart.Series.Add(pie);
pie.PieStyle = PieStyle.SmoothEdgePie;
pie.PieEdgePercent = 5;
pie.Values.Add(30);
pie.FillStyles[0] =
new
NColorFillStyle(Color.FromArgb(255, 0, 0));
// red defined as rgb
pie.Labels.Add(
"Company X"
);
pie.Values.Add(30);
pie.FillStyles[1] =
new
NColorFillStyle(Color.Green);
pie.Labels.Add(
"Company Y"
);
pie.Values.Add(40);
pie.FillStyles[2] =
new
NColorFillStyle(Color.Blue);
pie.Labels.Add(
"Company Z"
);
pie.Values.Add(27);
pie.FillStyles[3] =
new
NColorFillStyle(Color.Yellow);
pie.Labels.Add(
"Company XYZ"
);
pie.DataLabelStyle.Format =
"<label>\n<percent>"
;
pie.LabelMode = PieLabelMode.Rim;
[VB.NET]
Imports
System
Imports
System.Drawing
Imports
System.Windows.Forms
Imports
Nevron.Chart
Imports
Nevron.Chart.WinForm
Imports
Nevron.GraphicsCore
...
NChartControl1.Controller.Tools.Add(
New
NSelectorTool())
NChartControl1.Controller.Tools.Add(
New
NTrackballTool())
NChartControl1.Settings.JitterMode = JitterMode.
Auto
NChartControl1.Settings.JitteringSteps = 8
NChartControl1.Panels.Clear()
Dim
chart
As
New
NPieChart()
NChartControl1.Panels.Add(chart)
chart.Enable3D =
True
chart.Width = 70
chart.Depth = 10
chart.Height = 100
chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated)
chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyCameraLight)
Dim
pie
As
New
NPieSeries()
chart.Series.Add(pie)
pie.PieStyle = PieStyle.SmoothEdgePie
pie.PieEdgePercent = 5
pie.Values.Add(30)
pie.FillStyles(0) =
New
NColorFillStyle(Color.FromArgb(255, 0, 0))
' red defined as rgb
pie.Labels.Add(
"Company X"
)
pie.Values.Add(30)
pie.FillStyles(1) =
New
NColorFillStyle(Color.Green)
pie.Labels.Add(
"Company Y"
)
pie.Values.Add(40)
pie.FillStyles(2) =
New
NColorFillStyle(Color.Blue)
pie.Labels.Add(
"Company Z"
)
pie.Values.Add(27)
pie.FillStyles(3) =
New
NColorFillStyle(Color.Yellow)
pie.Labels.Add(
"Company XYZ"
)
pie.DataLabelStyle.Format =
"<label>"
& vbLf &
"<percent>"
pie.LabelMode = PieLabelMode.Rim
Article ID: 220, Created On: 5/16/2012, Modified: 1/28/2013