我正在尝试使用Google创建折线图,并且希望启用缩放选项。要显示在图表上的数据存在于MySQL数据库中。 当我尝试使用“资源管理器”选项时,该图仅在y轴上放大,而在x轴上没有放大。 这是我的代码:
<?PHP
define ("mysqli_host", "localhost");
define ("mysqli_username", "root");
define ("mysqli_password", "");
define ("mysqli_db", "db");
$con = mysqli_connect (mysqli_host, mysqli_username, mysqli_password, mysqli_db);
$query_aggiorna = mysqli_query ($con, "SELECT * FROM smst02 WHERE id >= 201 AND id <= 300 ORDER BY id");
$table1['cols'] = array (
array('label' => 'ora', 'type' => 'string'),
array('label' => 'ch3', 'type' => 'number')
);
$row1 = array();
if ($query_aggiorna)
{
while ($r1 = mysqli_fetch_assoc($query_aggiorna))
{
$temp1 = array();
$temp1[] = array ('v' => (string) $r1['ora']);
$temp1[] = array ('v' => (float) $r1['ch3']);
$rows1[] = array ('c' => $temp1);
}
}
$table1['rows'] = $rows1;
$jsonTable1 = json_encode($table1);
?>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['table','corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart()
{
var data = new google.visualization.DataTable(<?=$jsonTable1?>);
var intestazione = "Monitoraggio ";
var titoloassex = "ora";
var titoloassey = "ch3";
var options =
{
width:500,
height:500,
title: intestazione,
hAxis: {title: titoloassex, minValue: 20, maxValue: 25},
pointSize: 0.1,
explorer:
{
actions: ['dragToZoom', 'rightClickToReset'],
axis: 'horizontal',
keepInBounds: true,
maxZoomIn: 4.0
},
pointShape: 'circle',
colors: ['red'],
curveType: 'function',
vAxis: {title: titoloassey,format:'#.##',decimalSymbol: '.', minValue: -0.05, maxValue: 0.05},
trendlines: { 0: {type: 'polynomial',degree: 1,color: 'purple',lineWidth: 5, opacity: 0.6} },
legend: 'none',
};
var chart = new google.visualization.ScatterChart(document.getElementById('grafico'));
chart.draw(data, options);
}
</script>
<div id="grafico" style="margin:auto; text-align:center; "></div>
我在哪里错了?再见