Sparklines in WPF and Silverlight

09 May 2011

image

One seemingly-trivial-yet-recurring problem in financial software is the need for a live-updating line-chart. However, from multiple conversations with Lab49 folks, as well as from experience during my first project, I’ve learned that most WPF/Silverlight charting packages fall short in various ways, especially if you’re updating their data frequently. Seems like everyone just rolls their own line chart and tailors it to each project, but doesn’t share it for some reason. I’d like to break that trend by sharing and early version of my own sparkline control for WPF and Silverlight.

http://github.com/jschementi/sparkline

Sample Usage:

It’s implementation is very basic; Sparkline.AddTimeValue constructs a point at the next time interval and adds it to a Polyline. You can control the sparkline’s visuals, including adding visible points along the line and showing horizontal lines for the latest/highest/lowest values. The source builds assemblies for both .NET 4.0 and Silverlight 4.

There are obvious features missing like rendered axis or variable x-axis (time) values, but hopefully this provides a simple starting place for anyone else needing a very simple updating line graph.

By the way, Andre de Cavaignac, a colleague of mine at Lab49, and Daniel Simon shared their own a while back: Live Updating Line Graph in WPF. Let me know if there are any others out there.

comments powered by Disqus