Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Plotly.NET.CSharp/Plotly.NET.CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
</PropertyGroup>

<ItemGroup>
<None Include="..\..\docs\img\logo.png" Pack="true" PackagePath="\" />
<None Include="..\..\docs\img\logo.png" Pack="true" PackagePath="\" />
<None Include="./extension.dib" Pack="true" PackagePath="interactive-extensions/dotnet" />
<PackageReference Include="Plotly.NET" Version="3.*" />
</ItemGroup>

Expand Down
30 changes: 30 additions & 0 deletions src/Plotly.NET.CSharp/extension.dib
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!csharp

using Microsoft.DotNet.Interactive;
using Microsoft.DotNet.Interactive.Formatting;

var interactiveDoc = @"
<div>
[CHART]
[DESCRIPTION]
</div>
";



Formatter.Register<Plotly.NET.GenericChart.GenericChart>(
(chart, writer) =>
{
var chartMarkup = Plotly.NET.GenericChart.toChartHTML(chart);
var displayOpts = Plotly.NET.GenericChart.getDisplayOptions(chart);
var html = Plotly.NET.DisplayOptions.replaceHtmlPlaceholders(
displayOpts,
interactiveDoc.Replace("[CHART]", chartMarkup)
);
writer.Write(html);
},
"text/html"
);

"Interactive module loaded, enjoy!"