我在我的一个应用程序中使用d3.js图表.他们在这张图片中见图表
对于货币图表上的Y轴(参见图片),我希望最大值四舍五入为400,无论这里的最大条形尺寸是358.72美元,但我想保持在358.72,但在Y轴上它将是400限制.
代码就在这里
tradesChart = [
{
key: "Cumulative Return",
values: [
{
"label" : "6E",
"value" : 100 },
{
"label" : "NG",
"value" : 100 },
{
"label" : "TF",
"value" : 67 } ]
}
];
nv.addGraph(function() {
var chart = nv.models.discreteBarChart()
.x(function(d) { return d.label })
.y(function(d) { return d.value/100 })
.staggerLabels(true)
.showValues(true)
.valueFormat(d3.format('.0%'))
chart.yAxis.tickFormat(function(d) { return d3.format('d')(d*100) + '%'; });
d3.select('#chart-trades svg')
.datum(tradesChart)
.transition().duration(500)
.call(chart);
nv.utils.windowResize(chart.update);
return chart;
});
Run Code Online (Sandbox Code Playgroud)
请帮我解决这个问题