I am using d3.js but I am unable to show both values together on graph that is positive values above the x axis and negative value below x axis ...
I tried below code
var bar = g.selectAll(".bar").data(data);
        var barColorClass = 'blue-bar';
        var transitionOrigin =  D3Graph.height - 1;
        
        var rect = bar.enter().append("rect")
          .attr("class", "bar "+barColorClass)
          .attr("x", function(d, i) { return i * unit; })
          .attr("y", function(d) { return transitionOrigin;})
          .attr("width", unit);
        
        rect.transition(t)
        .attr("height", function(d) {
            
                return (y(d.amount) < 0) ? (D3Graph.height + 3) : (D3Graph.height - y(d.amount));
        
        }).attr("y", function(d) {
            
                return (y(d.amount) < 0) ? (-1 * 3) : y(d.amount);
                
        });
        
        
 
                        
In a canonical example you would adjust the
yandheightof the rects based on if they are positive or negative:Full example: