您好我有这样的Google Visualization Line图表......
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", { packages: ["corechart"] });
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Week');
data.addColumn('number', 'Points');
data.addRows([['12/26/2011 12:00:00 AM', 0], ['1/2/2012 12:00:00 AM', 0], ['1/9/2012 12:00:00 AM', 0], ['1/16/2012 12:00:00 AM', 0]]);
var options = {
width: 800, height: 400,
hAxis: {title: 'Week'},
vAxis: {title: 'Points', minValue: 0, baseline: 0},
title: 'Activity'
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
<div id="chart_div"></div>
如何将垂直轴设置为从0开始(现在从-1开始并转到1)(我的垂直轴值始终> 0)。它们也总是自然数,我怎样才能使垂直轴只显示刻度上的自然数(无分数)? 谢谢, 波格丹
答案 0 :(得分:2)
var options
中,您可以添加:
vAxis: {
viewWindowMode: 'explicit',
viewWindow: {
//max: 8000,
min: 0,
},
gridlines: {
count: 18, //set kind of step (max-min)/count
}
}