public static T UseXplot <T>(this T kernel) where T : Kernel { Formatter <PlotlyChart> .Register( (chart, writer) => writer.Write(PlotlyChartExtensions.GetHtml(chart)), HtmlFormatter.MimeType); return(kernel); }
public void Returns_the_html_with_div() { var chart = new PlotlyChart(); var html = PlotlyChartExtensions.GetHtml(chart); var document = new HtmlDocument(); document.LoadHtml(html); document.DocumentNode.SelectSingleNode("//div").InnerHtml.Should().NotBeNull(); document.DocumentNode.SelectSingleNode("//div").Id.Should().NotBeNullOrEmpty(); }
public void Returns_the_html_with_script_containing_require_config() { var chart = new PlotlyChart(); var html = PlotlyChartExtensions.GetHtml(chart); var document = new HtmlDocument(); document.LoadHtml(html); document.DocumentNode.SelectSingleNode("//script") .InnerHtml .Should() .Contain("var xplotRequire = require.config({context:'xplot-3.0.1',paths:{plotly:'https://cdn.plot.ly/plotly-1.49.2.min'}}) || require;"); }
public void Returns_the_html_with_script_containing_require_plotly_and_call_to_new_plot_function() { var chart = new PlotlyChart(); var html = PlotlyChartExtensions.GetHtml(chart); 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);"); }