Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Change Graph Linecolor Dynamically

Hello,

I have an active X (AxCWGraph) graph control on a Visual Basic.Net form.  From the properties area I have enabled eight channels and given each its own name and color.

What I am trying to do is only plot some of those linecolors, depending on the data to be drawn.  In other words I have a device which can stream up to, but doesn't have to stream eigtht  channels of data.  This means that channels 2, 5 and 7 could be enabled, which would mean I want the these specific channel colors to be graphed rather than just the first three default colors.  I am passing an array to the graph using the chartY function, which is smart enough to know how many channels to graph, but apparently I'm not smart enough to tell the graph which colors or channels it should be graphing. 

I have been fiddling around with the control and reading the documentation but I haven't found a way to do this.  The two ways I can think to do this are, first to only enable or make visible the correct graph channels, or second to dynamically change the colors for the channels to be graphed. 

Any help or ideas would be great. 

Thanks in advance,
Adam


0 Kudos
Message 1 of 7
(3,439 Views)
/bump
0 Kudos
Message 2 of 7
(3,431 Views)

Hi Adam,

I think your best option is to set the visible property for each plot to either nonvisible or visible depending upon what channels you are working with. So if you are using channels 2, 5, and 7, then just deselect the visible property for the other channels.  

For example, if you wanted to make Channel 1 invisible, then you could say

AxCWGraph1.Plots.Item(1).Visible = False

Hope this helps!

Best Regards,

Jonathan N.
National Instruments
0 Kudos
Message 3 of 7
(3,416 Views)
Thanks for your reply.

I have experimented with doing this, as I figured it would be the most elegant way to write the code.  However, I seem to have a problem getting it to work. 

I have deselected the 'visible' checkbox for all 8 plots in my graph, and then put in code just as you have shown here and it no plots show up?  I know my code is working because I have stepped through it, and I am getting to the correct points depending on the channels enabled, but the graph doesn't want to draw anything. 

Also, does the item count start at 1 or 0?  I have been wondering this as I can't seem to find it anywhere.

Any suggestions?

Thanks again.

Message Edited by jacko on 03-01-2006 03:12 PM

0 Kudos
Message 4 of 7
(3,416 Views)

I think I know where the problem is.  I stepped throught the code, and added a watch item of Graph.plots.item(5).  and item(1).

Channel 1 visible is set to false, and channel 5 visible is set to true at run-time, however for the Ydata as well as a few other part of item(5) it says," <error: an exception of type:{{System.Runtime.InteropServices.COMException}occerred>"

Any idea why this is happening?

THanks again!Smiley Tongue

0 Kudos
Message 5 of 7
(3,409 Views)
Hi Adam,
 
I am attaching an example that we used in Visual Basic 6.0 since this is an activeX control that you are using. Simply open it up in .NET and run through the conversion wizard. I just tested it out myself and it shows plotting different colors with different channels. I also tested out that statement I mentioned below for making a plot invisible and had no problem with it.
 
Hope this helps!

Best Regards,
Jonathan N.
National Instruments
0 Kudos
Message 6 of 7
(3,408 Views)
Thanks for your help.  I think the difference between my code and yours is that I am trying to make them visible at run-time rather than invisible. 

I'll check out your code, thanks again for your help!


Adam
0 Kudos
Message 7 of 7
(3,404 Views)