以下是从 Google code playground 复制的简单 Google 仪表图表的代码.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>
Google Visualization API Sample
</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['gauge']});
</script>
<script type="text/javascript">
function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
['Label', 'Value'],
['Memory', 80],
['CPU', 55],
['Network', 68]
]);
// Create and draw the visualization.
new google.visualization.Gauge(document.getElementById('visualization')).
draw(data);
}
google.setOnLoadCallback(drawVisualization);
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="visualization" style="width: 600px; height: 300px;"></div>
</body>
</html>
如何更改这些仪表的最大值?当我在选项中给出 var options = { max: 500};
时,它为所有三个仪表设置了 500。但是是否可以为不同的规范给出不同的最大值。
最佳答案
制作 3 个不同的仪表图表。您可以使用相同的 DataTable,但使用 DataView 为每个单独的图表仅使用一行。 。目前无法在 API 中单独设置仪表的值。请参阅this thread从 2011 年开始,Google 网上论坛中也说了同样的话。
(这可能不是一个非常高的优先级。如果您想做得更简单,您可以使用 Control Wrappers 链接所有这些,而不需要单独的 DataView)
关于charts - 仪表图最大值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16710436/