我想画一张图表,其中x轴是日期。
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
var data = new google.visualization.DataTable();
data.addColumn('string', 'x');
data.addColumn('number', 'history');
data.addRows([
[{v: 1, f:'11-05-2010'}, 10],
[{v: 2, f:'11-05-2011'}, 20],
[{v: 3, f:'11-05-2012'}, 34],
[{v: 4, f:'11-05-2013'}, 48]
]);
var options = {
title: '<?php echo $strings["updates_task"]; ?>',
legend: 'none',
lineWidth: 2,
hAxis: { minValue: 0, maxValue: 9 },
vAxis: {
minValue: 0,
gridlines: {
color: 'none',
count: 5
}
},
colors: ['#FF0000'],
pointSize: 10,
pointShape: 'square',
width:1200,
height:500
};
var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));
chart.draw(data, options);
}
当我使用x作为字符串时,显示日期但不显示垂直线。
当我使用x作为数字时,显示垂直线,但在日期显示2.5,5,7.5。但我想展示两者。我怎么能同时显示?