|
|
 |
| 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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

May 2nd, 2005, 05:20 PM
|
|
Authorized User
|
|
Join Date: Apr 2005
Location: Spanish Fork, UT, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|

May 2nd, 2005, 05:35 PM
|
 |
Wrox Author
Points: 33,170, Level: 79 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,161
Thanks: 7
Thanked 188 Times in 186 Posts
|
|
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.
|

May 2nd, 2005, 05:38 PM
|
|
Authorized User
|
|
Join Date: Apr 2005
Location: Spanish Fork, UT, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|

May 2nd, 2005, 05:47 PM
|
 |
Wrox Author
Points: 33,170, Level: 79 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,161
Thanks: 7
Thanked 188 Times in 186 Posts
|
|
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.
|

May 2nd, 2005, 05:59 PM
|
|
Authorized User
|
|
Join Date: Apr 2005
Location: Spanish Fork, UT, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hey, this looks like it. I'll check it out.
Actions are a direct result of your desires. Desire for good things.
|

May 2nd, 2005, 06:21 PM
|
|
Authorized User
|
|
Join Date: Apr 2005
Location: Spanish Fork, UT, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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#?
|

May 3rd, 2005, 04:01 PM
|
 |
Wrox Author
Points: 33,170, Level: 79 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,161
Thanks: 7
Thanked 188 Times in 186 Posts
|
|
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?
|

May 3rd, 2005, 04:07 PM
|
|
Authorized User
|
|
Join Date: Apr 2005
Location: Spanish Fork, UT, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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)...
|

May 3rd, 2005, 04:14 PM
|
 |
Wrox Author
Points: 33,170, Level: 79 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,161
Thanks: 7
Thanked 188 Times in 186 Posts
|
|
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?
|

May 3rd, 2005, 05:24 PM
|
|
Authorized User
|
|
Join Date: Apr 2005
Location: Spanish Fork, UT, USA.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is 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 11:52 AM |
| 3d pie chart |
Sunilmesu |
Pro Visual Basic 2005 |
0 |
April 30th, 2008 05:32 AM |
| Pie Chart |
jomet |
Pro JSP |
2 |
March 10th, 2008 11:42 PM |
| Pie-Chart |
crmpicco |
Javascript How-To |
2 |
February 10th, 2005 06:34 AM |
| Pie Chart |
lryckman |
Access |
0 |
April 26th, 2004 12:44 PM |
|
 |