Old Google Charting API: tools for still using them
Posted by jpluimers on 2016/11/10
While mocking the ScaleMM documentation, I bumped into a chart that I thought was an image, but is in fact generated by the (now deprecated) Image Charts API from Google.
In fact it is generated on the fly from a URL: http://chart.apis.google.com/chart?chxr=0,0,16|1,0,14682…&nonsense=something_that_ends_with.png
Compare the two below. They are identical (:
|
Static ScaleMM1 comparison chart |
![]() URL based ScaleMM1 comparison chart |
Even though the API is deprecated Google has no plans to turn it of, so it still works and is the easiest way to get charts into a Markdown or reStructuredText document.
In practice, it doesn’t matter if you use the chart.apis.google.com or chart.googleapis.com domain: they give the same results the same.
As I wanted to convert the results.txt to a chart, I dissected the above URL, looked up the definitions of the URL parameters (the trickiest: cds for lxy graphs and the combination of chds and chxr, easier: chls) and created a new URL for the chart below.
Notes:
- The number of entries chds and chdl must be the same.
- The number of entries in chds and chdl must match the number of lines in cds.
- The chxr axis start/end values must match the ones in chds.
- I let the axis start at 1 (not 0) as a zero-thread application is kind of useless.
- I increased the height to be twice the previous one as both JemallocMM and JemallocFFMM perform so badly.
- The undocumented parameter suffix nonsense=something_that_ends_with.png is absolutely essential: it is ignored by the API, but used by the Markdown to HTML conversion to recognise the image type (PNG) which the API generates so the browser can use the image to get width/height information.
The chart: it continuous to scale in the same linear way as the previous measurements.
![]() Static SimpleChallenge comparison chart |
![]() URL SimpleChallenge comparison chart |
I hand picked the line colours (avoiding black and white) from Ssnot!: Kmeans++ Color Quantization seeding which does not take into account Color Universal Design (CUD) / Colorblind Barrier Free and does not work that well on a white background.
–jeroen
references:
- Dynamically generate charts with a URL string.
- Deprecated chart wizard.
- Create a Google Chart quickly and easily. This Google Chart generator is easy to use and can be used to create beautiful charts fast.
- Alternative for the deprecated chart wizard.
- Explanation of the Image Charts.
- Parameters in the charts URL.
- Example of a SQL query resulting in a Charts URL.
- I need large set (20 and more) of contrasted and easily visually-distinguishable colors for coloring different datasets on a scientific plot.
- List of contrasting colours.
- Set of colors that is unambiguous both to colorblinds and non-colorblinds









Leave a comment