mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
fix: Download as image of dashboard chart did not work (#15897)
This commit is contained in:
parent
f6115a73d4
commit
7aeb15031d
@ -64,15 +64,23 @@ export default function downloadAsImage(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mapbox controls are loaded from different origin, causing CORS error
|
||||||
|
// See https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL#exceptions
|
||||||
|
const filter = (node: Element) => {
|
||||||
|
if (typeof node.className === 'string') {
|
||||||
|
return (
|
||||||
|
node.className !== 'mapboxgl-control-container' &&
|
||||||
|
!node.className.includes('ant-dropdown')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
return domToImage
|
return domToImage
|
||||||
.toJpeg(elementToPrint, {
|
.toJpeg(elementToPrint, {
|
||||||
quality: 0.95,
|
quality: 0.95,
|
||||||
bgcolor: GRAY_BACKGROUND_COLOR,
|
bgcolor: GRAY_BACKGROUND_COLOR,
|
||||||
// Mapbox controls are loaded from different origin, causing CORS error
|
filter,
|
||||||
// See https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL#exceptions
|
|
||||||
filter: (node: Element) =>
|
|
||||||
node.className !== 'mapboxgl-control-container',
|
|
||||||
...domToImageOptions,
|
|
||||||
})
|
})
|
||||||
.then(dataUrl => {
|
.then(dataUrl => {
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
|
Loading…
Reference in New Issue
Block a user