谷歌仪表图表中的格式时间 [英] Format time in google gauge chart

查看:16
本文介绍了谷歌仪表图表中的格式时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法像这样从秒到时间格式化 Google Gauge 图表?

Is there anyway to format Google Gauge chart from seconds to time like this?

推荐答案

使用对象表示法,您可以提供一个值 (v:) 和一个格式化的值 (f:>)

using object notation, you can provide a value (v:) and a formatted value (f:)

{v: 4.2, f: '01:16:04'}

仪表图将显示格式化的值

the gauge chart will display the formatted value

请参阅以下工作片段...

see following working snippet...

google.charts.load('current', {
  callback: function () {
    var data = google.visualization.arrayToDataTable([
      ['Label', 'Value'],
      [' ', {v: 4.2, f: '01:16:04'}]
    ]);

    var options = {
      height: 240,
      max: 5,
      minorTicks: 5,
      redFrom: 3.25,
      redTo: 5,
      yellowFrom: 1.65,
      yellowTo: 3.25,
      width: 240
    };

    var chart = new google.visualization.Gauge(document.getElementById('chart_div'));
    chart.draw(data, options);
  },
  packages:['gauge']
});

<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>

这篇关于谷歌仪表图表中的格式时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆