LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to set line color in visual basic

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

 

 

 

0 Kudos
Message 1 of 4
(15,446 Views)

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

Adri Kruger
National Instruments
LabVIEW Product Marketing
0 Kudos
Message 2 of 4
(15,417 Views)

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 

 

 

 

0 Kudos
Message 3 of 4
(15,402 Views)
Hi,

This discussion forum is used for topics pertaining to LabWindows/CVI. Originally I had though that you were using Measurement Studio components within the Visual Studio environment, but it is now clear that you are asking a question about VB scripting.

I would recommend posting this question on the MSDN discussion forum, as this issue is strictly a question about VB code.

-Adri K
Adri Kruger
National Instruments
LabVIEW Product Marketing
0 Kudos
Message 4 of 4
(15,399 Views)