]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Chart area boxes receive 0 margin during the final layout process (#9915)
authorEvert Timberg <evert.timberg+github@gmail.com>
Sun, 28 Nov 2021 15:25:27 +0000 (10:25 -0500)
committerGitHub <noreply@github.com>
Sun, 28 Nov 2021 15:25:27 +0000 (10:25 -0500)
src/core/core.layouts.js
test/fixtures/plugin.legend/legend-line-chart-area.json [new file with mode: 0644]
test/fixtures/plugin.legend/legend-line-chart-area.png [new file with mode: 0644]

index c5c7e46749f11fa16c40c75bb40c2239b8d2ec26..5154e1285f43875fffdc9daac719ff258e7421ca 100644 (file)
@@ -460,7 +460,7 @@ export default {
     each(boxes.chartArea, (layout) => {
       const box = layout.box;
       Object.assign(box, chart.chartArea);
-      box.update(chartArea.w, chartArea.h);
+      box.update(chartArea.w, chartArea.h, {left: 0, top: 0, right: 0, bottom: 0});
     });
   }
 };
diff --git a/test/fixtures/plugin.legend/legend-line-chart-area.json b/test/fixtures/plugin.legend/legend-line-chart-area.json
new file mode 100644 (file)
index 0000000..e3e2520
--- /dev/null
@@ -0,0 +1,35 @@
+{
+    "config": {
+        "type": "line",
+        "data": {
+            "labels": ["A", "B", "C", "D", "E"],
+            "datasets": [{
+                "data": [10, 20, 30, 40, 50],
+                "backgroundColor": "#00ff00",
+                "borderWidth": 0,
+                "label": ""
+            }]
+        },
+        "options": {
+            "plugins": {
+                "legend": {
+                    "position": "chartArea"
+                }
+            },
+            "scales": {
+                "x": {
+                    "display": false
+                },
+                "y": {
+                    "display": false
+                }
+            }
+        }
+    },
+    "options": {
+        "canvas": {
+            "height": 256,
+            "width": 512
+        }
+    }
+}
\ No newline at end of file
diff --git a/test/fixtures/plugin.legend/legend-line-chart-area.png b/test/fixtures/plugin.legend/legend-line-chart-area.png
new file mode 100644 (file)
index 0000000..f3b020f
Binary files /dev/null and b/test/fixtures/plugin.legend/legend-line-chart-area.png differ