Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Plots.indexof (waveformgraph) vs Plots.item (CWGraph)

I am using waveformGraph component to multiple plots in one graph.
But waveformGraph does Not has method of Plots.Item(in activeX CWGraph). It has Plots.indexof()... Shoud I use Plots.indexof

private void PlotOne_Click(object sender, EventArgs e)
{
       waveformGraph1.ClearData();
       waveformGraph1.Plots.?????????????
}  



Reference:
activeX CWGraph code is working:

Private Sub PlotOne_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PlotOne.Click
        ' Plot the selected plot onto the graph.
        CWGraph1.ClearData()
        CWGraph1.Plots.Item(PlotSlide.Value).PlotY(singlePlotData, 0, 1)
End Sub

Thanks
Matt
0 Kudos
Message 1 of 6
(4,207 Views)
I have tried to use following two ways, but complains received:
          
    waveformGraph1.Plots.IndexOf(slide1.Value).PlotY(singlePlotData, 0, 1);

or
    waveformGraph1.Plots[slide1.Value].PlotY(singlePlotData, 0, 1);


What is the correct way to grab the related plots (activeX CWGraph using Plots.Item(....)

Thanks
Matt

0 Kudos
Message 2 of 6
(4,203 Views)

Hi Matt,

Suppose you had a
WaveformGraph object called sampleWaveformGraph and you had two plots on this graph. To access plot 1's methods and properties, you would say

sampleWaveformGraph.Plots[0].PlotY(data);  // The parameters index of Plots[index] is zero-based

The IndexOf method returns the zero-based index of the first occurrence of an item in the collection. In this case, you’re working with the Plots collection. So for example, let’s say you had a plot object called waveformPlot2. Then to figure out at what index this plot is located in the Plots collection, you would say

int index;

index = sampleWaveformGraph.Plots.IndexOf(waveformPlot2);
  // if this plot was the second plot in your collection, index would be 1 since the Plots collection is zero-based.

Have a look at the shipping examples for plotting located in the
<MeasurementStudioVS2005>\DotNet\Examples\UI\Graph directory to help you get started on plotting.

Best Regards,

Jonathan N.
National Instruments
Message 3 of 6
(4,195 Views)
Hi Jonathan N.;

sampleWaveformGraph.Plots[0].PlotY(data);  // The parameters index of Plots[index] is zero-based

The index in Plots[index] is integer, however, I am using slide.value which is a double type. Do I have to conver slide.value to int
something like:    Plots[System.Convert.ToInt32(slide.Value)]      ????

Thanks
Matt
0 Kudos
Message 4 of 6
(4,187 Views)
Hi Jonathan N.;

AxCWSlide has a Numeric property in which you can select Discrete value(not Continuous)
and set Interval equal 1 so Plots.Item(PlotSlide.Value) is working.

Does Slide component in WindowForms Slide has the similar property I can set?
If yes, I can you Plots[slide.Value].PlotY(data) directly (no convert double to int for slide.Value

Thanks
Matt
0 Kudos
Message 5 of 6
(4,184 Views)
Hi Matt,

All of the derived NumericrPointer objects (Knob, Gauge, Meter, Slide, Tank, and Thermometer) have a Value property that is of type double. Thus, if you want to use that Value property in a parameter that accepts an integer, you must convert or typecast that value to a type int. So you could say

sampleWaveformGraph.Plots[(Int32) slide1.Value].PlotY(data);

or

sampleWaveformGraph.Plots[System.Convert.ToInt32(slide1.Value)].PlotY(data);


Best Regards,
Jonathan N.
National Instruments
0 Kudos
Message 6 of 6
(4,172 Views)