Google Chats

Google 图表 API 使您可以动态生成图表。要查看图表 API 的运行情况,请打开浏览器窗口,并将以下网址复制到其中:

http://chart.apis.google.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World

按下 Enter 键或回车键,即刻您就会看到以下图片:

黄色饼图


Google 图表 API 网址必须为以下格式:

http://chart.apis.google.com/chart?<parameter 1>&<parameter 2>&<parameter n>

注意:每个网址必须完全在一行中。

使用和号 (&) 字符对参数加以分隔。您可以按任意顺序指定任意数量的参数。例如,图表 API 会返回以下图表来响应下面的网址:

黄色饼图

http://chart.apis.google.com/chart?
chs=250x100
&chd=t:60,40
&cht=p3
&chl=Hello|World

其中:

  • http://chart.apis.google.com/chart? 是图表 API 的位置。
  • & 用于分隔参数。
  • chs=250x100 是图表的大小(以像素为单位)。
  • chd=t:60,40 是图表的数据。
  • cht=p3 是图表的类型。
  • chl=Hello|World 是图表的标签。

通过将网址嵌入 <img> 标签内,您可以将图表 API 图片包括在 HTML 文档中。例如,以下 <img> 标签会生成与上文相同的图片:

<img src="http://chart.apis.google.com/chart?
chs=250x100
&amp;chd=t:60,40
&amp;cht=p3
&amp;chl=Hello|World
"
alt="Sample chart" />

注意:您在 HTML <img> 标签中嵌入网址时,请注意要使用字符实体参考 &amp; 来代替和号 (&)。


Google Chat 的详细API 请阅读 http://code.google.com/intl/zh-CN/apis/chart/

posted @ 2009-06-02 19:44  _拖鞋_  阅读(296)  评论(0编辑  收藏  举报