Customizing Chart Elements / Custom Brushes for Plotting Data / Creating a Hatched Brush
In This Topic
Creating a Hatched Brush
In This Topic

The following sample code represents the handler that creates hatched 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.

To write code in Visual Basic

Visual Basic
Copy Code
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 foreclr As Color = ds.SymbolStyle.Color
    Dim backclr As Color = ds.LineStyle.Color   
    Dim hb As System.Drawing.Drawing2D.HatchBrush
    hb = New HatchBrush(HatchStyle.OutlinedDiamond, foreclr, backclr)
    e.Brush = hb 
End Sub

To write code in C#

C#
Copy Code
 
private void c1Chart1_DrawDataSeries(object sender,    C1.Win.C1Chart.DrawDataSeriesEventArgs e)      
{      
  C1.Win.C1Chart.ChartDataSeries ds = (ChartDataSeries)sender;
  Color forecolor = ds.SymbolStyle.Color;  
  Color backcolor = ds.LineStyle.Color;    
  System.Drawing.Drawing2D.HatchBrush hb;   
  hb = new HatchBrush(HatchStyle.OutlinedDiamond, forecolor, backcolor);  
  e.Brush = hb;   
}

The following image displays the hatch brush bar chart:

See Also