如何设置工具提示以显示百分比以匹配Google Visualization折线图中的轴? [英] How to set tooltips to display percentages to match axis in Google Visualization Line Chart?

查看:100
本文介绍了如何设置工具提示以显示百分比以匹配Google Visualization折线图中的轴?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以使用以下代码将工具提示设置为显示百分比:

The tooltips can be set to display percentages using the following code:


var formatter = new google.visualization.NumberFormat({
      fractionDigits: 2,
      suffix: '%'
    });
formatter.format(data, 1); // Apply formatter to first column.

NumberFormat是否可以将每个元素乘以100?否则,工具提示将显示为.50%.

Is there a way for NumberFormat to multiply each element by 100? Otherwise the tooltip appears as .50%.

我使用的是vAxis.format = "format:'#%' ",它乘以100.所以.5在垂直轴上显示为50%.

I am using vAxis.format = "format:'#%' " which does multiply by 100. So .5 is displayed as 50% on the vertical axis.

根据文档( icu-project.org/apiref),可以通过将%括在单引号中来覆盖它,但这是行不通的.

According to the documentation(icu-project.org/apiref), this can be overwritten by enclosing the % in single quotes, but this did not work.

最终结果是工具提示与轴不匹配.最好的方法是什么?

The net result is that the tooltips do not match the axis. What is the best way to do this?

推荐答案

var formatter = new google.visualization.NumberFormat({ 
  pattern: '#%', 
  fractionDigits: 2
});

感谢 http://groups.google.com/group/google-visualization-api/

这篇关于如何设置工具提示以显示百分比以匹配Google Visualization折线图中的轴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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