Following the demonstration of the Microsoft .NET Chart control in a previous document (here), I was challenged to create a more user friendly XControl. It's taken some time (we're all busy people) but here's the first draft!
Attached is an XControl that encapsulates a Microsoft .NET Chart. Properties have been created to allow setting of parameters and an Interactive Demo is included to show how easy it is to implement the XControl.
You'll need the Microsoft Charts toolkit, which is a very small download and absolutely free (download link).
The XControl is at V0.1 and therefore not finished yet, but most of the basic functionality is there. Currently you can:
If you like the XControl, please leave a comment with suggestions on how to improve it.
It is a working progress, and as such cannot be assumed to be stable or reliable, so I wouldn't necessarily recommend you use it for a mission-critical project! But with progress, it could become something very useful indeed
V0.1 Known problems:
Two more snapshots showing radar and polar plot modes (Note: I didn't use the Interactive Demo V0.1 to generate these)
Hi! This looks great, however I just tried to open the Interactive Demo.vi and a certain dependency is missing... System.Forms.DataVisualization.dll. I have Windows7 and VS9, is there a toolkit for these charts that i need to install?
Hi ali66b,
Yes, my apologies. You need the Microsoft Chart toolkit, which is a very small download and absolutely free (direct download link).
I referenced this originally in my Microsoft Charts In LabVIEW document, but forgot to include it here.
Yep.. works now! Thanks
Alex
This looks really cool. I can't wait to try it out.
Thoric,
You've outdone yourself again! I truly appreciate anyone who breaks the ice with new LabVIEW - .NET applications. I currently have a need for using your XControl via either the Radar or Polar chart type - but only with one (1) channel of data displayed. Is this possible with the current XControl functionality ? Thank you.
Hi KarlH, and thanks for the kudos!
Yes, Radar and Polar plots can be done with the XControl, but not in the Interactive Demo (V0.1) as there's a little bug with the plot mode ringlist. I'm working on improving the demo to allow you to control these parameters better.
I've added two snapshots to show the radar plot and polar plot modes, each showing two channels but you can plot just one of course.
.
Very nice, Thoric! I think it is time to invest some effort on my part to learn X-controls!
That being said - as a dumb user I did manage to throw an unhandled exception that forced me to have to actually close the demo and reopen it (I tried to use a column and pie chart simultaneously).
Hi Matt,
Yes, XControls can be very powerful! I acknowledge that my Interactive Demo has flaws, and setting the two plots to use conflicting types causes a .NET exception that can't be recovered. One has to close down the demo completely and reload it
Ideally the software would allow the user to change the plot types together to prevent the clash. I'm working on updating the Demo to make this possible
Jeez, Thoric! Whadaya have a day job or something?!
Hi there. Well done. Is it possible to use this control as an X-Y graph?
Yes, it most certainly can. Use the Point chart style for (X,Y) data.
In my demo, I generate random signals with monotonic x data, but it can easily accept a vector of X values and another of Y values (they need to be bundled into a LabVIEW Waveform datatype for the XControl)
There's also a FastPoint chart style, presumably for rapid updating or large datasets.
I'm no familiar with using waveform datatype but that only has Y and dt (constant). I want X vs Y. Can you post an image on how to form the necessary datatype? Very basic question I know. Much appreciated.
Also, how do you add/remove data series? When I wire my own data to the control terminal I still see the second random data series and in the legend. Can all the data series be reset?
Hi battler,
I also am not very familiar with LV waveform datatype, I selected to adopt it here because it allows multiple charts in one control (without resorting to using arrays - which might confuse basic users who want to plot a single chart). It may be you are right and that one cannot create a waveform datatype that contains independent X and Y values! This is a problem, and a limitation of NI's datatype I wasn't aware of . I've taken a quick look and cannot see a way around this right now. It may be I have to abandon the Waveform Datatype in favour of something else? (Gentle prod for suggestions from people)
On your second note, the XControl is supposed to delete an unwanted series from the chart when you input only one series. Clearly this isn't working. I'm looking at fixing this now...
Thoric, what about an array of cluster of x and y arrays. This is versatile as both x and y and dt (constant steps in y array) can be used. I think anyone wishing to use an x control and .NET should be familiar with arrays and these techniques. Nice work!
Hi battler,
Yes, I'm currently turning the internal data storage buffer into an array of clusters of x and y arrays, which is what the LV XYgraph accepts for multiple plots. However, I still want to avoid using an arrayed datatype for the indicator terminal because I know an array of a cluster of arrays can be bamboozling for newbies (I was there once myself!). So instead I'm wondering if I open up access to the internal data buffers through more property nodes (such as Active Series, X Data, Y Data), then one could programmatically populate the XControl when needing an XY plot. An obvious downside for newbie users, but does allow more functionality. We'll see how the development goes - I hope to have something for release soon...
Hi everybody, Thoric are there any chances to have this for LabVIEW version 8.5?
Thanks a lot, Do you plan to go further with this Topic?
Very impressive. I tried it in LV 2010 SP1 and got the following .NET Framework error when trying the StackedBar style:
Hi, yes, although the XControl supports StackedBar styles, the Interactive Demo causes a problem. The stackedbar style cannot be combined with other styles, but the interactive demo will only let you change one plot line style at a time, so as soon as you change the first to StackedBar it causes a .NET Chart control error.
The solution is to either change the interactive demo to set both line styles simultaneously by deleting the second ChartType control wiring to first to both array builder inputs in the "Chart Type:Value Change" event case (see snapshot below), or just avoid the interactive demo and play around with the XControl in your own VI
Nice work here. You might consider splitting the xcontrol along the lines of the waveform graph and xy graph, i.e, make two xcontrols with bascially the same backend but with different input types. It's hard to make a single type to handle all graph types.
Great job! I am very excited to see better looking plots are obtainable in labview. Is there a way to modify the scaling of the x and y axis? I have an array of numbers that I want to enter into the x and y axis but I can not figure out which VI will give me access.
Thanks.
Hi Thoric !
Nice job withe the MS Charts !
Currently manipulating them, I'm facing a small problem : did you fin a way to have the back color transparent ?
In my case, I can't get my VI background visible. It always stays grey even if I set the Chart.BackColor to Color.Transparent.
OK, so I've been looking into this and it appears that the LabVIEW .NET Container object doesn't honour the transparency of the contained .NET class instance. Therefore, although you can set a transparent background within the Chart control, LabVIEW shows this as a region of grey. Maybe one for the Idea Exchange?
Great Work, Thoric!
Is there a way to register events with .NET charts?
LVCoder wrote:
Is there a way to register events with .NET charts?
You have to register callback VIs when using .NET events: https://decibel.ni.com/content/docs/DOC-9161
LVCoder wrote:
Great Work, Thoric!
Is there a way to register events with .NET charts?
Yes, I use .NET callbacks in my LabVIEW Speech Synthesis demo, use this as a guide (as well as David's link) to learn more. (This presume the Microsoft Charts have any events to register in the first place?)
Thanks for the links!
I was looking for a maker property on a data point to make it movable, but couldn't find it. I believe I'll have to programatically change it's position using .NET events.
And, Yes, MS Charts have events to register.
Hi Thoric,
This is Excellent...! Could you please, guide me how to plot Polar Plot.
Anyone having problems running this in Labview 2014 with dotnet 4.0? When I select box plot it seems to crash.....
When loading the Xcontrol, it reports 5 warnings about the dot net assembly being 4.0 instead of 3.5.....
- Expected Assembly "System.Windows.Forms.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", but found "System.Windows.Forms.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35."
Thanks!