我有一个谷歌图表,显示我房间的压力值。图表中有几个问题
然而,图表行似乎是正确的,因为我认为它有一些起伏。
如何正确格式化vAxis和工具提示?
这是我正在使用的代码
<script type="text/javascript">
google.load('visualization', '1.1', {packages: ['line']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('datetime', 'Timestamp');
data.addColumn('number', 'pressure');
data.addRows([
[new Date('2015-11-19 18:26:05'),95245],[new Date('2015-11-19 18:19:07'),95186],[new Date('2015-11-19 18:19:06'),95186],[new Date('2015-11-19 18:12:05'),95152],[new Date('2015-11-19 18:05:53'),95151],[new Date('2015-11-19 17:58:04'),95172],[new Date('2015-11-19 17:51:04'),95152],[new Date('2015-11-19 17:44:04'),95141],[new Date('2015-11-19 17:37:04'),95111],[new Date('2015-11-19 17:30:04'),95102],[new Date('2015-11-19 17:26:04'),95112],[new Date('2015-11-19 17:19:05'),95064],[new Date('2015-11-19 17:12:04'),95042],[new Date('2015-11-19 17:05:04'),95027],[new Date('2015-11-19 16:58:04'),95032],[new Date('2015-11-19 16:51:04'),95045],[new Date('2015-11-19 16:44:05'),95042],[new Date('2015-11-19 16:37:05'),95016],[new Date('2015-11-19 16:30:05'),94990],[new Date('2015-11-19 16:26:04'),94995],[new Date('2015-11-19 16:19:04'),94985],[new Date('2015-11-19 16:12:04'),94969],[new Date('2015-11-19 16:05:04'),94955],[new Date('2015-11-19 15:58:04'),94949],[new Date('2015-11-19 14:50:18'),94987] ]);
var options = {
chart: {
title: 'abasingama_a1',
subtitle: 'Unit - Pa',
pointSize: 30
},
width: 800,
height: 300,
vAxis: { minValue: 95450, maxValue: 95550 },
pointSize: 30,
};
var chart = new google.charts.Line(document.getElementById('line_top_x'));
var formatter = new google.visualization.NumberFormat({pattern:'0.0e00'});
formatter.format(data, 1);
chart.draw(data, options);
}
</script>
答案 0 :(得分:1)
您需要在图表的图形中使用<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
转换选项。
google.charts.Line.convertOptions
应该是
chart.draw(data, options);
然后它就像你期望的那样工作
我会尝试使用chart.draw(data, google.charts.Line.convertOptions(options));
来实现您正在寻找的目标。