jmix2.2 chart component, how to export images through java api? And not by clicking a button?
Hi!
The only way I found is an asynchronous call to a Java script function for chart component:
chart.getElement().executeJs("""
var svgBlob = new Blob(
[$0._root.renderToSVGString({})],
{type:"image/svg+xml;charset=utf-8"}
);
var svgUrl = URL.createObjectURL(svgBlob);
var downloadLink = document.createElement("a");
downloadLink.href = svgUrl;
downloadLink.download = "newesttree.svg";
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
""");
This snippet uses the renderToSVGString()
method.
There is documentation for this method: Documentation - Apache ECharts
The only problem is that setting the choice of rendering method is not yet available.
I created an issue to implement the ability to select SVG as a renderer:
Unfortunately, there is currently no way to programmatically initiate a chart export.
Best regards,
Dmitriy