【问题标题】:Changing the number format in google charts graphs of the Tooltip Data and also Y Axis更改工具提示数据和 Y 轴的谷歌图表中的数字格式
【发布时间】:2015-11-18 02:54:10
【问题描述】:

我需要在我的工具提示数据(Y 轴)和 Y 轴的每千个之后添加一个逗号。如何更改数字格式?我尝试在我的代码中添加它,但似乎它不起作用。我的 vAxis 和 hAxis 标题显示也不起作用。

var options = {
  title:'<?php echo $row["$graph_title"];?>',
  height: 'auto',
  width : 'auto',
  tooltip : {trigger: 'selection'},
  is3D: true,
  vAxis: {title: '<?php echo $row1["$y_axis"]; ?>'},
  hAxis: {title: '<?php echo $row1["$x_axis"]; ?>'},
  bar: {groupWidth: "70%"},
  vAxis: {format:'decimal'}
};

【问题讨论】:

    标签: javascript php google-visualization tooltip number-formatting


    【解决方案1】:

    您可以继续使用numberFormatThe docmentation describes it作为

    描述数字列的格式。格式化选项包括指定前缀符号(例如美元符号)或用作千位标记的标点符号。

    var numberFormat = new google.visualization.NumberFormat({
        groupingSymbol: ','
    });
    numberFormat.format(data, COLUMNNUMBER);
    

    【讨论】:

    • 如果我想为工具提示做怎么办
    • 答案正是如此。
    • 你有例子吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多