You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ms...@apache.org on 2025/10/03 18:11:36 UTC
(superset) branch msyavuz/fix/blank-image-export created (now a790caeefc)
This is an automated email from the ASF dual-hosted git repository.
msyavuz pushed a change to branch msyavuz/fix/blank-image-export
in repository https://gitbox.apache.org/repos/asf/superset.git
at a790caeefc fix(explore): Include chart canvases in the screenshot
This branch includes the following new commits:
new a790caeefc fix(explore): Include chart canvases in the screenshot
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(superset) 01/01: fix(explore): Include chart canvases in the screenshot
Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
msyavuz pushed a commit to branch msyavuz/fix/blank-image-export
in repository https://gitbox.apache.org/repos/asf/superset.git
commit a790caeefcf4eca42e3a8eef357dbc94cce4d710
Author: Mehmet Salih Yavuz <sa...@proton.me>
AuthorDate: Fri Oct 3 21:10:59 2025 +0300
fix(explore): Include chart canvases in the screenshot
---
.../useExploreAdditionalActionsMenu/index.jsx | 1 +
superset-frontend/src/utils/downloadAsImage.ts | 19 +++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx b/superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx
index 19278a747b..fdc85dd248 100644
--- a/superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx
+++ b/superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx
@@ -393,6 +393,7 @@ export const useExploreAdditionalActionsMenu = (
'.panel-body .chart-container',
slice?.slice_name ?? t('New chart'),
true,
+ theme,
)(e.domEvent);
setIsDropdownVisible(false);
dispatch(
diff --git a/superset-frontend/src/utils/downloadAsImage.ts b/superset-frontend/src/utils/downloadAsImage.ts
index e8e36bc27e..cd4633e59d 100644
--- a/superset-frontend/src/utils/downloadAsImage.ts
+++ b/superset-frontend/src/utils/downloadAsImage.ts
@@ -205,11 +205,30 @@ const processCloneForVisibility = (clone: HTMLElement) => {
});
};
+const preserveCanvasContent = (original: Element, clone: Element) => {
+ const originalCanvases = original.querySelectorAll('canvas');
+ const clonedCanvases = clone.querySelectorAll('canvas');
+
+ for (let i = 0; i < originalCanvases.length; i++) {
+ if (originalCanvases[i] && clonedCanvases[i]) {
+ const originalCanvas = originalCanvases[i] as HTMLCanvasElement;
+ const clonedCanvas = clonedCanvases[i] as HTMLCanvasElement;
+ const ctx = clonedCanvas.getContext('2d');
+ if (ctx) {
+ clonedCanvas.width = originalCanvas.width;
+ clonedCanvas.height = originalCanvas.height;
+ ctx.drawImage(originalCanvas, 0, 0);
+ }
+ }
+ }
+};
+
const createEnhancedClone = (
originalElement: Element,
): { clone: HTMLElement; cleanup: () => void } => {
const clone = originalElement.cloneNode(true) as HTMLElement;
copyAllComputedStyles(originalElement, clone);
+ preserveCanvasContent(originalElement, clone);
const tempContainer = document.createElement('div');
tempContainer.style.cssText = `