There is a Feature Request for WebChart:
Issue #72195
In the meantime, here is a way to do it (you can wrap it as an Extension). I’ve posted it a while back in this forum thread in the Spanish section.
Here is the code for a WebButton.Pressed event:
Var js() As String
js.Add("Chart.helpers.each(Chart.instances, (instance) => {")
js.Add(" var parent = instance.canvas.closest('.XojoCharts').id || '';")
js.Add(" if (parent === '" + Chart1.ControlID + "') {")
js.Add(" XojoWeb.session.storage.setItem('chart-png', instance.toBase64Image(), true);")
js.Add(" XojoWeb.session.storage.getItem('chart-png', true);")
js.Add(" }")
js.Add("});")
ExecuteJavaScript(String.FromArray(js))
You’ll have the picture available in the Session.RequestedData event:
Select Case Key
Case "chart-png"
Var imageData As String = DecodeBase64(Value.Replace("data:image/png;base64,", ""))
WebPage1.ImageViewer1.Picture = New WebPicture(imageData, "chart.png")
End Select
I hope that helps.