Svjard / jinrikisha

JavaScript toolkit for creating interactive real-time graphs
http://code.shutterstock.com/rickshaw/
MIT License
2 stars 0 forks source link

Bar renders bad with yMin <> 0 (graph.min) #20

Open Svjard opened 12 years ago

Svjard commented 12 years ago

Look at this piece of Bar render code: (Rickshaw.Graph.Renderer.Bar render method)

var nodes = graph.vis.selectAll("path") .data(series.stack) .enter().append("svg:rect") .attr("x", function(d) { return graph.x(d.x) + barXOffset }) .attr("y", function(d) { return graph.y(d.y0 + d.y) }) .attr("width", seriesBarWidth) .attr("height", function(d) { return graph.y.magnitude(d.y) }); The problem is rectangle height which is calculated incorrectly when our graph.y scale function is created with yMin<>0. More correctly will be using something like .attr("height", function(d) { return graph.y.magnitude(d.y) - graph.y.magnitude(0)}) OR attr("height", function(d) {return graph.y(d.y0) - graph.y(d.y0 + d.y) }) for height instead of .attr("height", function(d) { return graph.y.magnitude(d.y) });