ailon's DevBlog: Development related stuff in my life

Add Interactive Flash Charts to Your ASP.NET Web Application. Part1: Basics

3/21/2008 4:26:22 PM

This is the first part in the series of tutorials showing how to add dynamic, interactive, data-driven charts to your ASP.NET web applications. These tutorials use amCharts Flash charting components and "ASP.NET Controls for amCharts" for ASP.NET integration.

In this first installment I will show you how to add ASP.NET Controls for amCharts into your Visual Studio toolbox and add a simplest form of pie chart to your page.

Setup

First we need to download amCharts controls and setup our environment. To download amCharts navigate to http://www.amcharts.com/download . Today we will need "Pie & Donut" chart and "ASP.NET Controls for amCharts". Download the files and extract the archives to your preferred location.

Now let's create a new web site in Visual Studio/Visual Web Developer Express and add amCharts to the Toolbox and the site.

To add ASP.NET Controls for amCharts to your Visual Studio toolbox select "Choose Toolbox Items ..." from Tools menu.

choose_toolbox_items_dialog

There select "Browse..." and navigate to the directory were you extracted "ASP.NET Controls for amCharts". Select am.Charts.dll and press "Open".

dll

Press "OK" and you should see 4 new controls added to your toolbox

 toolbox

Now we need to add Flash files for amCharts Pie & Donut chart to our web site. To do that we will create a directory called "amcharts" under the root of our web application and copy the directory "ampie" from the downloaded Pie & Donut chart archive and all of it's contents under that directory.

ampie_files

This is were ASP.NET Controls for amCharts assume to find amPie files. This location could be changed in your web.config file or in your code. See documentation for details.

We are all set to start adding pie charts to our pages.

Basic pie chart

Today we are going to add a simple, static pie chart. To do that we drag the PieChart control from the toolbox to the designer surface and drop it there.

design_pane

We want to add a title to our chart. In amCharts this is done by adding a label. You can add virtually unlimited number of labels but we only want one this time. In the properties window locate a property called "Labels" and press "..." button next to it.

 properties_labels

Collection editor opens. Press "Add" and add label text (title in our case) and modify other properties if you want. We will change color of our title, make it bigger and right-align it.

label_editor

Press "OK". Now let's add our data items. In the properties window locate "Items" and press "...".

properties_items

In the opened window press "Add" to add our first data item.

dataitemeditor

Type in Title (this will be shown in the legend and next to the slice), Value (this doesn't have to be in percents, amCharts will calculate the percents automatically). We'll make our first slice pulled out. To do this we set PullOut to True. Press "Add" to add another item and modify appropriate properties. Press "OK" and save your page.

That's it. In the source view this looks like this:

<cc1:PieChart ID="PieChart1" runat="server">
    <Items>
        <cc1:PieChartDataItem PullOut="True" Title="Yes" Value="32" />
        <cc1:PieChartDataItem Title="No" Value="68" />
    </Items>
    <Labels>
        <cc1:ChartLabel Align="Right" Text="Do you smoke?" TextColor="#FF8000" TextSize="20" />
    </Labels>
</cc1:PieChart>

and when we run our project it looks this way

in_browser

In the next part I'll show you how to bind pie chart to data.

kick it on DotNetKicks.com
Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Related posts

Comments

3/21/2008 4:28:52 PM

trackback

Trackback from DotNetKicks.com

Add Interactive Charts to Your ASP.NET Application. Part1: Basics

DotNetKicks.com

3/24/2008 1:04:32 AM

pingback

Pingback from fatihhayrioglu.com

Fatih HayrioÄŸlu’nun not defteri » 24 Mart 2008 web’den seçme haberler

fatihhayrioglu.com

1/8/2009 6:56:04 PM

Busby SEO Test Pinay

this is the best trick

Busby SEO Test Pinay us

1/9/2009 2:29:15 AM

Busby SEO Test

what best trick? It is not hard at all

Busby SEO Test us

1/9/2009 10:07:15 AM

Inventory Management Software

Hurmm..Nice tutorial..

Right noww, Im learning the ASP.net, so it might be helpful to me

Inventory Management Software us

1/10/2009 6:05:35 PM

inventory management software

very detail tutorial, i really respect you.

inventory management software sg

1/10/2009 10:37:42 PM

Busby SEO Test

I'll try soon this applications

Busby SEO Test us

1/11/2009 1:40:54 AM

jobs for 14 year olds

I will try it soon too.

jobs for 14 year olds us

1/11/2009 1:43:02 AM

jobs for 14 year olds

The interactive flash charts is very nice and I will use on my blog.

jobs for 14 year olds us

1/29/2009 12:26:03 PM

Original London Tour

I love the nice flash charts - thanks for this.

Original London Tour gb

2/26/2009 12:02:03 PM

Piyush

a very good teaching on flash charts.I Practiced your application.i must say its easy to learn.i really thankful to you.pls keep adding ..
regards..

Piyush us

2/26/2009 12:03:00 PM

SHORT JOKES

a very good teaching on flash charts.I Practiced your application.i must say its easy to learn.i really thankful to you.pls keep adding ..
regards..

SHORT JOKES us

3/9/2009 10:35:15 PM

san francisco business partnership lawyers

This is a great tutorial! Thanks for the great information.

san francisco business partnership lawyers us

3/19/2009 3:19:36 PM

Doctor is Out

Nun sagte über Ihre Nachricht, vielleicht kann ich subscride in Ihrem Blog,

Doctor is Out us

3/24/2009 6:19:47 AM

home of natures

Hellow. A pleasant day to all. I am enjoy reading your website or blog. I got many ideas for my blog. Thanks for the information about this topic Add Interactive Flash Charts to Your ASP.NET Web Application. Part1: Basics.

home of natures us

Comments are closed
Copyright © 2003 - 2009 Alan Mendelevich
Powered by BlogEngine.NET 1.3.1.0