Skip to content

Plotly.Net.ImageExport ToBase64JPGString hangs in Blazor Server Application #436

@markus-renezeder

Description

@markus-renezeder

Description

I try to create a chart and export it into a Base64 JPG string to display it as image on a page. If I run the .ToBase64JPGString (or any other ToBase64...), the export does not get finished.
Same behavior if I use .SaveJPG("chart.jpg").
.SaveHtml("chart.html") works as expected.

Run this in a console application, it works.

Repro steps

  1. Create a new Blazor Server Side Application
  2. Add class Index.razor.cs
  3. Add the following code in Index.razor.cs:
string image = string.Empty;
protected override void OnParametersSet()
{

    List<DateTime> dateTimes = new();
    List<float> temp = new();
    List<float> utemp = new();
    List<float> ltemp = new();

    for (int i = 0; i < 10; i++)
    {
        dateTimes.Add(DateTime.Now.AddDays(i));
    }

    for (int i = 0; i < 10; i++)
    {
        float t = Random.Shared.Next(10, 30);

        float diff = Random.Shared.Next(1, 10);

        temp.Add(t);

        utemp.Add(t + diff);
        ltemp.Add(t - diff);
    }

    var range = Chart.Range<DateTime, float, string>(dateTimes, temp, utemp, ltemp, Name: "range", mode: Plotly.NET.StyleParam.Mode.Lines_Markers);

    image = range.ToBase64JPGString();
}
  1. run the application

Expected behavior

Base64 image string

Actual behavior

.ToBase64JPGString hangs
.SaveJPG hangs

Related information

Windows 11
Plotly.Net 4.2.0
Plotly.Net.ImageExport 5.0.1
Plotly.Net.CSharp 0.11.1

.NET 6.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions