d3.js - Grouped Bar Chart with negative value d3 -


first time asking here.

i modify code here https://gist.github.com/mbostock/3887051 show negative values.

i have managed y axis show correct negative values changing line

y.domain([0, d3.max(data, function(d) { return d3.max(d.ages, function(d) { return d.value; }); })]); 

to be:

y.domain([ d3.min(data, function(d) { return d3.min(d.ages, function(d) { return d.value; }); }), d3.max(data, function(d) { return d3.max(d.ages, function(d) { return d.value; }); })]); 

but takes care of y axis, cant change on x axis.

i have looked everywhere online - there's stacked bar chart negative, not grouped bar chart negative.

please kindly help. thank in advance!

your sample data gave doesn't contain negative values, here's fiddle random data negative values http://jsfiddle.net/srg6a/ take notice of part:

// if 0 not between min & max put x-axis on bottom var xaxistransform =  height;      if(d3min < 0 && 0 < d3max) {         xaxistransform = height * (d3max / (d3max -d3min));     }   svg.append("g")             .attr("class", "y axis")             .attr("transform", "translate(0," + xaxistransform + ")") // line moves x-axis             .call(xaxis); 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -