Journal

Thoughts, ruminations, observations, and inspiration from theMechanism.

Easy legend generation for the Google Charts API map chart type

April 4, 2008 | Posted by Jeffrey Barke | 3 comments

In an earlier post, I wrote "I agree with Bjørn that the lack of an API-generated legend is problematic, though one could be constructed via HTML adjacent to the chart." However, it turns out that creating a legend is a bit more difficult than I initially thought. The difficulty was brought to my attention via a post to the Google Charts API Google Group that requested help in writing a PHP function to determine the hex value of interpolated colors. Since I figured this would be a common problem, I wrote a PHP 4 class that will hopefully solve it. You can see the tmMapLegend class in action below with the map produced in the earlier tutorial. Learn more about the class and download it here: http://themechanism.com/barkode/code/tmmaplegend/.

Red States and Blue States, USA

  •   States carried by the Republicans in all four elections
  •   States carried by the Democrats in all four elections
  •   States carried by the Republicans in three of the four elections
  •   States carried by the Democrats in three of the four elections
  •   States carried by each party twice in the four elections

Jeffrey Barke is senior developer and information architect at theMechanism, a maxi-media firm in New York City and London.

Spread the Love

del.icio.us:Easy legend generation for the Google Charts API map chart type digg:Easy legend generation for the Google Charts API map chart type spurl:Easy legend generation for the Google Charts API map chart type wists:Easy legend generation for the Google Charts API map chart type simpy:Easy legend generation for the Google Charts API map chart type newsvine:Easy legend generation for the Google Charts API map chart type blinklist:Easy legend generation for the Google Charts API map chart type furl:Easy legend generation for the Google Charts API map chart type reddit:Easy legend generation for the Google Charts API map chart type blogmarks:Easy legend generation for the Google Charts API map chart type Y!:Easy legend generation for the Google Charts API map chart type smarking:Easy legend generation for the Google Charts API map chart type magnolia:Easy legend generation for the Google Charts API map chart type segnalo:Easy legend generation for the Google Charts API map chart type

3 Comments So Far

Post a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Search the Archives
Feeds

Upcoming events

O'Reilly user group program member

Add to Technorati Favorites

We endorse

Basecamp

Want to work with us yet? We’re ready when you are.