Dan*_*iel 28
Google Developers网站提供了条形图格式的一些详细信息:https://developers.google.com/chart/interactive/docs/gallery/barchart
要使正常条形图堆叠,您需要使用该isStacked: true选项.您可以将以下代码复制并粘贴到"图表工具"操场中,以查看工作示例:http:
//code.google.com/apis/ajax/playground/?type = visible
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}
);
}
Run Code Online (Sandbox Code Playgroud)
您可能还对堆积区域图表感兴趣,具体取决于您要显示的数据.
还有一个问题,它使用图表工具图像API给出了堆积条形图的示例:Javascript中的条形图:堆积条形图+分组条形图
请注意,Google图表工具的图片图表部分已于2012年4月20日正式弃用.图片图表仍将按照Google的弃用政策运行一段时间,但我建议您专注于上述交互式HTML5 + SVG实施.
| 归档时间: |
|
| 查看次数: |
33791 次 |
| 最近记录: |