- Home /
Pie graph with more than 2 different variables?
Hello, I'm trying to create a pie graph, with 3 different variables. I'm having a hard time figuring out how i would go about and do that. I'm trying to get it to work by lets say we have 3 variables, and all their values are 50. Then the circle in total would have 150, which then makes each part of the pie 33,3%. But what I want to do, let's say i add another 50 to just one of the variables, then in total i would have 200, but two variables only make up for 25% but the last variable makes up 50% of the circle. Is it possible to even create it? Edit: I'm not asking how to turn the numbers in to percents. But what technique I can use for drawing a Pie graph with more than just 2 different wedges.
Are you asking how to turn any three numbers into percents? Or are you asking what technique you could use to draw a three-color pie chart with any size wedges?
What technique are you using for a two-color (the overlapping 1/2-circle trick?) How have you tried to adapt that?
I mean the technique to draw a three-color pie chart. I've already looked at http://answers.unity3d.com/questions/14770/creating-a-circular-progressbar-timer.html Which I couldnt think of a way to implement. Or in a way so that it will work with more than just 2 wedges. (I'll just edit it so it's clear what i mean.)
Unity doesn't have like graphing and drawing API's hooked up, so are you wanting to do this in a GUI texture or 3D object?
Answer by DaveA · Mar 05, 2012 at 10:26 PM
If I understand you correctly, you just want to draw a 3-wedge pie graph. If you have Pro, look into using the GL glass. Otherwise, you may need to construct wedge meshes on-the-fly. If you're values are fairly quantized (like in increments of 10) you could pre-render them and then just pull up the image of the corresponding chart, but I wouldn't want to go down that path.
Look in the Scripting Reference at the Mesh class. You'll probably want to use high-school trig to figure out the pie vertices.
I've thinked about the $$anonymous$$esh class, (I don't have pro :P)I have no idea how I should build the mesh. I'm lucky that I'm learning trigonometry in school right now, so its a good way for me to learn it.
Unity Free lets you create meshes. The math is just simple sin/cosin stuff. But, you will want to be comfortable with using arrays.
But, that 1st link you posted seems like it would work for any number of pie slices (that is, once you got it for two, it should be simple to add a 3rd, 4th... .)
Answer by Uchiha Itachi · Mar 28, 2014 at 03:37 AM
Sounds not an easy problem. I am recently also during some studies on the UI chart component, which has the UI pie graph inside, it sounds convenient in using, it would be quite fine if it can be applied in Unity.
Your answer

Follow this Question
Related Questions
Is there a way to render a SkinnedMesh a second time with another material in a frame? 0 Answers
Getting Error "DrawGUITexture: Texture is Null" when using Graphics.DrawTexture in OnGUI() 2 Answers
Graphics.Blit or texture update how long to draw to entire screen? 0 Answers
How to call Graphics.DrawTexture() in Update 1 Answer
How to draw a Sprite on OnDrawGizmos() 0 Answers