IMSL C# Programmer’s Guide
2D Drawing Elements >> Background  Previous Page  Contents  Next Page

Background

Background controls the drawing of the chart’s background. It is created by Chart as its child. It can be retrieved from a Chart object using the Chart.Background property.

The fill area attributes in the Background node determine how the background is drawn (see Fill Area Attributes).

The attribute FillType has the global default value of FILL_TYPE_SOLID. The attribute FillColor attribute is set to Color.White in this node.

Solid Color Background

To set the background to a solid color:

For example the following code sets the background to pink. To view chart in color please see the online documentation.

(Download Code)
using Imsl.Chart2D;
using System.Drawing;

public class SampleBackgroundSolid : FrameChart {

    public SampleBackgroundSolid() {
        Chart chart = this.Chart;
        chart.Background.FillType = ChartNode.FILL_TYPE_SOLID;
        chart.Background.FillColor = Color.Pink;
        AxisXY axis = new AxisXY(chart);
        double[] y = {4, 2, 3, 9};
        new Data(axis, y);
    }

    public static void Main(string[] argv) {
        System.Windows.Forms.Application.Run(new SampleBackgroundSolid());
    }
}

Gradient Color Background

To set the background to a color gradient:

For example the following code uses a yellow-to-red vertical gradient for the background setting. See Fill Area Attributes for more information on gradients.

(Download Code)
using Imsl.Chart2D;
using System.Drawing;

public class SampleBackgroundGradient : FrameChart {

    public SampleBackgroundGradient() {
        Chart chart = this.Chart;
        chart.Background.FillType = ChartNode.FILL_TYPE_GRADIENT;
        chart.Background.SetGradient(Color.Yellow, Color.Yellow,
            Color.Red, Color.Red);
        AxisXY axis = new AxisXY(chart);
        double[] y = {4, 2, 3, 9};
        new Data(axis, y);
    }

    public static void Main(string[] argv) {
        System.Windows.Forms.Application.Run(new SampleBackgroundGradient());
    }
}

Pattern Background

To set the background to a color pattern:

For example the following code sets the background to yellow/orange checkerboard pattern. See Fill Area Attributes for more information on patterns.

(Download Code)
using Imsl.Chart2D;
using System.Drawing;

public class SampleBackgroundPaint : FrameChart {

    public SampleBackgroundPaint() {
        Chart chart = this.Chart;
        chart.Background.FillType = ChartNode.FILL_TYPE_PAINT;
        Brush brush = FillPaint.Checkerboard(24, Color.Yellow, Color.Orange);
        chart.Background.SetFillPaint(brush);
        AxisXY axis = new AxisXY(chart);
        double[] y = {4, 2, 3, 9};
        new Data(axis, y);
    }

    public static void Main(string[] argv) {
        System.Windows.Forms.Application.Run(new SampleBackgroundPaint());
    }
}



©  Visual Numerics, Inc.  All rights reserved.  Previous Page  Contents  Next Page