Skip to content
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

Adding support for .NET Interactive extensions #150

Open
malisimo opened this issue Sep 6, 2020 · 0 comments
Open

Adding support for .NET Interactive extensions #150

malisimo opened this issue Sep 6, 2020 · 0 comments

Comments

@malisimo
Copy link

malisimo commented Sep 6, 2020

It would be great if XPlot could support the .NET Interactive extension mechanisms to allow it to work as a plugin to Jupyter Notebooks via a nuget package reference, rather than the .NET Interactive tools taking a hard dependency on XPlot.
This is related to the open issue on the .NET Interactive repo #582.
This would also address another issue #534.

Describe the solution you'd like
The discussion here (in particular this reply) suggests that it should already be possible by adding a dependency on dotnet.interactive and declaring an appropriate implementation of IKernelExtension and registering a handler for the appropriate chart type, for example:

type Layout() =
    member this.Register() =
        let formatFun = 
            fun (chart:PlotlyChart) (writer:System.IO.TextWriter) -> writer.Write(PlotlyChartExtensions.GetHtml(chart))
            |> fun f -> System.Action<_,_>(f)

        Formatter.Register<PlotlyChart>(formatFun,
            HtmlFormatter.MimeType,
            true)

Adding these types in the correct place (i.e. interactive-extensions/dotnet) to the nuget package should allow the .NET Interactive tools to find and register the XPlot type to allow it to be used as a plugin which will render XPlot charts to a MIME type that can be rendered in the notebook.

There may be an issue with target platforms currently - dotnet interactive targets netcoreapp3.1 and not netstandard which means that the XPlot nuget package should likely multitarget both netstandard2.0 and netcoreapp3.1. However this makes things a little ugly where there is conditionally compiled code and references, since XPlot itself should remain platform agnostic.

Doing this work will also pave the way for other plugins to be used within this new .NET Interactive platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant