« Credit Card Roulette, my first iPhone appMeasuring moods might make the moods being measured even richer »

Google Chart API enjoyment

There’s this little pie graph I want in my app that looks sorta like this:


Basically, it’s gonna be a stopwatch-like graph that tells you how much time is left for a particular food in a particular location.  In this case, the pie would represent 1 month left.  It’s convenient because there are 12 months in a year, 12 hours on a clock, etc.  I can color the pie slice differently when it’s nearing its “out of season” time (as is the case here, so the slice should be a red-ish color in the final deal).

Easy enough, right?  I told Matt, the guy who’s generously helping me design this, that I could make the pie charts with Google’s chart API.

The chart API takes data, like (1,11) to represent the amount that’s colored one color versus colored another.  But, unfortunately, the chart’s default orientation is at 3 o’clock.  To rotate the chart, you supply it with a number in radians.  So, after some research in radians, I determine that to rotate the slice 90 degrees clockwise, I give everything a radians of 4.712388975.

Unfortunately, that aligns the wrong side of the pie slice.  Making it look like this:


So, now I need to figure out how to rotate it to the a little bit less than the default offset.  Since I’m making one of these for each half-increment of a month, I’ll need 24 slices. So, each half month has its own correction of

1 radian * 15 (degrees) = 0.2617993875 radians

Each with a different radian correction to the offset.  Or, rather, for each increment,

(default offset) – ((half month correction from above) * (number of half months))

So now I figure this all out in a Google Docs spreadsheet.

And for some reason, I find the whole process highly enjoyable.


Also, now that I’ve got this spreadsheet open, I’m interested in using this information to help determine the colors used for each slice.  I have some colors that have been sampled from actual foods in nature and wonder how I might use math to simulate the changing colors of the season.

But I’m going to leave that for tomorrow because I want a drink right now.  I feel like I’m in that weird nerd limbo… nerdy enough to come up with a really convoluted way to get something really simple, and yet still not nerdy enough to come up with the really easy way to get something really simple.

10 Responses to “Google Chart API enjoyment”

  1. I was thinking about your UI problem. I think I would like to see horizontal stripes representing the seasonal year, one stripe per food, with a colored part that shows when they are in season, and a vertical line showing what time it is running through all of the stripes. Optionally you could have a “weeks left” label in the strips (or weeks until if out of season).

    I think the strength of this layout is that the user can, at a glance, see when certain foods are in season. E.g. they can use it as a reference rather than just a planner. It would also seem to be rather more compact that a pie chart!

  2. I do like that layout. I am using it for the website, but have had trouble adapting it to the smaller iPhone screen. It’s almost too much information, I think.

    I’ve moved to a more “stop watch” metaphor, showing you as if on a clock how much time is left for a particular item in season. I think it works, because of the coincidence of 12 hours and 12 months. And, in this case, I think less information is going to be easier and more useful to parse.

    But I will revisit this in a bit and see if it makes sense to users too.

  3. I love radians. And how certain methods of expression lead to different things attracted to and avoided.

    Can you get a pi constant in ObjC? Then you can have nicer looking constants like 1.5 * PI insead of 4.712388975, or PI/12 instead of 0.2617993875…

    (does google docs have a PI constant?) Then each half slice can be (pi / 12) radians. Or you can carry pi with you in the iphone since I’m sure ObjC will give you a pi.

  4. I’m not sure about getting a true pi in Objective C. I’m curious though, why do you love radians? Because they’re so weird?

  5. Ashutosh says:

    Does anyone have any idea of how to draw the charts/graphs on iPhone using the iphone API’s ?

    Basically my requirement is to have a CHART ENGINE to plot all kinds of charts/graphs such as
    line chart, pie chart, bar graphs & histogram etc.
    The graphs should have a very rich & nice graphics. Also i should have the granular control over the graphs elements (i.e. tapping on different area in graphs must display the data/navigate to the next view.)
    I am also ready to pay the charges for the CHART ENGINE.

  6. computer hardware reviews…

    [...]Enjoymentland » Google Chart API enjoyment[...]…

  7. goedkoop computer…

    [...]Enjoymentland » Google Chart API enjoyment[...]…

  8. iphone game…

    [...]Enjoymentland » Google Chart API enjoyment[...]…

  9. Or (with all the 608) you’ll be able to use those speakers being a stereo in another room.
    The online world has more resources and options than any brick and mortar electronics store may possibly possess.
    Tell your potential customers why you have recommended these systems.

  10. It takes only a few minutes to download and start using
    the program after you make your purchase. So why are celebrity pay cuts interesting news’ It’s
    not like us common folk feel sorry for them.
    There’s also a new updated version available for i – Phone users.