2

这是从谷歌代码游乐场复制的简单谷歌仪表图表的代码。

<!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。但是是否可以为不同的仪表给出不同的最大值。

4

1 回答 1

2

制作 3 个不同的仪表图。您可以使用相同的 DataTable,但使用DataView为每个单独的图表仅使用一行。目前无法在 API 中单独设置仪表的值。在 Google Groups 中查看2011 年的这个帖子,上面说了同样的话。

(可能这不是一个非常高的优先级。如果您想更简单地做到这一点,您可以使用Control Wrappers来链接所有这些,而无需单独的 DataViews)

于 2013-05-23T23:54:22.087 回答