04-20-2009 02:52 PM
I have been managing a software solution for three years now that has one waveform chart. I recently decided that it would be good to allow the users to use several different charts, but I didn't have any more real estate so I placed them on top of each other. Through a numeric control, I set it up so that the chart and legend would become visible when selected, and the others would become invisible. I did this after first trying Chart.SendToBack() but that method caused the chart to blink and layered plots to show. Now the charts disappear when I click on them. The only ones that don't disappear are the ones that I have not added plots to. My selection routine is shown below, and there is no other function or line of code that makes these charts invisible.
[code]
Try
Select Case numChart.Value Case 0wfgTemperature.Visible = True
wfg1.Visible = False
wfg2.Visible = False
wfg3.Visible = False
wfg4.Visible = False
legPlotsA(0).Visible = True
legPlotsB(0).Visible = True
legPlotsA(1).Visible = False
legPlotsB(1).Visible = False
legPlotsA(2).Visible = False
legPlotsB(2).Visible = False
legPlotsA(3).Visible = False
legPlotsB(3).Visible = False
legPlotsA(4).Visible = False
legPlotsB(4).Visible = False
Case 1wfgTemperature.Visible = False
wfg1.Visible = True
wfg2.Visible = False
wfg3.Visible = False
wfg4.Visible = False
legPlotsA(0).Visible = False
legPlotsB(0).Visible = False
legPlotsA(1).Visible = True
legPlotsB(1).Visible = True
legPlotsA(2).Visible = False
legPlotsB(2).Visible = False
legPlotsA(3).Visible = False
legPlotsB(3).Visible = False
legPlotsA(4).Visible = False
legPlotsB(4).Visible = False
Case 2wfgTemperature.Visible = False
wfg1.Visible = False
wfg2.Visible = True
wfg3.Visible = False
wfg4.Visible = False
legPlotsA(0).Visible = False
legPlotsB(0).Visible = False
legPlotsA(1).Visible = False
legPlotsB(1).Visible = False
legPlotsA(2).Visible = True
legPlotsB(2).Visible = True
legPlotsA(3).Visible = False
legPlotsB(3).Visible = False
legPlotsA(4).Visible = False
legPlotsB(4).Visible = False
End Select
Catch ex As ExceptionMsgBox(ex.ToString)
End Try
[/code]
04-22-2009 02:36 PM
SCXI,
I have made an example that shows/hides two waveformgraphs either using a numeric edit control or a listbox. You can put the graphs one ontop of another and the program works as expected. Please try this example on our community site How To Show/Hide Waveform Graphs Using Listbox or NumericEdit with VB .NET 2003 & Measurement Studi... if you have problems getting this code to perform as expected, please let me know. Another option could be to use the TabControl to show and hide the waveforms you want to.
04-23-2009 01:33 PM
Yours behaves as it should, but mine is a little different. I am appending data to the charts every second. I commented out all but the first chart and it would not disappear when I clicked on it. Then I uncommented the second chart plotyappend and the first would disappear but not the second. The trend continued. This is the update I am using:
[code]
Try
.wfgTemperature.PlotYAppendMultiple(ChartData)
.wfg1.PlotYAppendMultiple(ChartData1)
.wfg2.PlotYAppendMultiple(ChartData2)
'.wfg3.PlotYAppendMultiple(ChartData3)
'If (Now.Second Mod 5 = 0) Then .wfg4.PlotYAppendMultiple(ChartData)
Catch ex As Exception
Try
swError = New StreamWriter(Application.StartupPath & "\Errors\" & RunNumber & "_" & "Error Log.txt", True)
swError.WriteLine(TimeString & vbTab & "DisplayData - Chart" & vbNewLine & ex.ToString & vbNewLine & vbNewLine)
swError.Close()
Catch ex1 As Exception
End Try
End Try
[/code]
04-23-2009 02:16 PM
Michael,
Try this modified example that appends the plot every second as well as hides and shows two of the plots. It works on my computer, if this still is not the behavior you are experiencing, could you either modify this example or post a simplified version of your graphing application, without any data acquision so i can run it without hardware? One thing i had to do after setting visability was to call update on the graph.
wfg1.visible = false
wfg2.visible = true
wfg1.update()
wfg2.update()
12-29-2009 10:52 AM - edited 12-29-2009 10:53 AM
I have revisited this issue as the feature would be so useful for us, but I am having the same problem regardless of the 1 Hz update call. When the charts are not on top of each other they work exactly as expected. When they are on top of each other only the fourth chart works. All others will disappear when I click on them. I've attached a small project that doesn't have any DAQ in it.
Thanks!
12-29-2009 01:52 PM
12-30-2009 10:24 AM
What version of visual studio and measurement studio are you using? I get errors when I try to open this vb form.
From what I understand you are experiencing correct behavior except for when you click on a graph, at that time the graph will disapear unless it is graph number four. Is this correct? If so, when you run my example do you experience the same behavior with only two graphs?
12-30-2009 11:23 AM
The latest, and that error is very annoying. I have to comment on the lines that set those values on the designer (although that is bad practice). You can change the color settings on the plots for each chart to get rid of that error, but I'd like to know why it happens and how to fix it. I'm trying to specify the color of the plots and it gets mad.
I did not have the problem with your application, but from what I remember it was not writing to the charts at 1 Hz. That was the only difference I could find.
01-04-2010 12:38 PM
Michael,
I modified my example to demonstrate multithreading patterns with visual basic and posted a new copy to the Community. http://decibel.ni.com/content/docs/DOC-8738 . This should demonstrate how to update the UI from a seperate thread as well as how to make up to four graphs show and hide at a rate of 1hz (using a windows timer control). If you're still having problems getting yours to work, feel free to download and modify my example to meet your own needs.
I would recommend starting a new form thread for your question on changing color settings, that way anyone with the same question in the future can easily find the solution.
01-05-2010 01:25 PM
I don't really understand what you are doing differently that I am, other than that you are appending a waveform and I am appending a single point. I added a timer to your example and appended a waveform at 1 Hz and it worked fine. Then I moved my plotting command to an unthreaded timer in my program and the charts still disappear. I only need to plot points at 1 Hz, so plotting a waveform is not useful for me. Is there any chance you can reset the plot colors on my project to auto generation and then try it out?
Thanks.