可能重复:
Can someone help me create a simple vertical bar chart using google charts?谷歌图表工具 - 如何创建堆积条形图
进出口使用谷歌新的图表工具,我想创建堆叠条形图格式。
可能重复:
Can someone help me create a simple vertical bar chart using google charts?谷歌图表工具 - 如何创建堆积条形图
进出口使用谷歌新的图表工具,我想创建堆叠条形图格式。
的谷歌开发者网站上提供了有关条形图格式的一些细节:https://developers.google.com/chart/interactive/docs/gallery/barchart
要进行正常的条形图堆积,需要用户isStacked: true
选项。您可以复制并粘贴以下代码到图表工具操场上看到一个工作示例: 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}
);
}
您可能也有兴趣在一个堆积面积图,这取决于您要显示的数据。
还有一个问题,这给使用图表工具图像API堆积条形图的例子:Bar chart in Javascript: stacked bars + grouped bars
需要注意的是谷歌图表工具的图片图表部分,2012年4月20日,正式弃用。根据Google的弃用政策,图片图表仍然可以使用一段时间,但我建议您专注于上述交互式HTML5 + SVG实施。
谢谢,丹尼尔。 –
它不重复 – amleczko