Dynamic Pie Charts with Corona SDK Graphics 2.0

Following up on a topic in the CoronaLabs forums, we got interested in making an helper function to easily create pie charts for business apps (or any other use one might find them!)

We wanted something relatively lightweight (business apps usually do not require a ton of optimization), that made use of as few display objects as possible, while being completely customizable and still looking good.
One of the main issues with it was that the vector shapes created looked jaggy (due to lack of proper antialiasing).
Fortunately, Corona SDK Graphics 2.0 allows us to make our own AA implementation using fill on strokes, and this is the final result:
Schermata 2014-02-07 alle 23.59.41

 

 

 

 

 

 

Let’s take a look at how this library can be used to create a new pie chart.

As you can see, we can pass a data table containing the final radius that we want our pie to have and another table containing data for each one of the slices (just make sure that all the percentages add up to 100).
The result is a group object, containing our slices. This also means that you can loop through the slices like you would loop through objects in a group, and use that to customize your pie even more.

You can get this library here

 

3 Comments

  1. Hey, Would love to see this… I am runnng Windows simulator, Build:2100 (free)…not running. Must be a fresh build library.

    Looking forward to seeing it when my Simulator catches up. Cheers,

    • Hi Jason,
      what error are you getting exactly?