The Artima Developer Community
Sponsored Link

.NET Buzz Forum
NSurvey - Pie Charts

0 replies.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a flat view of this topic  Flat View
Previous Topic   Next Topic
Threaded View: This topic has 0 replies on 1 page
David Cumps

Posts: 319
Nickname: cumpsd
Registered: Feb, 2004

David Cumps is a Belgian Student learning .NET
NSurvey - Pie Charts Posted: Feb 24, 2005 1:47 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by David Cumps.
Original Post: NSurvey - Pie Charts
Feed Title: David Cumps
Feed URL: http://weblogs.asp.net/cumpsd/rss?containerid=12
Feed Description: A Student .Net Blog :p
Latest .NET Buzz Posts
Latest .NET Buzz Posts by David Cumps
Latest Posts From David Cumps

NSurvey already provides general charts displaying the results, but it uses a bar chart and I had to output pie charts as well. So, I implemented them as well.

First, I created a new page, called PieChartReport.aspx, which was empty. After this I used the same code as the BarChartReport and filled up a ChartPointCollection, which I then used to create a new PieChart, render it and send it back to the client

 

ChartEngine engine = new ChartEngine();

ChartCollection charts = new ChartCollection(engine);     

           

engine.Size = new Size(350, 400);

engine.Charts = charts;

engine.Title = new ChartText();

           

if (questions.Questions[0].IsParentQuestionIdNull()) {

  engine.Title.Text = Server.HtmlDecode(

          Regex.Replace(questions.Questions[0].QuestionText, "<[^>]*>", " "));

} else {

  String questionText = String.Format("{0} - {1}",

                      questions.Questions[0]["ParentQuestionText"].ToString(),

                      questions.Questions[0].QuestionText);

  questionText = questionText.Replace(Environment.NewLine, "");

  questionText = questionText.Replace("\t", "");

  questionText = questionText.Replace("<p>", "");

  questionText = questionText.Replace("</p>", "");

  engine.Title.Text = Server.HtmlDecode(

                                 Regex.Replace(questionText, "<[^>]*>", " "));

}

 

PieChart pie = new PieChart(data);

engine.Charts.Add(pie);

ChartLegend legend = new ChartLegend();

legend.Position = LegendPosition.Bottom;

engine.HasChartLegend = true;

engine.Legend = legend;

engine.GridLines = GridLines.None;

 

 

Update: I used the following control by the way (which was already in NSurvey): http://www.carlosag.net/Tools/WebChart/Default.aspx

Read: NSurvey - Pie Charts


Topic: [RFC] Visualizing service interface contracts Previous Topic   Next Topic Topic: If I had $1500 to blow away

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use