如何让 Google Charts 在散点图中显示多种颜色?
我想在 Google 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您只能在散点图中使用一个数据集,因此只能使用一种颜色。
http://code.google.com/apis/chart/#scatter_plot
< em>来自 API 描述:
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:
您可以使用带有白线和彩色形状的线图来有效地伪造多色散点图标记在您想要显示的点上。
You could effectively fake a multi-color scatter plot by using a line plot with white lines and colored shape markers at the points you want to display.
这是另一个示例:Twitter 图表。 我希望能做同样的事情。 需要找出如何做同心圆。
Here's another example: twitter charts. I'm hoping to do the same thing. Need to find out how to do the concentric circles.
在等待几秒钟的答案后,我回答了我自己的问题:-)
您确实可以为不同的数据元素设置不同的颜色。 例如:
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
chm= 发挥了魔力。 我试图有多个 chm= 语句。 您只需要一个,但有多个描述,并用竖线分隔。
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.