🎨 ECharts support asynchronous Immediately Invoked Function Expression (IIFE)) (#8015)

This commit is contained in:
颖逸 2023-04-17 22:19:21 +08:00 committed by GitHub
parent 80c1b0350d
commit b13398cbdd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,7 +29,7 @@ export const chartRender = (element: Element, cdn = Constants.PROTYLE_CDN) => {
});
}
}
echartsElements.forEach((e: HTMLDivElement) => {
echartsElements.forEach(async (e: HTMLDivElement) => {
if (e.getAttribute("data-render") === "true") {
return;
}
@ -39,7 +39,7 @@ export const chartRender = (element: Element, cdn = Constants.PROTYLE_CDN) => {
const renderElement = e.firstElementChild.nextElementSibling as HTMLElement;
try {
renderElement.style.height = e.style.height;
const option = looseJsonParse(Lute.UnEscapeHTMLStr(e.getAttribute("data-content")));
const option = await looseJsonParse(Lute.UnEscapeHTMLStr(e.getAttribute("data-content")));
echarts.init(renderElement, window.siyuan.config.appearance.mode === 1 ? "dark" : undefined, {width}).setOption(option);
e.setAttribute("data-render", "true");
renderElement.classList.remove("ft__error");