-
Notifications
You must be signed in to change notification settings - Fork 99
Add Kernel Extension for plotly formatter #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kMutagene
merged 2 commits into
plotly:dev
from
WalternativE:dotnet-interactive-formatter
Dec 9, 2020
+1,706
−142
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,4 +186,5 @@ docsrc/tools/FSharp.Formatting.svclog | |
docs | ||
temp/gh-pages | ||
/src/FSharp.Plotly/TestScript.fsx | ||
/pkg | ||
/pkg | ||
.ionide/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Auto-Generated by FAKE; do not edit | ||
namespace System | ||
open System.Reflection | ||
|
||
[<assembly: AssemblyTitleAttribute("Plotly.NET.Interactive")>] | ||
[<assembly: AssemblyProductAttribute("Plotly.NET")>] | ||
[<assembly: AssemblyDescriptionAttribute("A F# interactive charting library using plotly.js")>] | ||
[<assembly: AssemblyVersionAttribute("2.0.0")>] | ||
[<assembly: AssemblyFileVersionAttribute("2.0.0")>] | ||
do () | ||
|
||
module internal AssemblyVersionInformation = | ||
let [<Literal>] AssemblyTitle = "Plotly.NET.Interactive" | ||
let [<Literal>] AssemblyProduct = "Plotly.NET" | ||
let [<Literal>] AssemblyDescription = "A F# interactive charting library using plotly.js" | ||
let [<Literal>] AssemblyVersion = "2.0.0" | ||
let [<Literal>] AssemblyFileVersion = "2.0.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace Plotly.NET.Interactive | ||
|
||
open System.Threading.Tasks | ||
open Microsoft.DotNet.Interactive | ||
open Microsoft.DotNet.Interactive.Formatting | ||
open Plotly.NET.GenericChart | ||
|
||
type FormatterKernelExtension() = | ||
|
||
let registerFormatter () = | ||
Formatter.Register<GenericChart> | ||
((fun chart writer -> | ||
let html = toChartHTML chart | ||
|
||
writer.Write(html)), | ||
HtmlFormatter.MimeType) | ||
|
||
interface IKernelExtension with | ||
member _.OnLoadAsync _ = | ||
registerFormatter () | ||
|
||
if isNull KernelInvocationContext.Current |> not then | ||
let message = | ||
"Added Kernerl Extension including formatters for GenericChart" | ||
|
||
KernelInvocationContext.Current.Display(message, "text/markdown") | ||
|> ignore | ||
|
||
Task.CompletedTask |
1,219 changes: 1,219 additions & 0 deletions
1,219
src/Plotly.NET.Interactive/ExtensionVisualTest.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.1</TargetFramework> | ||
<LangVersion>preview</LangVersion> | ||
<OutputType>Library</OutputType> | ||
<NoWarn>$(NoWarn);NU5100</NoWarn><!-- dll outside of lib/ folder --> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="AssemblyInfo.fs" /> | ||
<Compile Include="Extension.fs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Remove="bin\**" /> | ||
<EmbeddedResource Remove="bin\**" /> | ||
<None Remove="bin\**" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Plotly.NET\Plotly.NET.fsproj" /> | ||
</ItemGroup> | ||
|
||
<Import Project="..\..\.paket\Paket.Restore.targets" /> | ||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
group DotnetInteractive | ||
|
||
FSharp.Core | ||
Microsoft.DotNet.Interactive | ||
Microsoft.DotNet.Interactive.Formatting | ||
Microsoft.DotNet.Interactive.FSharp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
type project | ||
id Plotly.NET.Interactive | ||
title | ||
Plotly.NET.Interactive | ||
owners | ||
Timo Mühlhaus, Kevin Schneider | ||
authors | ||
Timo Mühlhaus, Kevin Schneider, Gregor Beyerle, F# open source contributors | ||
projectUrl | ||
https://plotly.github.io/Plotly.NET/ | ||
iconUrl | ||
https://raw.githubusercontent.com/plotly/Plotly.NET/master/docsrc/files/img/logo.png | ||
licenseUrl | ||
https://github.com/plotly/Plotly.NET/blob/master/LICENSE | ||
requireLicenseAcceptance | ||
false | ||
language | ||
F# | ||
copyright | ||
Copyright 2017-2020 | ||
tags | ||
visualization charting plotly F# | ||
summary | ||
A .NET Interactive Kernel Extension for displaying Plotly.NET charts | ||
description | ||
A .NET Interactive Kernel Extension for displaying Plotly.NET charts | ||
files | ||
bin/Release/netstandard2.1/Plotly.NET.Interactive.dll ==> interactive-extensions/dotnet | ||
repositoryType | ||
git | ||
repositoryUrl | ||
https://github.com/plotly/Plotly.NET | ||
include-pdbs false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also saw this one in your blog post, could you give me some info why we need to do this? My js is 'basic' 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess would be, that hoisting works a bit different in Electron from how it works in most browsers. When calling the immediately executed anonymous function to set up the plotly chart it tries to use the
fsharpPlotlyRequire
function and dies because it is undefined at the time. In other browser environments this doesn't happen. Why does this difference exist: beats me. You can try out how it behaves in VSCode (with the .NET interactive plugin) when you don't have this expression. It should work in your normal Jupyter environment, though. I can't talk about Nteract because I didn't test it there. Should also just happen for the recent versions of VSCode Insiders because they changed something there (my guess would be, that they switched to a newer Electron version, but I'm not sure).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well that's strange. I guess as long as this change does not affect the other environments we can take it.