views:

520

answers:

2

Approaching Silverlight development is a rather daunting task as it seems to require a rather different mindset to work I have done in the past.

I have been working on it for several months and we have already released an application that presents form-based pages. So I have the basics of XAML for layout but what I need to do now is move into graphically representing data. For example transform a list of objects representing vehicle speed recordings into a line graph of speed. I am at a loss on what the best way is to approach this.

Can anyone point me to articles or tutorials that present this kind of thing?

+1  A: 

Bang your head against it for 3-6 months. That's how I did it and it's worked out pretty well so far.

But seriously, the learning curve sucks.

There's charting libraries for Silverlight out there, you could grab one of those but I wouldn't waste money on it. It's relatively easy to write this kind of code yourself.

All you really need is a DrawingVisual. Once you have that you can render what you need on to it's surface. The trick is to make sure that you have sufficient layout information when you render. Because this is vector graphics, you can use the ScaleTransform to match your content bounds instead of repainting on size changed. Other than that, you'll wanna host your DrawingVisual in a UIFrameworkElement and let the dimension of that object govern where and how you draw your data. This will give you all the layout goodness of WPF/Silverlight.

For drawing there are plenty of Geometry classes you can rely on but there's one thing that you'll wanna do and that's to adjust the level of detail in your data points with respect to your drawing. This is the number one trick to make sure you don't hog the CPU.

Avoid drawing more than one data point per pixel. If you have a lot of data points, and a small drawing surface you can use a rolling average to smooth the result.

If you approach this with the above things in mind you should be able to write a flexible graph UI element that you can visualize data with, in no time at all.

I did this in a WPF application, I'm pretty much assuming that you can do the exact same thing with Silverlight 2.0, you'll just yell at me if you cant?

John Leidegren
I'm reading up on Paths and the mini-language used to describe them. I think that will work best for what I need.
Steve Crane
I found an article on Canonical Splines in WPF and Silverlight (http://is.gd/k4eu) that is exactly what I need for this particular plot.
Steve Crane
Doesn't appear that you can (yelling suppressed). WPF gives us DrawingVisual for low level stuff, but it didn't make it into Silverlight 2. I just got bit trying to port something from WPF. There is a bit of discontent about it not being in Silverlight 3, but I haven't confirmed that yet. Here's hoping.
Adrian
+1  A: 

Your first port of call for Silverlight learning should be the official site http://silverlight.net/Learn/

If you want to do any data visualization/charting then first try the Silverlight Toolkit on codeplex. It's fantastic if you want to get anything up and running quickly.

Also check out Delay's Blog on charting and the chartbuilder code

brodie