Jump to content

How to create a pie chart


Recommended Posts


I would like to create a dynamic pie chart. Let's say something like this 


What would be the best approach? In the outcome I would like to receive separate meshes to be able to select one of them, add animation, change material and so on. I tried with csg with a cone made of cylinder but I would like to switch to something simpler.

Link to comment
Share on other sites

Sounds like a fun challenge if no one else gets on it I'll whip up a demo here for that, it would not be that hard if you know how to extrude custom shapes and how to work pi calculations.   


If if I have time tommrow I'll make a function with arguments for the slices so you can just call one thing.

Link to comment
Share on other sites


I was going to do a version with extrudes if I can, but I only had like 30 min's to do this trying to get it done before my girlfriend finishes dinner cause i promised Id pay her attention.

If I can pump that out really fast before she is done I will but I figured this will at least get you going for now.

***Edit beat her to it, but um it does not work... something is up with the extrude I only used them for  a limited time way back im not sure if this is the correct way to construct an extrude now, but once someone who knows better can chime in this is how a solid shape from that function would be done.

@RaananW or maybe @Wingnut could comment on why the extrudes are not coming up but the paths work.

You might even be able to figure it out if you read the section on parametric shapes http://doc.babylonjs.com/tutorials/parametric_shapes
I just do not have time as of right now.  Sorry to get back to you so late today was busy busy busy.
also on a quick note I mentioned how you can make the gaps smaller between slices, if you like the effect you can leave it or do what i said in the comments, another option would be to add 0.5 to the 2nd to last point i think and subtract 0.5 from the 2nd point when generating the slicepaths from the j interval.

If I get some more time ill refine it for you and push a module to the BJS git with a new BAYLON constructor if approved.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...