boundary / firespray

Blazingly fast streaming charts
MIT License
106 stars 13 forks source link

!axisYStartsAtZero results in incorrect chart #2

Closed wcainboundary closed 9 years ago

wcainboundary commented 9 years ago

Configuration property axisYStartsAtZero (default true) is ignored in setupGeometries, such that when it is false, the axis gets adjusted but the chart does not, so the two can easily have different scales (effectively resulting in an incorrect chart). Affects even a simple line chart.

Something like this seems to help, but I haven't fully tested it:

diff --git a/src/geometries.js b/src/geometries.js
index 7add3e7..ddb28bb 100644
--- a/src/geometries.js
+++ b/src/geometries.js
@@ -77,7 +77,7 @@ fy._computeGeometryData = function(config, cache) {

        var stackedMaxValue = d3.max(stackedMaxValues);
        var scaleYCopy = cache.scaleY.copy(); //TODO ?
-       scaleYCopy.domain([0, stackedMaxValue]);
+       scaleYCopy.domain([config.axisYStartsAtZero ? 0 : scaleYCopy.domain()[0], stackedMaxValue]);

        // bar width
        var barW = cache.scaleX(cache.data[0].values[1].x);
biovisualize commented 9 years ago

I fixed it in a simpler way. https://github.com/boundary/firespray/commit/39c3d57c7af9ea8b0254c891d2d7bebe37cc1362

wcainboundary commented 9 years ago

Thanks! Works great in my testing.