Quick initial impressions of Microsoft "new" Charting Controls

Microsoft released some really cool charting controls a while back. ScottGu writes about it in one of his blog posts. It is a sweet little collectio  of charting controls both for windows and web development. In the web scenario, you add a specific webcontrol to your page, give it some data and it renders it nicely. At least that is the simple explanation. There is a LOT more things you can control and tweak to make it look like you want it. However, this time I'm actualy using the windows parts of the controls. Reason? Well, I need to create some charts in memory to be added to a PDF document. So I don't really want a webcontrol... So, here are some of my thoughts after working with it for a couple of hours.

First off, I have to say I like it. There are some good examples showing you how to use the controls and get the desired look and feel. I haven't done a deep dive at all. If I were a windows programmer however, I would very much dive in and have a look at the cool features available for live charting, as well as the selection features where you can zoom in on interesting areas in the chart. The samples are windows/webapplications that run on you computer so that you can browse through them and get the information that you need. But you can also open the source code and have a look at exactly what is being done. By the way, I have to say how much I appreciate Microsoft's new approach. Opening up things for the developer, giving them access to source code and so on. Very nice! Thank you Microsoft...

So, what have I found that I DON'T like about the controls. Well, there are a couple of things. There is the little thing where some settings don't have properties for getting and setting. In these cases you have to pass in strings to some non-descript dictionary. Feels very unintuitive and makes it hard to do things without the documentation. An example is if you wish to make the bars in your chart round instead of square. To do this, you wite the following code:

[code:c#]
Series s = new Series();
s["DrawingStyle"] = "Cylinder";
[/code]

It isn't that bad when you see the code like this, or know that this is the way to do it. But I would have preferred:

[code:c#]
Series s = new Series();
s.DrawingStyle = DrawingStyle.Cylinder;
[/code]

There is also another thing I ran into. I tried to make my chart look like the example I had found. To do this, I had to change the border of my chart to a style called Raised. This is according to the examples done by modifying the BorderSkin property of the Chart object. And it is...but thats not all you have to do. The BorderSkin property is of type BorderSkin, which has properties called SkinStyle, BorderWidth, BorderColor among others. So I do something like the following:

[code:c#]
Chart chart = new Chart();
chart.BorderSkin.SkinStyle = BorderSkinStyle.Raised;
chart.BorderSkin.BorderWidth = 1;
chart.BorderSkin.BorderColor = Color.Black;
chart.BorderlineDashStyle = ChartDashStyle.Solid;
[/code]

In my mind that should give me a 1px wide, black, raised border. Well, it didn't! It looked like this...

After a bit of fiddling around, I did get my border to work and look just like the example. But I had to set some other properties than expected.

[code:c#]
Chart chart = new Chart();
chart.BorderSkin.SkinStyle = BorderSkinStyle.Raised;
chart.BorderlineWidth = 1;
chart.BorderlineColor = Color.Black;
chart.BorderlineDashStyle = ChartDashStyle.Solid;
[/code]

This code solves the problem andgives me the border I wanted...

As you can see, to get my border I had to leave the BorderSkin property and start setting properties on the Chart object. Reason? Well, the BorderSkin is only for the shadowing and things and not for my border around the chart. Well, that doesn't really make sense in my eyes since the BorderSkin property actually causes changes to the border as well. In this case it gives it rounded corners... Well... Not that big a deal, but kind of annoying in my eyes.

So what's the verdict? I like the controls without a doubt. They will join me in many projects in the future, but I will probably have to sit down and work with them a bit before I'll understand all the tweaks available. But generally speaking, good work Microsoft! 

Comments are closed