Search in sources :

Example 1 with Page

use of tech.tablesaw.plotly.components.Page in project tablesaw by jtablesaw.

the class PageTest method testCustomPlotlyJsLocation.

@Test
public void testCustomPlotlyJsLocation() {
    BarTrace trace = BarTrace.builder(x, y).build();
    String location = this.getClass().getResource(this.getClass().getSimpleName() + ".class").toString();
    Page page = Page.pageBuilder(new Figure(trace), "plot").plotlyJsLocation(location).build();
    String html = page.asJavascript();
    assertTrue(html.indexOf("\"" + location + "\"") > 0);
}
Also used : BarTrace(tech.tablesaw.plotly.traces.BarTrace) Page(tech.tablesaw.plotly.components.Page) Figure(tech.tablesaw.plotly.components.Figure) Test(org.junit.jupiter.api.Test)

Example 2 with Page

use of tech.tablesaw.plotly.components.Page in project tablesaw by jtablesaw.

the class PageTest method testDefaultPlotlyJsLocation.

@Test
public void testDefaultPlotlyJsLocation() {
    BarTrace trace = BarTrace.builder(x, y).build();
    Page page = Page.pageBuilder(new Figure(trace), "plot").build();
    String html = page.asJavascript();
    assertTrue(html.indexOf("\"" + "https://cdn.plot.ly/plotly-latest.min.js" + "\"") > 0);
}
Also used : BarTrace(tech.tablesaw.plotly.traces.BarTrace) Page(tech.tablesaw.plotly.components.Page) Figure(tech.tablesaw.plotly.components.Figure) Test(org.junit.jupiter.api.Test)

Example 3 with Page

use of tech.tablesaw.plotly.components.Page in project tablesaw by jtablesaw.

the class Plot method show.

public static void show(Figure figure, String divName, File outputFile) {
    Page page = Page.pageBuilder(figure, divName).build();
    String output = page.asJavascript();
    try {
        try (Writer writer = new OutputStreamWriter(new FileOutputStream(outputFile), StandardCharsets.UTF_8)) {
            writer.write(output);
        }
        new Browser().browse(outputFile);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) Page(tech.tablesaw.plotly.components.Page) OutputStreamWriter(java.io.OutputStreamWriter) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) Browser(tech.tablesaw.plotly.display.Browser)

Example 4 with Page

use of tech.tablesaw.plotly.components.Page in project tablesaw by jtablesaw.

the class TemplateUtilsTest method createPageHtml.

private String createPageHtml() {
    Trace trace = ScatterTrace.builder(x, y).build();
    Figure figure = new Figure(trace);
    Page page = new PageBuilder(figure, "plot").build();
    String html = page.asJavascript();
    return html;
}
Also used : Trace(tech.tablesaw.plotly.traces.Trace) ScatterTrace(tech.tablesaw.plotly.traces.ScatterTrace) Page(tech.tablesaw.plotly.components.Page) PageBuilder(tech.tablesaw.plotly.components.Page.PageBuilder) Figure(tech.tablesaw.plotly.components.Figure)

Aggregations

Page (tech.tablesaw.plotly.components.Page)4 Figure (tech.tablesaw.plotly.components.Figure)3 Test (org.junit.jupiter.api.Test)2 BarTrace (tech.tablesaw.plotly.traces.BarTrace)2 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1 UncheckedIOException (java.io.UncheckedIOException)1 Writer (java.io.Writer)1 PageBuilder (tech.tablesaw.plotly.components.Page.PageBuilder)1 Browser (tech.tablesaw.plotly.display.Browser)1 ScatterTrace (tech.tablesaw.plotly.traces.ScatterTrace)1 Trace (tech.tablesaw.plotly.traces.Trace)1