Hello Syncfusion,
A while ago I reacted to another thread on the forum.
https://www.syncfusion.com/forums/169967/export-chart-data-to-base64
In there you used this sample:
<SfChart @ref="@chartInstance">
<ChartEvents OnExportComplete="@GetUrl">ChartEvents>
SfChart>
@code
{
private SfChart chartInstance;
public async Task ExportChart(MouseEventArgs args)
{
await chartInstance.ExportAsync(ExportType.PNG, "Chart", Syncfusion.PdfExport.PdfPageOrientation.Portrait, false);
}
public void GetUrl(ExportEventArgs Args)
{
var dataURL = Args.DataUrl;
}
}
That works fine and all. But I created a chart as component. (Another razor page)
So when I press on the main page the button to create a PDF report. I access the
chartInstance.ExportAsync.
private async void CreateReport()
{
string base64 = ColumnChart.CreateExportImage();
string base64 = PieChart.CreateExportImage();
}
This calls within the ColumnChart Razor file the method that does basicly
chartInstance.ExportAsync();
But the problem that I have it that the "GetUrl" is not kicked till the the CreateReport is done.
public void GetUrl(ExportEventArgs Args)
{
var dataURL = Args.DataUrl;
}
Is there a way to have the dataurl returned whin the same function. Something like:
public async Task CreateExportImage()
{
base64 = null;
await ExportAsync(null);
while(
GetUrl()
== null) //As long the dataurl is still null wait till it's created
{
System.Threading.Thread.Sleep(500);
}
base64 = GetUrl();
return
base64;
}
public async Task ExportAsync(MouseEventArgs args)
{
ColumnChart.ExportAsync(ExportType.PNG, "Chart", null, false);
}
(Example might be needed some more files to work)
Attachment: PDFExportChartSample_ed8d3a9.zip