HOWTO: Change Colors to Patterns with the MSChart Control
ID: Q192902
|
The information in this article applies to:
-
Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, versions 5.0, 6.0
on the following platforms: NT, Win95, Win98
SUMMARY
By default, the MSChart control uses colors to differentiate between data
sets. This works well on a color monitor or printer, but if a printout to a
monochrome printer is created, the colors may be hard to distinguish. Using
the code provided, you can programmatically change the MSChart control to
use patterns instead of colors.
MORE INFORMATION
Modifying some properties is all that needs to be done to get the MSChart
control to use patterns.
Step-by-Step Example
- Create a new Standard EXE project in Visual Basic. Form1 is created by
default.
- Choose Components from the Project menu to show the Components Dialog.
- In Visual Basic 5.0, select "Microsoft Chart Control." In Visual Basic
6.0, select "Microsoft Chart Control 6.0 (OLEDB)."
- Place an instance of the Chart control and a CommandButton on Form1.
- Place the following code in the General Declaration Section of Form1:
Private Sub Command1_Click()
MSChart1.Plot.SeriesCollection(1).DataPoints(-1).Brush.Style _
= VtBrushStylePattern
MSChart1.Plot.SeriesCollection(1).DataPoints(-1).Brush.Index _
= VtBrushPatternBoldDownDiagonal
MSChart1.Plot.SeriesCollection(1).DataPoints(-1).Brush.FillColor.Set _
255, 255, 255
MSChart1.Plot.SeriesCollection(2).DataPoints(-1).Brush.Style _
= VtBrushStylePattern
MSChart1.Plot.SeriesCollection(2).DataPoints(-1).Brush.Index _
= VtBrushPatternBoldHorizontal
MSChart1.Plot.SeriesCollection(2).DataPoints(-1).Brush.FillColor.Set _
255, 255, 255
MSChart1.Plot.SeriesCollection(3).DataPoints(-1).Brush.Style _
= VtBrushStylePattern
MSChart1.Plot.SeriesCollection(3).DataPoints(-1).Brush.Index _
= VtBrushPatternBoldUpDiagonal
MSChart1.Plot.SeriesCollection(3).DataPoints(-1).Brush.FillColor.Set _
255, 255, 255
MSChart1.Plot.SeriesCollection(4).DataPoints(-1).Brush.Style _
= VtBrushStylePattern
MSChart1.Plot.SeriesCollection(4).DataPoints(-1).Brush.Index _
= VtBrushPatternBoldVertical
MSChart1.Plot.SeriesCollection(4).DataPoints(-1).Brush.FillColor.Set _
255, 255, 255
End Sub
- Run the project and click Command1 and note that the chart now uses
monochrome patterns instead of colors.
REFERENCES
For additional information, please see the following article in the
Microsoft Knowledge Base:
Q168749
HOWTO: Print the Contents of the MS Chart Control
Additional query words:
kbDSupport kbDSD kbVBp kbVBp500 kbVBp600 kbCtrl
Keywords : kbGrpVB
Version : WINDOWS:5.0,6.0
Platform : WINDOWS
Issue type : kbhowto
|