05-06-2009 04:11 PM
I try to write a visual basic application to draw several lines in the chart, how do I set those lines to certain color. Right now all of
the lines are set to automatic color.
For example, I want to draw line 1 to Blue color in my chart
line 2 to Red color
line 3 to Magenta color
I set:
MarkerBackgroundColorIndex = xlAutomatic
MarkerForegroundColorIndex = xlAutomatic
Thanks
05-07-2009 11:35 AM
Hi,
Could you clarify what Visual basic environment you are developing in? Are you using VB 6.0 or VB.NET? Also, are you drawing these lines on the waveform graph component?
-Adri K
05-07-2009 05:36 PM
Hi Adri,
I'm using Microsoft Visual Basic editor to open tha macro of Excel sheet that have a chart setup in it. What I intedn to do it
to let the macro takes care of the plot. Here is sample of the data:
For line #1 - I have the data point x1(n) , y1(n)
For line #2 - I have the data point x2(n) , y2(n)
For line #3 - I have the data point x3(n) , y3(n)
Here are portion of the macro code that I set up:
.
.
.
'SET PLOT SCALES IF THERE IS A TDF PARAM KEY MATCH
'X1 AXIS SETTINGS
ActiveChart.Axes(xlCategory).Select
With ActiveChart.Axes(xlCategory)
.MinimumScale = xminval1
.MaximumScale = xmaxval1
If check.Xaxis1MinorU = "NONE" Then
.MinorTickMark = xlTickMarkNone
Else
.MinorUnit = check.Xaxis1MinorU
.MinorTickMark = xlCross
End If
.MajorUnit = (xmaxval1 - xminval1) / 10
.Crosses = xlCustom
.CrossesAt = -150
.ReversePlotOrder = False
.ScaleType = xlLinear
End With
'Y1 AXIS SETTINGS
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScale = yminval1
.MaximumScale = ymaxval1
If check.Yaxis1MinorU = "NONE" Then
.MinorTickMark = xlTickMarkNone
Else
.MinorUnit = check.Yaxis1MinorU
.MinorTickMark = xlCross
End If
.MajorUnit = (ymaxval1 - yminval1) / 10
.Crosses = xlCustom
.CrossesAt = -150
.ReversePlotOrder = False
.ScaleType = xlLinear
End With
ActiveChart.PlotArea.Select
With Selection.Border
.ColorIndex = 16
.Weight = xlThin
.LineStyle = xlContinuous
End With
ActiveChart.SeriesCollection(1).Select
With Selection
.MarkerBackgroundColorIndex = xlAutomatic
.MarkerForegroundColorIndex = xlAutomatic
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 2
.Shadow = False
End With
On Error GoTo NoSpecLine
ActiveChart.SeriesCollection(2).Select
With Selection
.MarkerBackgroundColorIndex = vbMagenta
.MarkerForegroundColorIndex = vbMagenta
.MarkerStyle = xlNone
.ActiveChart.Color = vbRed
.Smooth = False
.MarkerSize = 2
.Shadow = False
End With
On Error GoTo NoSpecLine
ActiveChart.SeriesCollection(3).Select
With Selection
.MarkerBackgroundColorIndex = vbMagenta
.MarkerForegroundColorIndex = vbMagenta
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 2
.Shadow = False
End With
What I got was a chart with 3 plotted lines which the Patterns Color was set to Automatic. How to I set The Pattern Color to certain
color I want instead of automatic color.
Thanks
05-07-2009 06:12 PM