Applies to: Nevron Chart for .NET
How to assign a semi-transparent color to Nevron Chart element?
There are two ways to set transparency of the NFillStyle element.
Lets create a simple bar chart:
[C#]
nChartControl.Legends.Clear();
NChart chart = nChartControl.Charts[0];
chart.Wall(ChartWallType.Back).FillStyle =
new
NGradientFillStyle(GradientStyle.DiagonalDown, GradientVariant.Variant3, Color.Aqua, Color.Blue);
NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);
bar.DataLabelStyle.Visible =
false
;
bar.Values.Add(4);
bar.Values.Add(8);
bar.Values.Add(2);
bar.Values.Add(10);
bar.Values.Add(7);
bar.Values.Add(1);
[VB.NET]
nChartControl.Legends.Clear()
Dim
chart
As
NChart = nChartControl.Charts(0)
chart.Wall(ChartWallType.Back).FillStyle =
New
NGradientFillStyle(GradientStyle.DiagonalDown, GradientVariant.Variant3, Color.Aqua, Color.Blue)
Dim
bar
As
NBarSeries =
DirectCast
(chart.Series.Add(SeriesType.Bar), NBarSeries)
bar.DataLabelStyle.Visible =
False
bar.Values.Add(4)
bar.Values.Add(8)
bar.Values.Add(2)
bar.Values.Add(10)
bar.Values.Add(7)
bar.Values.Add(1)
The first way is to create a NColorFillStyle object, and call the SetTransparencyPercent method with float value of the transparency percent as a parameter:
[C#]
NColorFillStyle colorStyle =
new
NColorFillStyle(Color.Red);
colorStyle.SetTransparencyPercent(50);
area.FillStyle = colorStyle;
[VB.NET]
Dim
colorStyle
As
New
NColorFillStyle(Color.Red)
colorStyle.SetTransparencyPercent(50)
area.FillStyle = colorStyle
The second way is when create the NcolorFillStyle object to use the constructor with NArgbColor object parameter:
[C#]
NColorFillStyle colorStyle =
new
NColorFillStyle(
new
NArgbColor(75, 200, 85, 140));
area.FillStyle = colorStyle;
[VB.NET]
Dim
colorStyle
As
New
NColorFillStyle(
New
NArgbColor(75, 200, 85, 140))
area.FillStyle = colorStyle
Note: The first parameter of the NArgbColor constructor is the transparency level. 0 is 100% transparency and 255 is 100% opacity.
Article ID: 66, Created On: 10/6/2010, Modified: 12/1/2010