charts - 仪表图最大值

标签 charts google-visualization max google-gauges

以下是从 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/

相关文章:

text - 如何增加 MPAndroid 条形图顶部文本值的大小?

javascript - 如何创建一个函数来呈现谷歌图表?

javascript - 如何将时间线图表与 ControlWrapper 绑定(bind)以过滤时间线

MySQL MAX() 运行很慢

python - 使用 groupby 获取组中具有最大值的行

javascript - 使用 JavaScript 显示基于时间的甘特图

javascript - 如何在Google日历图表中使用 bool 类型列?

javascript - 带有线条的 Google Charts API 标签

javascript - 带有 geohash 的谷歌图表

c++ - 如何在 C++ 中将 const int 设置为最大值?