【问题标题】:ionic nvd3 how to have comma separator for thousands on Y axis离子 nvd3 如何在 Y 轴上有数千个逗号分隔符
【发布时间】:2017-05-19 07:36:19
【问题描述】:

请看看我的图表生成 http://imgur.com/a/Kds5f

在 Y 轴上,我想用逗号分隔千位。

例如:

100000 应该是 100,000 而 80000 应该是 80,000

Here is my code snippet,参考$scope.options


更新:

我用 tickFormat 试过了

                  yAxis: {
                    axisLabel: 'ktoe',
                    axisLabelDistanc: 40,
                    tickFormat: d3.format(',')
                  },

但它以逗号出现,但对于 100,000,1 像这样消失

http://imgur.com/a/Vu2y9

【问题讨论】:

    标签: angular ionic-framework graph nvd3.js


    【解决方案1】:

    格式化刻度

    chart.yAxis.tickFormat(function (d) {
        var format = d3.format(",");
        return '£ ' + format(d); // If you want add '£' symbol
    });
    

    将图表向左调整margin : {left: 40},以便能够在图表上看到yAxis

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2013-11-17
      • 1970-01-01
      • 2019-03-22
      • 2013-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-21
      相关资源
      最近更新 更多