在Google测量图表中格式化时间 [英] Format time in google gauge chart

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

问题描述

无论如何要将Google Gauge图表从几秒钟变成这样的时间?
使用对象表示法,您可以提供一个值( v:)和一个格式化的值( f:

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



显示格式化的值



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


$ b

 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,r edTo:5,yellowFrom:1.65,yellowTo:3.25,width:240}; var chart = new google.visualization.Gauge(document.getElementById('chart_div')); chart.draw(数据,选项); },packages:['gauge']});   


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

解决方案

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>

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

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