Google图表工具 - 如何创建堆叠条形图 [英] Google Chart Tools - How to create stacked bar chart

查看:834
本文介绍了Google图表工具 - 如何创建堆叠条形图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

我使用新的Google图表工具,我想创建堆叠条形图格式。

Im using new Google Chart Tools, and I want to create stacked bar chart format.

推荐答案

Google Developers网站提供了有关条形图格式的一些详细信息: https://developers.google.com/chart/interactive/docs/gallery/barchart

The Google Developers site gives some details on the bar chart format: https://developers.google.com/chart/interactive/docs/gallery/barchart

为了使标准条形图堆叠,您需要用户 isStacked:true 选项。您可以将以下代码复制并粘贴到图表工具操作区中,以查看工作示例:
http://code.google.com/apis/ajax/playground/?type=visualization

To make a normal bar chart stacked, you need to user the isStacked: true option. You can copy and paste the following code into the Chart Tools playground to see a working example: http://code.google.com/apis/ajax/playground/?type=visualization

function drawVisualization() {
  // Create and populate the data table.
  var data = google.visualization.arrayToDataTable([
    ['Year', 'Austria', 'Bulgaria', 'Denmark', 'Greece'],
    ['2003',  1336060,    400361,    1001582,   997974],
    ['2004',  1538156,    366849,    1119450,   941795],
    ['2005',  1576579,    440514,    993360,    930593],
    ['2006',  1600652,    434552,    1004163,   897127],
    ['2007',  1968113,    393032,    979198,    1080887],
    ['2008',  1901067,    517206,    916965,    1056036]
  ]);

  // Create and draw the visualization.
  new google.visualization.BarChart(document.getElementById('visualization')).
      draw(data,
           {title:"Yearly Coffee Consumption by Country",
            width:600, height:400,
            vAxis: {title: "Year"},
            hAxis: {title: "Cups"},
            isStacked: true}
      );
}

您可能还对Stacked Area Chart感兴趣,

You might also be interested in a Stacked Area Chart, depending on what data you are trying to display.

还有一个问题,它提供了一个使用Chart Tools Image API的堆叠条形图的示例: JavaScript中的图表:堆叠栏+已分组栏

There is also a question which gives an example of a stacked bar chart using the Chart Tools Image API: Bar chart in Javascript: stacked bars + grouped bars

请注意,Google图表工具的图片图表部分已于2012年4月20日正式弃用。根据Google的弃用政策,图表仍会工作一段时间,但我建议您专注于交互式HTML5 + SVG实施

Note that the Image Charts portion of Google Chart Tools was officially deprecated on the 20th April, 2012. Image charts will still work for a while as per Google's deprecation policy, but I recommend you concentrate on the interactive HTML5+SVG implementation described above.

这篇关于Google图表工具 - 如何创建堆叠条形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆