Spread WPF 17
Spread WPF Documentation / Developer's Guide / Working with Charts / Understanding Charts / Chart Area
In This Topic
    Chart Area
    In This Topic

    The chart area represents the entire chart area. You can set the font, background, foreground, and border for the chart control area. The chart elements use the chart area font unless specifically set.

    The chart uses default values when the fill is set to automatic.

    Element Default Value
    Area Automatic fill
    Chart Area White background
    Plot Area White background
    Axis Inherited from chart
    Legend Inherited from chart
    Data Series Generated automatically
    Data Point Generated automatically
    Data Label White background

    The following image displays custom settings for the chart area.

    Custom Chart Area Example

    Using Code

    The following example sets the chart area border, background, foreground, and fonts.

    1. Add values to the control. 
    2. Create a bar chart with the SpreadChart class. 
    3. Set the appearance properties such as Fill using the SpreadChart class.
    4. Add the chart.
    CS
    Copy Code
    private double strokeThickness;
    private Brush stroke;
    private Brush fillBrush;
    private double chartFontSize;
    private double axisFontSize;
    private FontFamily fontFamily;
    private FontStyle fontStyle;
    private FontWeight fontWeight;
    private FontStretch fontStretch;
    private Brush foreground;
    
    strokeThickness = 2;
    stroke = new SolidColorBrush(Colors.Green);
    fillBrush = new SolidColorBrush(Colors.Red);
    foreground = new SolidColorBrush(Colors.Blue);
    chartFontSize = 25;
    axisFontSize = 25;
    fontFamily = new FontFamily("Arial Narrow");
    fontStyle = FontStyles.Italic;
    fontWeight = FontWeights.Bold;
    fontStretch = FontStretches.ExtraExpanded;
    
    GrapeCity.Windows.SpreadSheet.Data.SpreadChart chart = new GrapeCity.Windows.SpreadSheet.Data.SpreadChart("Chart", GrapeCity.Windows.SpreadSheet.Data.SpreadChartType.BarStacked, "Sheet1!$A$1:$A$7", 0, 0, 200, 200);
    gcSpreadSheet1.ActiveSheet.SetArray(0, 0, new object[,] { { 1 }, { 2 }, { 3 }, { 4 }, { 5 }, { 6 }, { 7 }, { 8 }, { 9 }, { 10 } });
    
    //stroke
    chart.StrokeDashType = GrapeCity.Windows.SpreadSheet.Data.StrokeDashType.LongDashDotDot;
    chart.StrokeThickness = strokeThickness;
    chart.Stroke = stroke;
    ////fill
    chart.Fill = fillBrush;
    chart.FontSize = chartFontSize;
    chart.FontFamily = FontFamily;
    chart.FontStyle = fontStyle;
    chart.FontWeight = fontWeight;
    chart.FontStretch = fontStretch;
    chart.Foreground = foreground;
    
    gcSpreadSheet1.ActiveSheet.Charts.Add(chart);
    
    VB.NET
    Copy Code
    Private strokeThickness As Double
    Private stroke As Brush
    Private fillBrush As Brush
    Private chartFontSize As Double
    Private axisFontSize As Double
    Private fontFamily As FontFamily
    Private fontStyle As FontStyle
    Private fontWeight As FontWeight
    Private fontStretch As FontStretch
    Private foreground As Brush
    
    strokeThickness = 2
    stroke = New SolidColorBrush(Colors.Green)
    fillBrush = New SolidColorBrush(Colors.Red)
    foreground = New SolidColorBrush(Colors.Blue)
    chartFontSize = 25
    axisFontSize = 25
    fontFamily = New FontFamily("Arial Narrow")
    fontStyle = FontStyles.Italic
    fontWeight = FontWeights.Bold
    fontStretch = FontStretches.ExtraExpanded
    
    Dim chart As New GrapeCity.Windows.SpreadSheet.Data.SpreadChart("Chart", GrapeCity.Windows.SpreadSheet.Data.SpreadChartType.BarStacked, "Sheet1!$A$1:$A$7", 0, 0, 200, 200)
    GcSpreadSheet1.ActiveSheet.SetArray(0, 0, New Object(,) {{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}})
    
    'stroke
    chart.StrokeDashType = GrapeCity.Windows.SpreadSheet.Data.StrokeDashType.LongDashDotDot
    chart.StrokeThickness = strokeThickness
    chart.Stroke = stroke
    'fill
    chart.Fill = fillBrush
    chart.FontSize = chartFontSize
    chart.FontFamily = fontFamily
    chart.FontStyle = fontStyle
    chart.FontWeight = fontWeight
    chart.FontStretch = fontStretch
    chart.Foreground = foreground
    
    GcSpreadSheet1.ActiveSheet.Charts.Add(chart)