【问题标题】:Rounding nvd3 angularJS percentages for cummulative line chart为累积折线图舍入 nvd3 angularJS 百分比
【发布时间】:2014-07-08 18:54:33
【问题描述】:

您好,我正在使用这样的折线图:

http://cmaurer.github.io/angularjs-nvd3-directives/cumulative.line.chart.html

但我想知道是否有办法编辑 y 轴最大值和最小值(以及工具提示中的值),这样它们就不会显示这些超长小数。

我进入 nvd3 文件并在那里找到它们并设法使用 Math.round 对它们进行舍入......但我想知道是否有办法解决这个问题,所以我不必修改实际的 nvd3 文件。

【问题讨论】:

    标签: javascript angularjs nvd3.js


    【解决方案1】:

    对于 yAxis 范围,请尝试 chart.forceY([MinValue, MaxValue])

    并覆盖您的工具提示尝试:

    .tooltip(function(key, x, y, e, graph) {
        // You can use Math.round on y or x decimal place 
        return '<h3>' + key + '</h3>' + '<p>' + y + ' at ' + x + '</p>'
    });
    

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-08
      • 2011-09-11
      • 2017-03-03
      • 2013-06-10
      相关资源
      最近更新 更多