Is it possible to use Plotly.js in a C# Winforms WebBrowser component?

I am attempting to use Plotly.js in a C# Winforms desktop application from within a WebBrowser toolbox component for the sake of seamlessness, and am having some difficulties. The code is loaded into the component by assigning the literal string to WebBrowser.DocumentText property.

Specifically, I get the following error when the program is run: "Plotly is undefined." The same code, when pasted into a file called index.html, loads and runs correctly in a FireFox browser window when double-clicked. Must be something REALLY simple and newbie or just ignorant.

Here are the contents of the index.html file:

<html>
<head>
<script src = 'plotly-latest.min.js'></script>
</head>
<body>
<div id = "myDiv"></div>
<script>
var myDiv = document.getElementById('myDiv');
var trace = {
x : [9,8,5,1],
y : [1,2,4,8],
z : [11,8,15,3],
mode : 'lines' };
var data = [trace];
Plotly.newPlot(myDiv, data);
</script>
</body>
<html>

Thanks for any assistance you might render (pun intended!).


WebBrowser control by default uses IE6 which is not compatible to Plotly.js. You can make it use IE11 to display your graph using windows registry. You can also do it in code if you need to distribute your app.

You also have an option of ditching WebBrowser control and use third party browser controls like CefSharp (free) or DotNetBrowser (commercial).