-2

I'm making a questionnaire that shows results as charts I have decided to have the questionnaire write the results in an text f file when the user submits and want to read the file in and then assign the values to a pie chart I have all this done apart from the pie chart and am sort of struggling with it and help is greatly appreciated thank you.

TaW
  • 53,122
  • 8
  • 69
  • 111
  • 1
    What is your dispaly technology? It massively changes how to go about this. WinForms, WPF/UWP, XNA, ASP.Net, other? – Christopher Apr 21 '18 at 12:46
  • Thanks for the fast reply I am using WinForms. – Shawn596 Apr 21 '18 at 13:03
  • So you can read all the lines in the file and each has what? a number, two numbers, a number and a text? MSChart can create nice Pie charts very simply, but you still need to show us some more effort.. You may want to study [some](https://stackoverflow.com/search?q=user%3A3152130+pie) of the many examples here on SO.. – TaW Apr 21 '18 at 13:15
  • It will be reading in a single number for each slice of the pie chart. Thank you both for your help I'm quite a novice at programming – Shawn596 Apr 21 '18 at 13:23
  • Ok, this numbers should be the y-values of the dataopints you add to the Series.Points collection of an MSChart. But don't you want some kind of legend to the numbers? – TaW Apr 21 '18 at 13:26
  • Here is a minimal example: `Series s = chart1.Series[0]; s.ChartType = SeriesChartType.Pie; s.IsValueShownAsLabel = true; s["PieLabelStyle"] = "Outside"; string filePath = @"yourdatafilepath.txt""; var data = File.ReadAllLines(filePath); foreach (var item in data) { int pt = s.Points.AddY(item); s.Points[pt].LegendText = "point # " + pt; }` – TaW Apr 21 '18 at 13:39

1 Answers1

-1

The most "vanilla" solution is to draw a image and host it in a PictureBox. But drawing a Pie Chart Image by code is far from easy. It goes a bit to deeply into image drawing for the average programmer.

If you want a simple solution with a prexisting control element, you have to add some 3rd Party Libraries to your setup. The DevExpress and Infographics libraries both have PieChart controls:

So you can pick your pioson.

Christopher
  • 9,634
  • 2
  • 17
  • 31
  • Wrong. Hardly. Surely not. Wrong. Shrug. Typo. – TaW Apr 21 '18 at 13:41
  • @TaW: WHAT? Please try full sentences. I still have not developed any psychic abilities, so I am dependant on what you write. – Christopher Apr 21 '18 at 14:29
  • I have commented on the six sentences of your post. – TaW Apr 21 '18 at 14:57
  • @Taw: The sad part is, had you just written "Actually there is MSChart and it supports Pie Charts" it would have been less writing, less work, less confusion and you might even have gotten an Upvote from me. – Christopher Apr 21 '18 at 17:13
  • That is exactly what I wrote. In my comments to the question. I have even included the full code needed to load the pie chart. Your post, while well-meaning is simply wrong on all the points you make. But I admit, my comment to you was rather terse and confusing. Sorry about that. – TaW Apr 21 '18 at 18:22