IMSL C# Programmers Guide
|
2D Drawing Elements >> Background |
Background
Background
controls the drawing of the charts 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:
FillType
to FILL_TYPE_SOLID
, and
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.
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:
FillType
to FILL_TYPE_GRADIENT
, and
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.
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:
FillType
to FILL_TYPE_PAINT
, and
FillPaint
to the desired pattern.
For example the following code sets the background to yellow/orange checkerboard pattern. See Fill Area Attributes for more information on patterns.
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. |