From 9ebdaa9d15b5a258a065d0f28cf7f482b192f9cf Mon Sep 17 00:00:00 2001 From: Ludo Stellingwerff Date: Mon, 7 Dec 2015 16:10:30 +0100 Subject: [PATCH] Fix bar graph Y-axis scale with stacking bar graphs. --- lib/timeline/component/LineGraph.js | 1 + lib/timeline/component/graph2d_types/bar.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/timeline/component/LineGraph.js b/lib/timeline/component/LineGraph.js index 32aa5d58..557c76c4 100644 --- a/lib/timeline/component/LineGraph.js +++ b/lib/timeline/component/LineGraph.js @@ -1014,6 +1014,7 @@ LineGraph.prototype._convertXcoordinates = function (datapoints) { var toScreen = this.body.util.toScreen; for (var i = 0; i < datapoints.length; i++) { datapoints[i].screen_x = toScreen(datapoints[i].x) + this.props.width; + datapoints[i].screen_y = datapoints[i].y; //starting point for range calculations } }; diff --git a/lib/timeline/component/graph2d_types/bar.js b/lib/timeline/component/graph2d_types/bar.js index 58467c74..fc26ed47 100644 --- a/lib/timeline/component/graph2d_types/bar.js +++ b/lib/timeline/component/graph2d_types/bar.js @@ -73,7 +73,7 @@ Bargraph.draw = function (groupIds, processedGroupData, framework) { intersections[key].resolved += 1; if (group.options.stack === true) { - if (combinedData[i].y < group.zeroPosition) { + if (combinedData[i].screen_y < group.zeroPosition) { heightOffset = intersections[key].accumulatedNegative; intersections[key].accumulatedNegative += group.zeroPosition - combinedData[i].screen_y; } @@ -96,7 +96,7 @@ Bargraph.draw = function (groupIds, processedGroupData, framework) { screen_x:combinedData[i].screen_x, screen_y:combinedData[i].screen_y - heightOffset, groupId: combinedData[i].groupId, - label: combinedData[i].label, + label: combinedData[i].label }; Points.draw([pointData], group, framework, drawData.offset); //DOMutil.drawPoint(combinedData[i].x + drawData.offset, combinedData[i].y, group, framework.svgElements, framework.svg);