Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get Google Charts to display multiple colors in a scatter chart?

I would like to display multiple colors (and potentially shapes and sizes) of data points in a Google Chart scatter chart. Does anyone have an example of how to do so?

like image 486
Kent Beck Avatar asked Sep 16 '08 21:09

Kent Beck


People also ask

How do I add color to a Google chart?

Changing the Color You can change the color of the lines that connect data points in Google Charts in two subtly different ways: with the colors option to change the chart palette, or with the series option to specify the color for particular series. In the following chart, we set the color of each series explicitly.

How do you make a scatter graph on Google?

Select Insert > Chart on the toolbar, choose Scatter Plot in the Insert Chart window and click OK. It will provide you with a pre-made scatter plot.


2 Answers

I answered my own question after waiting SECONDS for an answer here :-)

You can indeed have different colors for different data elements. For example:

http://chart.apis.google.com/chart?chs=300x200&cht=s&chd=t:1,2,3|6,5,4&chds=1,3,0,10&chxt=x,y&chxl=0:|0|1|2|1:|0|10&chm=d,ff0000,0,0,8,0|a,ff8080,0,1,42,0|c,ffff00,0,2,16,0

It's the chm= that does the magic. I was trying to have multiple chm= statements. You need to have just one, but with multiple descriptions separated by vertical bars.

like image 52
Kent Beck Avatar answered Sep 18 '22 11:09

Kent Beck


You can only use one dataset in a scatter plot, thus only one color.

http://code.google.com/apis/chart/#scatter_plot

From the API description:

Scatter plots use multiple data sets differently than other chart types. You can only show one data set in a scatter plot.

like image 27
davethegr8 Avatar answered Sep 21 '22 11:09

davethegr8