Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Re-ordering CWPlot objects within a CWGraph control

ComponentWorks CWGraph control 3.0.1 in VB6SP5 on Win98SE.

On the Plots tab of the property page for the CWGraph control the list of plots can be re-ordered by moving the selected plot up and down the list. This ordering is reflected in the "background to foreground" ordering of the displayed plots on the graph, i.e. Plot-1 will always appear "behind" Plot-2, so if both plots contain the same data Plot-1 cannot be seen since it is completely obscured by Plot-2.

This causes problems where many plots are present in the control. I have a VB ListBox with a list of the plots displayed on the graph. When a ListItem is selected I want the associated plot to be moved to the foreground (so that no other data overlaps it
.)

My original solution was to use an "Active" plot that was always the last added. This means that to add another plot to the list the Active plot must be deleted, the new plot created and the data loaded into it and then the Active plot re-created and the data also loaded into it.

However, for my current application I cannot have keep a data buffer in memory for every plot on the graph - it's just not practical.

I know that there's no way to copy a CWPlot object or that the plot data can be read back from the graph, however is there a way to push a "background" plot to the foreground?
0 Kudos
Message 1 of 3
(5,850 Views)
Hello

You can reorder the CWPlot's objects by accessing them thru the plots obejects. KInda like the following

Dim temp As CWPlot
Set temp = CWGraph1.Plots(1)
CWGraph1.Plots(1) = CWGraph1.Plots(2)
CWGraph1.Plots(2) = temp

I hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 3
(5,850 Views)
I don't know if you've actually tried this but I don't think it works the way you might imagine it does.

If you have two plots: "Plot-1" and "Plot-2" then after running this code snippet you end up with two plots named "Plot-2". This is because 'temp' only takes a reference to "Plot-1", it does not make a copy. So, when "Plot-1" is changed to "Plot-2" by the second line then 'temp' changes also. Therefore assigning 'temp' to "Plot-2" makes no difference.

No other CWPlot properties seem to change.

A proper way to reorganise the CWPlot objects seems to be a major omission, especially since it's the ordering that defines which plot's data is show "on top". Perhaps this is something that should be seriously looked at for the next iteration of this
control?

For the moment it looks like the only way to do what I wanted is to store the data that backs every plot in memory. This is not a great solution with a lot of large plots as this will make a very simple application extremely memory hungry.
0 Kudos
Message 3 of 3
(5,850 Views)