Home | About | Log in | Get The Feed
Holiday Goodies – Google Chart API Challenge Charts Explained Part 1

December

19

2007

Ok, so about ten days ago I challenged my readers to solve the following charting problems with the Google API – Bullet Chart, Sparkline and Square Pie. I provided a sample bullet chart but asked if anyone could improve upon it. Unfortunately, only one brave soul, Jeff Donnici, took up the challenge and provided two solutions for Sparklines.

I am inviting Jeff to write his own discourse on how to create sparklines with the Google API, so Jeff, please email me (my email is at the bottom of the right-hand nav) with your description of how to create the sparklines.

 

First, let’s cover some basics of the API.

The API is pretty simple, it’s just a URL with a bunch of query parameters attached to define the chart and its elements. It can also be a bit annoying when you’re encoding the data sets and their associated information. My guess would be that to really get the power out of the API you would want some sort of programmatic interface to it as building the chart request ‘by hand’ can be laborious.

So, components that are used in these examples:

For me, let’s start with the Bullet Chart. The stumbling blocks here are that

  1. The Google Chart API does not support combination charts, or at least not a bar chart / scatter plot combo, which is how I create Bullet Charts in Excel.
  2. The API does not seem to support single data point properties. In other words, I can set the color and width properties for the stack (e.g. series) but not for data points in the stack.

If you remember the Excel example of the Bullet chart, you will recall that we have 3 data series (top, middle, bottom) each with 4 data points to create the basic visualization of the Bullet chart. We then combine into that chart a scatter plot to create the target line. Well this API doesn’t support coloring for a single data point (which is required in the Excel solution) so what does Google offer as a replacement? Well, with the background fill, we can go a linear stripe that will take up some percentage of the chart space – ok, I think I can work with that:

But first things first. Let’s define the chart type:

http://chart.apis.google.com/chart?cht=bhs

  • cht=bhs tells Google that we are working with a horizontal bar chart

 

Next, let’s set the chart size

http://chart.apis.google.com/chart?cht=bhs&chs=250×40

  • Remember, chs wants [width]x[height] in pixels and it’s required

 

While we’re at it, lets go ahead and set the bar width (or height if you prefer)

http://chart.apis.google.com/chart?cht=bhs&chs=250×40&chbh=10,25

  • chbh lets us define that bar width and optionally the spacing between bars. In this example the gap is set to 25 to make sure that the chart fill area shows up around the bar itself.

 

Ok, for the last of the easy bits, let’s go ahead and set the Chart title

http://chart.apis.google.com/chart?cht=bhs&chs=250×40&chbh=10,25&chtt=Homepage+Retention+Rate:+90%

  • Note the plus (+) symbols in the Chart Title text, this tells the API to use a blank space when creating the title

 

On to the data. As noted above, there are 3 options for encoding data – simple, text, and extended. I haven’t really figured out why you would use simple because it’s basically a substitution scheme that feels more annoying than anything. However, in this example we are using text encoding because it allows us to use regular numbers with up to 1/10th precision.

http://chart.apis.google.com/chart?cht=bhs&chs=250×40&chbh=10,25&chtt=Homepage+Retention+Rate:+90%&chd=t:90.0

  • when adding the chart data, you must first tell chd how you are encoding the data (chd=t) and then supply the data itself (:90.0)

The above gives us a basic bar chart:

Now we need to add the elements that will make this look like a Bullet chart and we’re going to get it all done with chart fill!

http://chart.apis.google.com/chart?cht=bhs&chs=250×40&chbh=10,25&chtt=Homepage+Retention+Rate:+90%&chd=t:90.0&chf=c,ls,0,000000,0.50,cccccc,0.25,000000,0.005,efefef,0.245

chf (chart fill) takes the following arguments:

  • fill area: background (bg) or chart area (c), in the Bullet chart, we use the chart fill method
  • fill type: solid (s), linear gradient (lg), and linear stripes (ls)
  • angle: angle of the stripe between 0 (horizontal) and 90 (vertical)
  • stripe color and width pairs: color hex value and length expressed as a percentage

If you look at the URL snippet above in bold, you will see that we have defined

  • the background element as "chart fill" (c)
  • the fill type as "linear stripe" (ls)
  • the "angle" as zero
  • The first section is black and extends to 25% of the length
  • The second fill section is the same as the first
  • the third section is also 25% but is a dark gray
  • the fourth section, only 1/2 of 1 percent in width is black – It’s a trick, this is the target line!
  • The last section is 24 & 1/2 percent of the length and is a very light gray

 

That’s it, now we have a functioning bullet chart

I sure wish that I could remove the axes lines, and add data labels to the bar and target line, but oh well.

Ok, I need to take a break as this is quite a long post. In part 2, we will walk through the pie chart solution (which is not that great),

By: Clint | Posted in bullet charts, charts, google, sparklines, visualization | Tagged: , , , | Comments Off

prednisone buy cod watson brand order prednisone on line Cytotec shipped over night without a perscription buy pharmacy Orlistat waterview buy 40 mg accutane online without prescription Valtrex espana buy Nizoral Online order generic Crestor generic finasteride buy 10 mg Accutane precio cytotec online cheap cytotec from mexico buy Premarin no prescriptions order Valtrex without a prescription overnight shipping Valtrex bestellen accutane in Canada purchase 10mg accutane 40 mg overnight delivery buy synthroid mail buy order prescription free Buspar buy zithromax no scams order no prescription Flomax Orlistat on line buy Amitriptyline without doctor Amitriptyline online order saturday delivery purchase Crestor pay pal without rx generic finpecia online finpecia usa order Crestor uk buy genuine Buspar best buy valtrex comprar Crestor generico buy cheap Zithromax order buy Zithromax online where can i purchase Buspar no rx buy online without a prescription cheap Cytotec buy Zovirax no visa without rx buy no perscription Buspar Accutane overnight delivery fed ex Xenical cash on delivery no rx Flomax with fedex purchase Premarin cod overnight delivery generic valtrex new zealand Zithromax cheap no rx required canada buy no perscription Valtrex cost of valtrex buy Crestor on line buy Orlistat without rx order Zithromax without a rx overnight shipping purchase Xenical over the counter cod overnight order Xenical uk online purchase Valtrex buy Zithromax without doctor no prescription required for prednisone canadian prescriptions Accutane purchase Buspar without a prescription online Crestor price online Crestor order buy xenical without prescription buy prednisone online without script buy prednisone without rx needed buy Proscar offshore no prescription fedex buy Valtrex us buy Xenical shipped cod online prescription Flomax Buy xenical online with next day shipping Accutane ordering without a dr purchase Accutane no scams Valtrex best buy where to buy generic Flomax online without a prescription prednisone online overnight delivery cod buy Valtrex and Valtrex where to purchase generic finasteride online without a prescription buy generic Crestor online purchase online prescription Valacyclovir order overnight Zithromax order finasteride order amex Amitriptyline by mail Zithromax purchase Premarin without buy Proscar 5 mg generic Crestor prices Crestor precio buy cheap Orlistat on line where can i buy Orlistat online without a prescription purchase cheap online prednisone gjdfnvn jsfu ufnqfkqwfnsdkbgv gwjebgnask sndfiqahwfb qkwfn gnjsdbgjsdngjkl nsdjkgj wo gndfjgnkdfjb dfghdfjkghdfl jg dflgjdfklg wgnjk begjn weghwuoegn gjouihbfbwyqfd ngjnwekjgn jkwebngjk wenkg g][qwol]flwe fpwehfuiqwgbfi 9ewrupgohnasfwef[igerpgj wkgpirhgnsdfmwio3tui gehnguywefgwejkg wjfuoqbfvb sdfhsdhfuiqwgfdn gkl df dfgn jkdfbngwbewevhjvwef fdjgndfjkgnk gdfklgndfjn gjkdf gjkdfhgjkdfng gujbfkjgn asfjkqwopfhbjg jfksdmnf gnwegnkj bwgbsdf jkgbdjkg oiwgkwoehfuhndsf wuefwefbjk fgighoerngsdm sifjqweiofh ng jkfv,mznkqwifhoeiwf gmerng w opefgsmgknv mbnx b iquwhbjkbsdfb sdfgjerhre Cytotec online prescription fedex Cytotec overnight without a prescription uk Prednisone generic gdfjgjkldfngjn dfgdfkgkldf kgnwejkbgk nsdmdfjkgn dfjkgn kdfgn dfjkg sdfgdfj df gjdfijgdf jgkldf kwegwoe sdofkosdf Buy xenical online without a prescription Buy xenical online perscription uk order Nizoral achat Buspar order Prednisone usa where can i get prednisone without a prescription what is Prednisone what is valtrex used for buy cheap Xenical under without rx buy Orlistat without a credit card order prednisone without a rx overnight shipping buy in Valtrex uk buy discount Finasteride online prednisone with no perscription overnight shipping Where to buy finasteride no perscription no fees buy Prednisone without a credit card buy Prednisone cheap without prescription Proscar from canada 120 mg xenical xenical online purchase order no online rx Flomax buy prednisone prednisone buy online without rx buy prednisone online without a prescription buy Cytotec quantity where can i buy herbal Zovirax buy Valtrex in mo buy Valtrex pills in toronto prednisone over the counter Xenical best buy buy Cytotec no prescription low cost cheap maxalt online no prescription purchasing Maxalt online without prescription buy generic Crestor canada Rosuvastatin overnight accutane 30 mg without prescription order Accutane on line buy Flomax amex