Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 2nd, 2005, 04:20 PM
Authorized User
 
Join Date: Apr 2005
Location: Spanish Fork, UT, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to DudeBori82 Send a message via MSN to DudeBori82
Default Help on Pie Chart

I am new to C# and ASP.NET and would like to make a pie chart from 4 double variables. Every article I can find is too advanced for me, is there any book, person, or article that can explain how to build a pie chart in ASP.NET/C# in lower level terms? (For slower people like me to understand.) (If anyone is familiar with C1WebChart, that would even be better.)

Actions are a direct result of your desires. Desire for good things.
__________________
Troubleshooting life: 1 bug at a time.
Reply With Quote
  #2 (permalink)  
Old May 2nd, 2005, 04:35 PM
Imar's Avatar
Wrox Author
Points: 72,045, Level: 100
Points: 72,045, Level: 100 Points: 72,045, Level: 100 Points: 72,045, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,083
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Do you want to build the chart engine yourself, or do you just want to create a chart using an existing component?

If the latter, check out this site and this article.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #3 (permalink)  
Old May 2nd, 2005, 04:38 PM
Authorized User
 
Join Date: Apr 2005
Location: Spanish Fork, UT, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to DudeBori82 Send a message via MSN to DudeBori82
Default

I don't want to reinvent the wheel. I have C1WebChart component, but i can't find anything (not even examples) on how to do it from a low level. I would prefer to use an existing component.

Actions are a direct result of your desires. Desire for good things.
Reply With Quote
  #4 (permalink)  
Old May 2nd, 2005, 04:47 PM
Imar's Avatar
Wrox Author
Points: 72,045, Level: 100
Points: 72,045, Level: 100 Points: 72,045, Level: 100 Points: 72,045, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,083
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

What "low level" are you referring to? The site I pointed you to has the component, a bunch of examples and a help file.

Are you looking for something else?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #5 (permalink)  
Old May 2nd, 2005, 04:59 PM
Authorized User
 
Join Date: Apr 2005
Location: Spanish Fork, UT, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to DudeBori82 Send a message via MSN to DudeBori82
Default

Hey, this looks like it. I'll check it out.

Actions are a direct result of your desires. Desire for good things.
Reply With Quote
  #6 (permalink)  
Old May 2nd, 2005, 05:21 PM
Authorized User
 
Join Date: Apr 2005
Location: Spanish Fork, UT, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to DudeBori82 Send a message via MSN to DudeBori82
Default

Code:
            DataSet dsChartData = new DataSet();
            dsChartData.Tables.Add("Chart Data");
            dsChartData.Tables[0].Columns.Add("Incomplete");
            dsChartData.Tables[0].Columns.Add("Pass");
            dsChartData.Tables[0].Columns.Add("Pass (Effective)");
            dsChartData.Tables[0].Columns.Add("Fail");
            dsChartData.Tables[0].Rows.Add(dsChartData.Tables[0].NewRow());
            dsChartData.Tables[0].Rows[0]["Statuses"] = dIncompletePercentage;
            dsChartData.Tables[0].Rows[1]["Statuses"] = dPassPercentage;
            dsChartData.Tables[0].Rows[2]["Statuses"] = dPassEffectivePercentage;
            dsChartData.Tables[0].Rows[3]["Statuses"] = dFailPercentage;

            PieChart pcWebChart = new PieChart();

            pcWebChart.DataSource = dsChartData;

            pcWebChart.DataXValueField = "X Value";
            pcWebChart.DataYValueField = "Y Value";
            pcWebChart.DataBind();

            pcWebChart.DataLabels.Visible = true;

            wcPieChart.Charts.Add(pcWebChart);
            wcPieChart.RedrawChart();


I tried to recreate it in C#, but it didn't work. It gives me a invalid DataSource type when i try to access the page. - I don't actually get that data from a database, it's calculated. Can someone help me figure this out with C#?
Reply With Quote
  #7 (permalink)  
Old May 3rd, 2005, 03:01 PM
Imar's Avatar
Wrox Author
Points: 72,045, Level: 100
Points: 72,045, Level: 100 Points: 72,045, Level: 100 Points: 72,045, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,083
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Is this the code form the control I pointed you to, or is C1WebChart a different control?

The WebChart I linked to accepts any IEnumerable object as its datasource, so you can't point it to a DataSet directly. You'll need to do something like this:

pcWebChart.DataSource = dsChartData.Tables[0].DefaultView;

The DefaultView of the Table object is an IEnumerable, so that should work.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Big Exit by P J Harvey (Track 1 from the album: Stories From The City, Stories From The Sea) What's This?
Reply With Quote
  #8 (permalink)  
Old May 3rd, 2005, 03:07 PM
Authorized User
 
Join Date: Apr 2005
Location: Spanish Fork, UT, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to DudeBori82 Send a message via MSN to DudeBori82
Default

I just used chart.data.Add(Chartpoint("String", FloatValue));
and it worked fine. They give a great startup help for C# on the website of the WebChart download.
Thanks for your help!!
Here is the final working code:
Code:
float fIncompletePercentage = (float)dIncompletePercentage;
            float fPassPercentage = (float)dPassPercentage;
            float fPassEffectivePercentage = (float)dPassEffectivePercentage;
            float fFailPercentage = (float)dFailPercentage;

            PieChart chart = new PieChart();
            chart.Data.Add( new ChartPoint("Incomplete", fIncompletePercentage) );
            chart.Data.Add( new ChartPoint("Pass", fPassPercentage) );
            chart.Data.Add( new ChartPoint("Pass (Effective)", fPassEffectivePercentage) );
            chart.Data.Add( new ChartPoint("Fail", fFailPercentage) );

            chart.DataXValueField = "Status";
            chart.DataYValueField = "Percent";
            chart.DataLabels.ShowValue = true;

            wcWebChart.Charts.Add(chart); 
            wcWebChart.RedrawChart();


The only thing now, is to figure out how do configure the color for each status (not use the default colors)...
Reply With Quote
  #9 (permalink)  
Old May 3rd, 2005, 03:14 PM
Imar's Avatar
Wrox Author
Points: 72,045, Level: 100
Points: 72,045, Level: 100 Points: 72,045, Level: 100 Points: 72,045, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,083
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You're welcome.

Yeah, the site comes with a lot of useful examples. Did you download the zip file with examples? It shows a lot of other cool tricks you can do with it....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Demo-stratie by Osdorp Posse (Track 12 from the album: Geendagsvlieg) What's This?
Reply With Quote
  #10 (permalink)  
Old May 3rd, 2005, 04:24 PM
Authorized User
 
Join Date: Apr 2005
Location: Spanish Fork, UT, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to DudeBori82 Send a message via MSN to DudeBori82
Default

found it!
Code:
chart.Colors = new Color[]{ Color.LightGray, Color.LightGreen, Color.Blue, Color.Red};
Actions are a direct result of your desires. Desire for good things.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create 3d pie chart Sunilmesu Pro Visual Basic 2005 1 April 30th, 2008 10:52 AM
3d pie chart Sunilmesu Pro Visual Basic 2005 0 April 30th, 2008 04:32 AM
Pie Chart jomet Pro JSP 2 March 10th, 2008 10:42 PM
Pie-Chart crmpicco Javascript How-To 2 February 10th, 2005 06:34 AM
Pie Chart lryckman Access 0 April 26th, 2004 11:44 AM



All times are GMT -4. The time now is 01:29 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.