]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Use full height for fullWidth box when left/right (#7836)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Fri, 2 Oct 2020 12:13:04 +0000 (15:13 +0300)
committerGitHub <noreply@github.com>
Fri, 2 Oct 2020 12:13:04 +0000 (08:13 -0400)
Use full height for fullWidth box when left/right

src/core/core.layouts.js

index 585bedd6799f260b3ff35686dd84ac7c352cde39..18e2aff7f1c04e96c27f8acef69677e30f8fd987 100644 (file)
@@ -47,12 +47,14 @@ function setLayoutDims(layouts, params) {
        let i, ilen, layout;
        for (i = 0, ilen = layouts.length; i < ilen; ++i) {
                layout = layouts[i];
-               // store width used instead of chartArea.w in fitBoxes
-               layout.width = layout.horizontal
-                       ? layout.box.fullWidth && params.availableWidth
-                       : params.vBoxMaxWidth;
-               // store height used instead of chartArea.h in fitBoxes
-               layout.height = layout.horizontal && params.hBoxMaxHeight;
+               // store dimensions used instead of available chartArea in fitBoxes
+               if (layout.horizontal) {
+                       layout.width = layout.box.fullWidth && params.availableWidth;
+                       layout.height = params.hBoxMaxHeight;
+               } else {
+                       layout.width = params.vBoxMaxWidth;
+                       layout.height = layout.box.fullWidth && params.availableHeight;
+               }
        }
 }
 
@@ -187,8 +189,8 @@ function placeBoxes(boxes, chartArea, params) {
                } else {
                        box.left = x;
                        box.right = x + box.width;
-                       box.top = chartArea.top;
-                       box.bottom = chartArea.top + chartArea.h;
+                       box.top = box.fullWidth ? userPadding.top : chartArea.top;
+                       box.bottom = box.fullWidth ? params.outerHeight - userPadding.right : chartArea.top + chartArea.h;
                        box.height = box.bottom - box.top;
                        x = box.right;
                }
@@ -344,6 +346,7 @@ export default {
                        outerHeight: height,
                        padding,
                        availableWidth,
+                       availableHeight,
                        vBoxMaxWidth: availableWidth / 2 / verticalBoxes.length,
                        hBoxMaxHeight: availableHeight / 2
                });