【发布时间】:2015-12-09 16:01:29
【问题描述】:
长期以来,我一直在尝试简单地在下图中旋转我的 hAxis。尝试了下面解释的几种解决方案!不敢相信这么简单的事情似乎很难做到。源码如下:
<html>
<title>VM Allocation Performance</title>
<meta http-equiv="refresh" content="30">
<head>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["bar"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['09/12/2015 10:00:00',3.52],['09/12/2015 10:30:00',7.56],['09/12/2015 11:00:00',8.99],['09/12/2015 11:30:00',4.93],['09/12/2015 12:00:00',10.26],['09/12/2015 12:30:00',9.82],['09/12/2015 13:00:00',12.62],['09/12/2015 13:30:00',9.07],['09/12/2015 14:00:00',4.94],['09/12/2015 14:30:00',8.98],['09/12/2015 15:00:00',7.85],['09/12/2015 15:30:00',3.59],['09/12/2015 16:00:00',5.64]],true);
var options = {
chart: {
title: 'VM Allocation',
subtitle: 'Since Shift Start',
}
//I tried with slantedText: true here but while my graph was rendering, labels were not rotated!
};
var chart = new google.charts.Bar(document.getElementById('chart_div'));
chart.draw(data, google.charts.Bar.convertOptions(options));
}
</script>
</head>
<body>
<div id='chart_div' style='width: 450px; height: 400px;'></div>
</body>
</html>
这是我目前尝试过的:
我阅读了 Google 文档,相应地更改了我的代码(因为它是一个“材料”图等...),但仍然没有。
我尝试使用与我发现的 jsfiddle 相同的 hAxis 块,但没有运气。
我详细介绍了一些细节,并在Google doc 上看到选项“slantedText”只能在离散轴上工作,所以我想我必须将我的 hAxis 类型从日期/时间更改为字符串,我试过了没有成功。
我继续尝试使用 SO 的 this 解决方案,虽然我仍然可以渲染图表,但我的日期/时间标签仍未完全显示(这就是我想旋转它们的原因)。
有人可以帮忙吗?
【问题讨论】:
标签: javascript html graph google-visualization axis