Introduction
One of the things that has often bothered me about ASP.NET is its lack of a control for basic charting; other web technologies like ColdFusion come with this feature out of the box. The only route we have is to use GDI+ and go from there which can be a pain – especially when we only want to display a simple bar chart.
Here we review an alternative solution – ComponentArts’ 2006.1 WebChart component. Throughout this review I used ComponentArts’ 2006.1 WebChart component with Visual Studio 2005 SP1.
Hopefully what I say here will give you the information required for you to sum up the pros and cons of the purchase of ComponentArts’ 2006.1 WebChart component.
Creating a simple chart
When I got this component the first thing I wanted to see was exactly how fast I could actually get a chart up and running – not with the use of relational data, but with just some dummy data defined manually using C#. For me this was the deciding factor of the component, if it required too much work then why should I buy it? I’d rather save the cash and go down the GDI+ route!
The good news is that you can build a chart very quickly, and visually the graphs are stunning with the option of using many themes including both 2D and 3D charts. My first chart was composed using the C# listing in Fig. 1 and the server mark-up in Fig. 2.
Figure 1: Some dummy data in the codebehind for the SimpleChart.aspx
Figure 2: The xml mark-up for the component
One of the things that confused me at first was that there was no graph when I viewed the page, as it turned out I had to switch to design mode to define the view direction (I always use code view). I must admit after feeling a little annoyed that I had to switch to design view I saw one of the most visually attractive smart tag’s ever! Upon clicking the smart tag I could rotate my graph in 3D space as shown in Fig. 3.
Figure 3: Customizing the web chart control
At this point I was not only impressed with how easy it was to create a basic web chart but also the components’ usability. For anyone who likes pretty things then you won’t be disappointed with the amount of different styles of chart that come with ComponentArts’ 2006.1 WebChart control.
Using relational data
We’ve seen that it’s easy to create a chart but the reality is that we want the chart for use with high volumes of relational data.
In this example, we will use a SqlDataSource control and reference a stored procedure defined in our database. Hooking the WebChart control up to the SqlDataSource control is achieved by simply setting the DataSourceID of the WebChart control to the ID of our SqlDataSource control (Fig. 4) – as we would do a normal ASP.NET server control.
All that is left now is to define the x and y of our chart to the two column names returned by the stored procedure – Title and Units (Fig. 5).
Figure 4: Hooking the WebChart control up to a SqlDataSource control
Figure 5: Binding the x and y of our WebChart control to the relevant data
Custom data access layer
For this example using relational data we will use custom data objects and the ObjectDataSource control. This example is based on the units of a book in stock (hypothetical book shop); to further clarify the scenario I have provided the code for the Book type (Fig. 6) and the Books class (fig. 7) which make up our DAL.
Figure 6: Book type
Figure 7: Books class
With all the plumbing in place it was time to hook my WebChart control up to an ObjectDataSource control which used the GetBooks method of the Books class (Fig. 8).
Figure 8: Hooking up the webchart control to an ObjectDataSource
The only thing left for me to do was define the x and y values of my chart, the x being the book titles and the y being the units in stock for that particular book as shown in Fig. 9.
Figure 9: Defining the x and y values of our webchart control
As soon as I had done that I viewed the page and the WebChart control had bound correctly to my custom data access layer.
As you can tell the process of hooking the WebChart control up to my DAL was very smooth, and more importantly very quick.
Other features
The WebChart control has an impressive list of features, although I decided to use a custom DAL for my relational data example the control also works well with DataSet’s.
If you are curious about how customizable the WebChart control is then you need not worry, you can change the appearance of pretty much everything from chart titles to background images and more.
The ComponentArt 2006.1 WebChart component also comes with a setup wizard that includes the required functionality to define the charts appearance and data source/bindings amongst many other properties of the WebChart control.
For a full list of features visit ComponentArts’ website [1].
Summary
Overall I thought ComponentArts’ 2006.1 WebChart component was easy to use and required minimal coding on my behalf which was a big plus. Another big plus for the component was that it provided many different styles of charting which can be very helpful as the readability of specific data can be a lot easier to identify when it is displayed on the correct chart style.
I would definitely recommend this component to anyone who requires powerful charting for their ASP.NET sites.
[1] http://www.componentart.com/charting/default.aspx
About Granville Barnett
 |
Sorry, no bio is available
This author has published 32 articles on DotNetSlackers. View other articles or the complete profile here.
|
You might also be interested in the following related blog posts
November's Toolbox Column Now Online
read more
October's Toolbox Column Now Online
read more
September's Toolbox Column Now Online
read more
August's Toolbox Column Now Online
read more
July's Toolbox Column Now Online
read more
An Overview of Wrox Series
read more
Due Diligence and Code Comments
read more
The Joy of Code Reviews
read more
Some Early Thoughts on My Book
read more
Book Review Interest
read more
|
|
Please login to rate or to leave a comment.