If you’re into one of "those" reality TV series, you must have heard of the TV series “The Swan”. This series shows how proper technology and tools can transform ugly ducklings into beautiful swans by offering women the incredible opportunities to undergo physical, mental, and emotional transformations. I know I should not use the word "ugly, as it's the inner beauty that counts right? Yeah right. Is that why we have graphic designers? Unfortunately, the inner beauty concept does not work quite right in the programming world. No matter how great an application you have, you can’t sell it if it's not user friendly and good looking.
If you are a Windows Forms developer or an ASP.NET Web developer, at some point; you will end up writing applications that need to represent data in a graphical format. So this is where these various charting and graphics applications and tools come into the picture. Today, there are dozens of chart components available for .NET and it’s really difficult to decide unless you’ve tried many of them. To be honest, I’ve not used all of them but I’ve used couple of them and I found Dundas Chart Enterprise version much more powerful and robust then others.
Installation
Installing Dundas Chart 4.1 is a pretty simple and straight forward process (you can download a full evaluation version of Dundas Chart 4.1 from Dundas’ web site by clicking here). After registering, you will receive an email with a user id and password that you will be required to provide during the installation process. Dundas Chart supports both Windows Forms and ASP.NET but they come as separate downloads. Dundas Chart version 4.1 comes in 4 different versions -
Obviously the enterprise versions have extra features than the professional versions. Information on the differences can be found at Dundas’ website (www.dundas.com).
Visual Studio Integration
One of the nice features of Dundas Chart is the tight integration with Visual Studio .NET/2003. After installing the Chart, you can immediately see the chart in your Toolbox. See Dundas Chart Enterprise in Figure 1.
Figure 1. Dundas Chart Enterprise in Visual Studio Toolbox
Chart and Data Wizard
Here comes the good part. As soon you drag the Chart control to a page, it converts into a wizard as you can see from Figure 2.
Figure 2. Dundas Chart Wizard
As you can see from Figure 2, there are a full assortment of chart features that you can customize within the Wizard. If you click on any of these Wizard tabs you will see various additional customization options related to that tab. For example, if I click on 3D, it looks like Figure 3.
Figure 3. 3D option
And now if I check “3D Enabled” check box, the chart appearance looks like Figure 4. It actually changes the chart view from 2D to 3D.
Figure 4. 3D view of chart
The next feature tab provides appearance settings. There are various pre-made appearance styles that you can choose from, or you can create you own. You can also use the Border and Advance tabs to set different settings. See Figure 5.
Figure 5. Appearance settings
The Series Data Tab of the wizard allows you to specify the data source (See Figure 6). It can be an ADO.NET data source or series data. Interesting thing is, if you click on Chart Data Source drop down, it launches ADO.NET Data Adapter Configuration Wizard, which allows you to create a data connection and specify the data source.
Figure 6. Chart data source
Besides the above discussed features, the Dundas Chart and DataWizard provides many more chart customization options that are possible directly within the Wizard (I can keep going and going).
Setting Chart Properties
Besides the wizard and code, you can also set the Chart properties using the typical Properties window. As you can see in Figure 7, Annotations, ChartAreas, Legends, Series, and Titles are some of the many properties. If you click on these properties, it launches visual editors to edit the data.
Figure 7. Setting Chart properties using Properties WindowFor example, if you click on the Series property, it launches the Series Collection Editor, where you can set various data for the series. See Figure 8.
Figure 8. Series Collection Editor
Using Dundas Chart Programmatically
Using Dundas chart programmatically is no different than other ASP.NET controls. After dragging the Chart control from the Toolbox to your ASP.NET page, it adds the following code to your ASP.NET page:
protected Dundas.Charting.WebControl.Chart Chart1;
After that, you need to include the following namespace:
using Dundas.Charting.WebControl;Now you can start using Chart methods and properties. For example, the following code sets Chart Legends:private void Page_Load(object sender, System.EventArgs e){// Set legend positionChart1.Legend.Position.Auto = false;Chart1.Legend.Position.X = 35;Chart1.Legend.Position.Y = 40;Chart1.Legend.Position.Width = 35;Chart1.Legend.Position.Height= 10;// Set InputTag rendering typeChart1.RenderType = RenderType.InputTag;}And the output of the above code generates Figure 9.
Figure 9. Creating Dundas chart programmatically.
The following code shows how to merge data points from multiple series into one series.
private void Page_Load(object sender, System.EventArgs e){// Merge data from 4 different series into one series that has 4 Y valuesChart1.DataManipulator.CopySeriesValues("High:Y,Low:Y,Open:Y,Close:Y", "Stock:Y1,Stock:Y2,Stock:Y3,Stock:Y4");// Set stock series attributesChart1.Series["Stock"].Type = SeriesChartType.Stock;Chart1.Series["Stock"].BorderWidth = 2;Chart1.Series["Stock"].ShadowOffset = 2;}
The above code generates Figure 10.
Figure 10. Merging series
Conclusion
If you are looking for an extreme makeover for your data and application, you may want to give Dundas Chart Enterprise 4.1 a try. Your application may be the winner of one of “those” beauty contests. You never know ;).