无法获取Google Charts Axis以十进制格式 [英] Can't get Google Charts Axis to format in decimal

查看:65
本文介绍了无法获取Google Charts Axis以十进制格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为小数点形式的特定图形设置选项.我遇到了很多问题,但似乎无法弄清楚为什么它对我不起作用.

I am trying to set an option for a specific graph in the decimal form. I went through many questions, but I can't seem to figure out why it isn't working for me.

var temp_chart_options = {
   title: 'Temperature',
   hAxis: {title: 'Date',  titleTextStyle: {color: '#262626'}, format:'decimal' },
   vAxis: {minValue: 0, format: 'decimal'},
   keepInBounds: true,
};

temp_chart.draw(temp_data, temp_chart_options);

我尝试做format: 'decimal'format: { pattern: 'decimal' },甚至做了temp_chart.draw(data, google.charts.Line.convertOptions(temp_chart_options));,甚至看着这些问题:

I tried doing format: 'decimal', or format: { pattern: 'decimal' } and even did temp_chart.draw(data, google.charts.Line.convertOptions(temp_chart_options)); and even looked at these questions:

  • google chart vertical axis and tooltip value formatting
  • Google Chart Vertical Axis and Tooltip Value Formatting
  • How to format numbers in Google API Linechart?

但它们似乎都不起作用:(

But none of them seem to work :(

编辑

有人知道如何更改悬停格式吗?

Does anyone know how to change the format of the hover?

推荐答案

垂直轴上的format参数需要指定适当的格式模式.例如,vaxis: {format:'0.00'}会给您一个数字,其后是小数点后两位.

The format parameter on your vertical axis needs to specify a proper format pattern. For example, vaxis: {format:'0.00'} will give you a number with two decimal places after it.

请注意, Google的文档对此并不完整.他们给出了一个使用预设的示例,以及一个使用分隔符(例如'#,###')的示例,但是没有显示小数位的示例,也没有关于数字格式说明符的完整文档.也许它在其他地方有记录,但是如果是这样的话,我上面链接到的页面应该至少提供一个链接.它不是.我通过实验发现了0.00格式.

Note that Google's documentation is very incomplete about this. They give an example using the presets, and an example of using separators (e.g. '#,###'), but there is no example showing decimal places, nor is there any complete documentation on number format specifiers that I could find. Perhaps it is documented elsewhere, but the page I linked to above ought to at least provide a link to it if so. It does not. I discovered the 0.00 format by experimentation.

这篇关于无法获取Google Charts Axis以十进制格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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