Esempio n. 1
0
        public static T UseXplot <T>(this T kernel)
            where T : KernelBase
        {
            var extension = new XPlotKernelExtension();

            Task.Run(() => extension.OnLoadAsync(kernel)).Wait();
            return(kernel);
        }
Esempio n. 2
0
            public void Returns_the_html_with_script_containing_require_config()
            {
                var extension = new XPlotKernelExtension();
                var html      = extension.GetChartHtml(new PlotlyChart());
                var document  = new HtmlDocument();

                document.LoadHtml(html);

                document.DocumentNode.SelectSingleNode("//script").InnerHtml.Should().Contain("require.config({paths:{plotly:\'https://cdn.plot.ly/plotly-latest.min\'}});");
            }
Esempio n. 3
0
            public void Returns_the_html_with_div()
            {
                var extension = new XPlotKernelExtension();
                var html      = extension.GetChartHtml(new PlotlyChart());
                var document  = new HtmlDocument();

                document.LoadHtml(html);

                document.DocumentNode.SelectSingleNode("//div").InnerHtml.Should().NotBeNull();
                document.DocumentNode.SelectSingleNode("//div").Id.Should().NotBeNullOrEmpty();
            }
Esempio n. 4
0
            public void Returns_the_html_with_script_containing_require_config()
            {
                var extension = new XPlotKernelExtension();
                var html      = extension.GetChartHtml(new PlotlyChart());
                var document  = new HtmlDocument();

                document.LoadHtml(html);

                document.DocumentNode.SelectSingleNode("//script")
                .InnerHtml
                .Should()
                .Contain("var xplotRequire = requirejs.config({context:'xplot-3.0.1',paths:{plotly:'https://cdn.plot.ly/plotly-1.49.2.min'}});");
            }
Esempio n. 5
0
            public void Returns_the_html_with_script_containing_require_plotly_and_call_to_new_plot_function()
            {
                var extension = new XPlotKernelExtension();
                var html      = extension.GetChartHtml(new PlotlyChart());
                var document  = new HtmlDocument();

                document.LoadHtml(html);

                var divId = document.DocumentNode.SelectSingleNode("//div").Id;

                document.DocumentNode
                .SelectSingleNode("//script")
                .InnerHtml.Split("\n")
                .Select(item => item.Trim())
                .Where(item => !string.IsNullOrWhiteSpace(item))
                .Should()
                .ContainInOrder(@"xplotRequire(['plotly'], function(Plotly) {",
                                "var data = null;",
                                @"var layout = """";",
                                $"Plotly.newPlot('{divId}', data, layout);");
            }