The WebBrowser
.NET component is using Internet Explorer which, as other mention, probably cannot render modern JavaScript used by Plotly.js
For .NET you can use one of the following:
the WebView2
control which uses Edge to render the web page
WebView article
WebView2 component on NuGet
NuGet\Install-Package Microsoft.Web.WebView2
CefSharp
- a .NET wrapper around the Chromium Embedded Framework (CEF) which uses Chromium engine to render pages (very similar with the engine used by the Chrome browser)
CefSharp github repository
CefSharp.WinForms package
NuGet\Install-Package CefSharp.WinForms
You can use your solution to make a page with JavaScript and load it in one the above webbrowser control or
you can use Plotly.NET to render Plotly directly from C#.
Example:
using Plotly.NET;
using Plotly.NET.LayoutObjects;
...
LinearAxis xAxis = new LinearAxis();
xAxis.SetValue("title", "xAxis");
xAxis.SetValue("showgrid", false);
xAxis.SetValue("showline", true);
LinearAxis yAxis = new LinearAxis();
yAxis.SetValue("title", "yAxis");
yAxis.SetValue("showgrid", false);
yAxis.SetValue("showline", true);
LinearAxis zAxis = new LinearAxis();
zAxis.SetValue("title", "zAxis");
zAxis.SetValue("showgrid", false);
zAxis.SetValue("showline", true);
Layout layout = new Layout();
layout.SetValue("xaxis", xAxis);
layout.SetValue("yaxis", yAxis);
layout.SetValue("zaxis", zAxis);
layout.SetValue("showlegend", true);
List<Tuple<double, double, double>> p = new List<Tuple<double, double, double>>();
foreach (var m in batch.Measurements)
{
var (_x, _y, _z) = m.GetCartesianCoordinates();
p.Add(Tuple.Create(_x, _y, _z));
}
string plotHtmlFilePath = GetNewUniqueTempPath();
Plotly.NET.Chart3D.Chart.Point3D<double, double, double, double>(p.ToArray())
.WithLayout(layout)
.SaveHtml(plotHtmlFilePath);
// using WebView2 control
plotWebView.Source = new Uri(plotHtmlFilePath);
or it can open it for you in the default browser:
Plotly.NET.Chart3D.Chart.Point3D<double, double, double, double>(p.ToArray())
.WithLayout(layout)
.Show();