谷歌折线图:如何添加单位? [英] Google Line Chart: How to add units?
本文介绍了谷歌折线图:如何添加单位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
https://google-developers.appspot.com/图表/交互式/ docs / gallery / linechart#示例
如何将单位添加到垂直轴,如$或€?在这个例子中,它应该是1.200 $,1.000 $,800 $,600 $和400 $。
How can I add units to the vertical axis like "$" or "€"? In the example, it should be 1.200 $, 1.000 $, 800 $, 600 $ and 400 $.
只要像这样添加'$'就行不通了: / p>
Just adding '$' like this doesn't work:
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2004', 1000 '$', 400],
['2005', 1170 '$', 460],
['2006', 660 '$', 1120],
['2007', 1030 '$', 540]
]);
我知道,这是一个糟糕的例子,因为销售没有任何单位,但它只是一个例子。
I know, it's a bad example as sales doesn't have any unit, but it's just an example.
推荐答案
您需要为您的图表选项添加一个格式标记,如下所示:
You need to add a format tag to your graph options as follows:
var options = {
vAxis: {format:'# $'}
};
参考: https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart#Configuration_Options
这篇关于谷歌折线图:如何添加单位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文