Skip to content

Commit

Permalink
revert numbering, add a TODO in Step3
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Jan 29, 2019
1 parent 0345c93 commit 075e61a
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/core/core.layouts.js
Expand Up @@ -203,12 +203,13 @@ module.exports = {
// What we do to find the best sizing, we do the following
// 1. Determine the minimum size of the chart area.
// 2. Split the remaining width equally between each vertical axis
// 3. Give each layout the maximum size it can be. The layout will return it's minimum size
// 4. Adjust the sizes of each axis based on it's minimum reported size.
// 5. Refit each axis
// 6. Position each axis in the final location
// 7. Tell the chart the final location of the chart area
// 8. Tell any axes that overlay the chart area the positions of the chart area
// 3. Split the remaining height equally between each horizontal axis
// 4. Give each layout the maximum size it can be. The layout will return it's minimum size
// 5. Adjust the sizes of each axis based on it's minimum reported size.
// 6. Refit each axis
// 7. Position each axis in the final location
// 8. Tell the chart the final location of the chart area
// 9. Tell any axes that overlay the chart area the positions of the chart area

// Step 1
var chartWidth = width - leftPadding - rightPadding;
Expand All @@ -219,6 +220,10 @@ module.exports = {
var verticalBoxWidth = (width - chartAreaWidth) / verticalBoxes.length;

// Step 3
// TODO re-limit horizontal axis height (this limit has affected only padding calculation since PR 1837)
// var horizontalBoxHeight = (height - chartAreaHeight) / (topBoxes.length + bottomBoxes.length);

// Step 4
var maxChartAreaWidth = chartWidth;
var maxChartAreaHeight = chartHeight;
var outerBoxSizes = {top: topPadding, left: leftPadding, bottom: bottomPadding, right: rightPadding};
Expand Down Expand Up @@ -251,7 +256,7 @@ module.exports = {

// At this point, maxChartAreaHeight and maxChartAreaWidth are the size the chart area could
// be if the axes are drawn at their minimum sizes.
// Steps 4 & 5
// Steps 5 & 6

// Function to fit a box
function fitBox(box) {
Expand Down Expand Up @@ -339,7 +344,7 @@ module.exports = {
maxChartAreaWidth = newMaxChartAreaWidth;
}

// Step 6 - Position the boxes
// Step 7 - Position the boxes
var left = leftPadding + leftPaddingAddition;
var top = topPadding + topPaddingAddition;

Expand Down Expand Up @@ -374,15 +379,15 @@ module.exports = {
helpers.each(rightBoxes, placeBox);
helpers.each(bottomBoxes, placeBox);

// Step 7
// Step 8
chart.chartArea = {
left: outerBoxSizes.left,
top: outerBoxSizes.top,
right: outerBoxSizes.left + maxChartAreaWidth,
bottom: outerBoxSizes.top + maxChartAreaHeight
};

// Step 8
// Step 9
helpers.each(chartAreaBoxes, function(box) {
box.left = chart.chartArea.left;
box.top = chart.chartArea.top;
Expand Down

0 comments on commit 075e61a

Please sign in to comment.