google-visualization - 谷歌折线图 : How to add units?

标签 google-visualization

https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart#Example

如何将单位添加到垂直轴,如“$”或“€”?在示例中,它应该是 1.200 $、1.000 $、800 $、600 $ 和 400 $。

像这样添加 '$' 是行不通的:

var data = google.visualization.arrayToDataTable([
      ['Year', 'Sales', 'Expenses'],
      ['2004',  1000 '$',      400],
      ['2005',  1170 '$',      460],
      ['2006',  660 '$',       1120],
      ['2007',  1030 '$',      540]
    ]);

我知道,这是一个不好的例子,因为销售没有任何单位,但这只是一个例子。

最佳答案

您需要在图形选项中添加格式标签,如下所示:

var options = {
    vAxis: {format:'# $'}
};

引用:https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart#Configuration_Options

关于google-visualization - 谷歌折线图 : How to add units?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15325837/

相关文章:

javascript - 如何在谷歌折线图中为注释赋予颜色

google-analytics - 在 Google Analytics API 响应中格式化数据并使用 Charts API 进行可视化

javascript - Google 可视化 API 不起作用。 (语言.html :17 Uncaught TypeError: Cannot read property 'Query' of undefined)

c# - Linq 根据年份和类别选择产品数量

javascript - Sankey 的 Google 图表 API 未触发选择事件

javascript - 通过 ajax 将 json 传递给 google charts - 如何格式化日期

polymer - 在 Polymer 的 <google-chart> Web 组件中使用 "google.visualization.*"对象

javascript - Google 可视化和 ASP 更新面板

javascript - 谷歌折线图 : issue with line graph combine 3 data array in one chart possible?

javascript - 如何编辑谷歌可视化数据表中的选项?