The following sample code represents the handler that creates linear gradient brush.
Please note that the given code snippet shows the initial declarations of some objects using their full namespace. In subsequent use of those and related objects, the namespace is omitted for brevity.
Private Sub C1Chart1_DrawDataSeries(ByVal sender As Object, _
ByVal e As C1.Win.C1Chart.DrawDataSeriesEventArgs) _
Handles C1Chart1.DrawDataSeries
Dim ds As C1.Win.C1Chart.ChartDataSeries = sender
Dim clr1 As Color = ds.LineStyle.Color
Dim clr2 As Color = ds.SymbolStyle.Color
If(e.Bounds.Height > 0 And e.Bounds.Width > 0) Then
Dim lgb As System.Drawing.Drawing2D.LinearGradientBrush = _
New LinearGradientBrush(e.Bounds, clr1, clr2, LinearGradientMode.Horizontal)
e.Brush = lgb
End If
End Sub
•C#
private void c1Chart1_DrawDataSeries(object sender,
C1.Win.C1Chart.DrawDataSeriesEventArgs e)
{
C1.Win.C1Chart.ChartDataSeries ds = (ChartDataSeries)sender;
Color clr1 = ds.LineStyle.Color;
Color clr2 = ds.SymbolStyle.Color;
if(e.Bounds.Size.Height > 0 && e.Bounds.Size.Width > 0)
{
System.Drawing.Drawing2D.LinearGradientBrush lgb =
new LinearGradientBrush(e.Bounds, clr1, clr2, LinearGradientMode.Horizontal);
e.Brush = lgb;
}
}
The following image shows the linear gradient brush: