如何在"离散条形图"中更改整数中的小数值

Moa*_*eeq 5 javascript nvd3.js

我使用离散条形图(NVD3库)在我的网站中显示图表.虽然显示图表一切都很好,但我的问题是如何将十进制值更改为整数.在y轴上显示的值显示整数值.虽然我用哪个数组显示具有整数值的值.我使用的js代码如下

     nv.addGraph(function() {  
     var chart = nv.models.discreteBarChart()
    .x(function(d) { return d.label })
    .y(function(d) { return d.value })
    .staggerLabels(true)
    .tooltips(false)
    .showValues(true)
    .transitionDuration(250);
    chart.xAxis.axisLabel("<?php echo $configureGrid['x_axis']['legend']; ?>");
    chart.yAxis.axisLabel("<?php echo $configureGrid['y_axis']['legend']; ?>");
    d3.select('#issue_by_time svg')
    .datum(historicalBarChart)
    .call(chart);
    nv.utils.windowResize(chart.update);
    return chart;
    });
    });
Run Code Online (Sandbox Code Playgroud)

Moa*_*eeq 13

用这个,

chart.yAxis.tickFormat(d3.format(',f'));
Run Code Online (Sandbox Code Playgroud)

将小数值转换为y轴的整数

chart.xAxis.tickFormat(d3.format(',f'));
Run Code Online (Sandbox Code Playgroud)

将小数值转换为x轴的整数

chart.valueFormat(d3.format('d'));
Run Code Online (Sandbox Code Playgroud)

将小数值转换为整数,通过图形输入