I am using d3.js diagrams in one of my applications. Here they are in this image. See Charts .
For the Y axis on the money chart (see image), I want the maximum value to be rounded to 400, no matter what the maximum bar size here is $ 358.72, but I want to keep the bar at 358.72, but along the Y axis it will be up to 400.
The code for this is here.
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;
});
Please help me solve this problem.
source
share