I have recently been looking for some graphing/charting functionality for a home project I am working on. My requirements are fairly simple:
- handle data quantities in the region of thousands and tens of thousands of rows/items
- be able to display line charts with or without data points (there will be so many data points that they can become noise)
- be able to display multiple sets of data to be able to compare data
- free or cheap
- xcopy install
Now as the Charting products I wanted to compare were all going to be in WPF I assumed that these requirements were just a given but apparently not, so let me specify them as well
- be able to bind the data from my own view model (i.e. I don’t want to have controls littering my View Model)
- have the graph update as the data changes
Now to see the list of contenders:
- WPF Toolkit Charting (aka System.Windows.Controls.DataVisualization.Toolkit)
- AmCharts
- VisiFire
- DynamicDataDisplay (aka D3)
So for the really quick review of each
WPF Toolkit Charting
This is the CodePlex project from some of the lads at Microsoft. This is presumable of a lesser quality than the rest of the Toolkit as the Charting component is in preview. The WPF Toolkit allows for great looking charts by utilising the power of WPF Styles. It is one of those balancing acts that must be difficult to make when designing software; extensibility vs. simplicity. The WPF Toolkit leans more towards the extensible option. Extending the charts to look the way you want can be done but many will find it fiddly and frustrating, but once done can be very rewarding and the Graphs can look amazing. The WPF Toolkit also utilises the power of WPF binding by allowing me to bind to my ViewModel. So it looks like a good start, however, the clear and painful problem with the WPF Toolkit is performance. When loading up even hundreds of rows/items the performance is fairly poor. When I tried to throw just over a thousand items at a Line Series the performance was completely unacceptable. One other problem I have is that I get intermittent lock ups. When updating the data, the charting code will run off into a loop and not come out of it, freezing the UI. Hmmm another cross.
Positives:
- Extensibility allows for beautiful graphs
- Charts bind to ViewModel
- Free
Negatives:
- Woeful performance
- Random lock ups.
AmCharts
AmCharts appears to be a Charting solution aimed at the financial industry. The chart control that I thought would best fit my needs was the Stock chart. This chart had a great feature that allowed zooming on the X-axis by providing a range slider. Performance was great when I threw ~1500 items at the control. An odd problem I had was the graph would only appear once I resized my window. I think this has to do with binding to a ViewModel as the Demo does not have this problem but it also directly interacts with the control from the Code behind. I want to avoid “messing with controls” from my ViewModel. A more real problem I have is that while the performance is great, the binding seems to be a once off event. Changes to the values in my collection are not reflected by any change to the chart.
Positives
- Good performance
- Charts bind to ViewModel
- Zoom functionality
- Good samples
- Smallest DLL size (223KB)
Negatives
- One time data binding
- Odd problem with Chart not rendering until i resized the window.
Visifire
VisiFire charts looked to be a great option. They were very easy to get up and running, had some good samples like the AmCharts. My first play with the Visifire charts provided me with a good looking chart. My problems came when I went to bind the Charts to my ViewModel…Visifire does not support data binding! I’m not even sure why someone would write a WPF control that does not support data binding. I wasted plenty off time writing some adapters so that I could get data binding working. Data binding is in the wish list for version 3 (how it didn't make it into the wish list for the 1st version I don’t know). Performance of Visfire was pretty good (not spectacular) and sat in between AmCharts and the hopelessly slow WPF Toolkit.
Positives
- Easy to get up and running
- Pretty good looking default charts
- Moderate performance
Negatives
- You cant bind a data series to a collection!
Dynamic Data Display
The Dynamic Data Display (aka D3) is another Microsoft project on Codeplex from a Microsoft research team in Russia. D3 authors claim outstanding performance even with massive amounts of data. Sounds like a sure fire winner! The control library also supports different types of charts to the other libraries like Maps and Isolines ( I have no idea what an isoline is). The samples show some good stuff with smooth moving animated graphs with dynamic data points. The big fail on the project is again, no data binding. All manipulation of the charts needs to be done in C# code and needs to be very imperative. There are some guys, however, who have made posts creating an extension to the controls to support data-binding. Either way, while this looked to be a good set of controls, the authors don’t appear to have followed the Pit-of-Success principle. I would go in to details, but the fact it took me hours of reading forums, looking at samples and coding to just get my Model showing on the screen. When it did get on to the screen it was fast, but didn’t update when the underlying data changed. This is a very immature set of controls but may have a bright future if the team can get some fundamentals right.
Positives
- High performance
- Easy to scroll and zoom data
Negatives
- Hardest set of controls to work with. Everything has to be done in code. Authors seem to miss the point of WPF entirely. Presentation and logic feel very much couple together.
- After all my mucking around the chart didn’t update with my changes to the data.
In summary, I am pretty disappointed with the state of all of these charting controls. What I did manage to get working to a satisfactory state was the WPF Toolkit. As the only real problem I had with the WPF Toolkit charting controls was their performance; I decided that an easy way to get some better performance out of the control was to only show as many data points as there were available pixels. If I only have 400 pixels to show my data it becomes a bit silly to try and get the graph to render 1400 data points. I created a Custom Control that extends CollectionViewSource by having a MaxItemCount property that can be set to effectively filter the amount of data the CollectionViewSource reveals to the Charting controls. The performance was better but I was able to further tweak the performance by adding a DivisionConverter to further reduce the collection size by the parameter specified (10 in my case). This means I only show a data point for every 10 pixels wide the chart is. This ended up being a great compromise….except for the random lock ups. If I play on the Chart for long enough changing the data to update the chart, eventually the program just falls in to a loop. If I can solve this bug I may have a winner on my hands. Ed:—Playing around more I may have got rid of this problem. Still pops up sometimes straight after a build, but a restart fixes it. This may be to do with my build of Win7 (pre release that I am still running). This throws the WPF Toolkit +the 2 tiny bits of filter code clearly into the lead as it can be made to look great and handle tens of thousands of rows.
If any one is interested in the code I used to test/play with each of these libraries you can find a zip of the VS2008 solution here. To see any of the spikes, just set it as the start up project and run or Right click on the project and “Debug”—> “Start new instance”. Only the MyDomain project wont run as that is the Class library that has the small part of the domain to test the charts with.
9 comments:
There is a good post on squeezing performance out of the WPF tool kit charts on Delay's blog.
http://blogs.msdn.com/delay/archive/2010/01/13/i-feel-the-need-the-need-for-speed-seven-simple-performance-boosting-tweaks-for-common-silverlight-wpf-charting-scenarios.aspx
It is typically that I find this post after I have done most of these changes any way. Oh well.
Thanks for taking the time to write this. I liked the Visifire API the most, and it now supports Databinding. But, it's very slow for charts with > 5k points. Infragistics has a new product called XamDataChart, but the company itself is very unresponsive to email inquiries and they lack little documentation. I'm still searching for the right chart. Thanks again.
-JP
Thank you for posting this, it is great to see other devs in my same position. My data set generally consists of 8 line series with 360 points per series.
I have settled on the WPF toolkit. There is no way to state performance other than, woeful, as you said. I found subsequent chart rendering speeds up 2-3 times by recreating Series for updates rather than updating the data points, but it leaks tons and tons of memory this way. I have not yet found a way to force it to release whatever memory it is holding on to, and it holds on to it for the duration the program is open.
I've done everything on Delay's performance blog other than trying a different platform! -J
Hello I would like to add to my previous post - I threw my hands up and moved to WPF Toolkit 4 from 3.5, and now while memory consumption is still egregious, at least now the GC is able to get the memory back soon after the Series is no longer in use.
Visifire has support for DataBinding now. Even the performance has been optimized if the chart contains larger number of DataPoints.
Please check out the blog posts here.
http://www.visifire.com/blog/2011/10/20/performance-optimised-initial-render-now-2x-faster/
Visifire has support for DataBinding now. Even the performance has been optimized if the chart contains larger number of DataPoints.
Please check out the blog posts here.
http://www.visifire.com/blog/2011/10/20/performance-optimised-initial-render-now-2x-faster/
Great news on the visifire update. I will need to have a look, however the next charts I will be using will be for a Metro app so I am not sure if any of these findings are relevant for Metro at all?
If you decide to update your wpf charting content, or for those researching wpf charting, include http://www.gigasoft.com in the mix. No hassle 7 meg demo download with equally simple uninstall guaranteed to impress that quickly shows high levels of logic, rendering quality, and the necessary code.
Hey Lee,
Long time no speak! I stumbled across this post. If you're looking for performance in a WPF Chart control, take a look at SciChart - which I wrote and now licensing through my Ltd Company.
We cover most of the basic chart types Line, Scatter, Mountain, Bar, Candlestick, OHLC but its tuned for immense performance - tens of millions of data-points. One of our users posted a youtube video demonstrating the performance of SciChart in a trading system.
Hope all's well!
Best regards,
Andrew
Post a Comment