【发布时间】:2018-07-05 12:00:26
【问题描述】:
我想在折线图上显示数据值,即鼠标悬停时显示的数据值,我需要默认显示它们。我在这里尝试了解决方案Google Charts API: Always show the Data Point Values in Graph
data.addColumn({type: 'number', role: 'annotation'});
我将它添加到我的代码中(我不确定将其准确放在哪里),但它没有做任何改变。
这是我的代码的一部分:
<!DOCTYPE html>
<html>
<head>
<title>Week/Orders</title>
<script type="text/javascript" src="loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart(){
var data = new google.visualization.DataTable();
var data = google.visualization.arrayToDataTable([
['Week','Orders'],
<?php
while($row = mysqli_fetch_assoc($aresult)){
echo "['".$row["Week"]."', ".$row["Orders"]."],";
}
?>
]);
var options = {
title: 'Week Vs Orders',
'width':1700,
'height':600,
legend: { position: 'bottom' }
};
var chart = new google.visualization.LineChart(document.getElementById('curvechart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="curvechart" style="width: 900px; height: 400px"></div>
</body>
</html>
我有两个价值观;周和订单。默认情况下,我只需要图表上显示的“订单”值。我怎样才能做到这一点?谢谢。
【问题讨论】:
标签: charts google-visualization