Reputation: 3997
Here is the link. http://krispo.github.io/angular-nvd3/#/discreteBarChart
I want to position the values shown at the top of each bar inside the bar. Is there any way to do it in angular nvd3.
Upvotes: 1
Views: 609
Reputation: 32327
Using nvd3 I don't think so:
But using d3 you can do it like this:
$timeout triggering function later(used here so that nvd3 ends up making the chart) same as window timeout.
$timeout(function() {
//get all the positive bars and to its text y add 14
d3.selectAll(".positive").selectAll("text").forEach(function(k) {
var v = parseFloat(d3.select(k[0]).attr("y")) + 14;
d3.select(k[0]).attr("y", v)
})
}, 1000);//do this after a time out of 1 sec
$timeout(function() {
//get all the negative bars and to its text y minus 14
d3.selectAll(".negative").selectAll("text").forEach(function(k) {
var v = parseFloat(d3.select(k[0]).attr("y")) - 14;
d3.select(k[0]).attr("y", v)
})
}, 1000);//do this after a time out of 1 sec
Working code here
Hope this helps!
Upvotes: 1