I'm not sure how smart this is, but I solved a similar problem in this way:
// A function that assigns a shadow style to an element
function setShadowStyle(el, shadowStyle) {
el.style.boxShadow = shadowStyle;
}
// ... some functions omitted ...
function savePNG() {
// Set the element with which we will work
let graph = document.querySelector("#graph");
// Set the element's shadow style to default
const defaultShadowStyle = window.getComputedStyle(graph).boxShadow;
// Removing the shadow before starting html2canvas
setShadowStyle(graph, 'none');
// We perform all the necessary actions of html2canvas
html2canvas(graph).then(function (canvas) {
let img = document.body.appendChild(canvas);
download(img, "image/png", "graph.png");
// Be sure to set some timeout, after which we remove the temporary canvas block
setTimeout(function () {
img.remove();
}, 500);
});
// Return the original style of the shadow to the corresponding block
setShadowStyle(graph, defaultShadowStyle);
}