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:

•      set the attribute FillType to FILL_TYPE_SOLID, and

•      set the attribute FillColor to the desired 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:

•      set the attribute FillType to FILL_TYPE_GRADIENT, and

•      set the attribute Gradient to the desired color gradient specification.

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:

•      set the attribute FillType to FILL_TYPE_PAINT, and

•      set the attribute FillPaint to the desired pattern.

For example the following code sets the background to yellow/orange checker­board 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 - Developers of IMSL and PV-WAVE
http://www.vni.com/
PHONE: 713.784.3131
FAX:713.781.9260