Skip to content

Commit fa99037

Browse files
authored
Add Kernel Extension for plotly formatter (#54)
* Add Kernel Extension for plotly formatter - Add dependencies for extension in own group because they are not stable yet - Add fix for GenericChart JS which breaks the embedded charts in VSCode - Add notebook for visually testing extension * Add requested changes from PR review - Shorten project name and related namespaces - Reflect changes in visual inspection notebook - Switch project to netstandard2.1
1 parent 7c4d440 commit fa99037

File tree

11 files changed

+1706
-142
lines changed

11 files changed

+1706
-142
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,5 @@ docsrc/tools/FSharp.Formatting.svclog
186186
docs
187187
temp/gh-pages
188188
/src/FSharp.Plotly/TestScript.fsx
189-
/pkg
189+
/pkg
190+
.ionide/

Plotly.NET.sln

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".ci", ".ci", "{2461AFBF-6E1
8383
.circleci\config.yml = .circleci\config.yml
8484
EndProjectSection
8585
EndProject
86+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Plotly.NET.Interactive", "src\Plotly.NET.Interactive\Plotly.NET.Interactive.fsproj", "{0F135E3B-B0E1-42A9-B180-18C0221DC7B8}"
87+
EndProject
8688
Global
8789
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8890
Debug|Any CPU = Debug|Any CPU
@@ -102,6 +104,12 @@ Global
102104
{2C9916F4-817A-4B70-8D83-F48E9A30544F}.Dotnet|Any CPU.Build.0 = Debug|Any CPU
103105
{2C9916F4-817A-4B70-8D83-F48E9A30544F}.Release|Any CPU.ActiveCfg = Release|Any CPU
104106
{2C9916F4-817A-4B70-8D83-F48E9A30544F}.Release|Any CPU.Build.0 = Release|Any CPU
107+
{0F135E3B-B0E1-42A9-B180-18C0221DC7B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
108+
{0F135E3B-B0E1-42A9-B180-18C0221DC7B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
109+
{0F135E3B-B0E1-42A9-B180-18C0221DC7B8}.Dotnet|Any CPU.ActiveCfg = Debug|Any CPU
110+
{0F135E3B-B0E1-42A9-B180-18C0221DC7B8}.Dotnet|Any CPU.Build.0 = Debug|Any CPU
111+
{0F135E3B-B0E1-42A9-B180-18C0221DC7B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
112+
{0F135E3B-B0E1-42A9-B180-18C0221DC7B8}.Release|Any CPU.Build.0 = Release|Any CPU
105113
EndGlobalSection
106114
GlobalSection(SolutionProperties) = preSolution
107115
HideSolutionNode = FALSE

paket.dependencies

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ source https://nuget.org/api/v2
55

66
nuget FSharp.Core >= 4.7
77
nuget Newtonsoft.Json >= 12.0.3
8-
nuget Argu
8+
nuget Argu
99

1010
nuget System.Runtime.InteropServices.RuntimeInformation >= 4.3.0
1111

@@ -14,4 +14,19 @@ source https://nuget.org/api/v2
1414
source https://ci.appveyor.com/nuget/fsharp-formatting
1515

1616
nuget FSharp.Formatting prerelease
17-
nuget FSharp.Formatting.CommandTool prerelease
17+
nuget FSharp.Formatting.CommandTool prerelease
18+
19+
group DotnetInteractive
20+
# until .NET Interactive is out of beta most packages needed to write extension
21+
# dont exist in the public repositories - consumers of the nuget shouldn't need this
22+
source https://api.nuget.org/v3/index.json
23+
source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json
24+
source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json
25+
source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet3.1/nuget/v3/index.json
26+
source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json
27+
source https://pkgs.dev.azure.com/dnceng/public/_packaging/MachineLearning/nuget/v3/index.json
28+
source https://www.powershellgallery.com/api/v2
29+
30+
nuget Microsoft.DotNet.Interactive 1.0.0-beta.20574.9
31+
nuget Microsoft.DotNet.Interactive.Formatting 1.0.0-beta.20574.9
32+
nuget Microsoft.DotNet.Interactive.FSharp 1.0.0-beta.20574.9

paket.lock

Lines changed: 308 additions & 98 deletions
Large diffs are not rendered by default.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Auto-Generated by FAKE; do not edit
2+
namespace System
3+
open System.Reflection
4+
5+
[<assembly: AssemblyTitleAttribute("Plotly.NET.Interactive")>]
6+
[<assembly: AssemblyProductAttribute("Plotly.NET")>]
7+
[<assembly: AssemblyDescriptionAttribute("A F# interactive charting library using plotly.js")>]
8+
[<assembly: AssemblyVersionAttribute("2.0.0")>]
9+
[<assembly: AssemblyFileVersionAttribute("2.0.0")>]
10+
do ()
11+
12+
module internal AssemblyVersionInformation =
13+
let [<Literal>] AssemblyTitle = "Plotly.NET.Interactive"
14+
let [<Literal>] AssemblyProduct = "Plotly.NET"
15+
let [<Literal>] AssemblyDescription = "A F# interactive charting library using plotly.js"
16+
let [<Literal>] AssemblyVersion = "2.0.0"
17+
let [<Literal>] AssemblyFileVersion = "2.0.0"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
namespace Plotly.NET.Interactive
2+
3+
open System.Threading.Tasks
4+
open Microsoft.DotNet.Interactive
5+
open Microsoft.DotNet.Interactive.Formatting
6+
open Plotly.NET.GenericChart
7+
8+
type FormatterKernelExtension() =
9+
10+
let registerFormatter () =
11+
Formatter.Register<GenericChart>
12+
((fun chart writer ->
13+
let html = toChartHTML chart
14+
15+
writer.Write(html)),
16+
HtmlFormatter.MimeType)
17+
18+
interface IKernelExtension with
19+
member _.OnLoadAsync _ =
20+
registerFormatter ()
21+
22+
if isNull KernelInvocationContext.Current |> not then
23+
let message =
24+
"Added Kernerl Extension including formatters for GenericChart"
25+
26+
KernelInvocationContext.Current.Display(message, "text/markdown")
27+
|> ignore
28+
29+
Task.CompletedTask

0 commit comments

Comments
 (0)