Search in sources :

Example 1 with PieTrace

use of tech.tablesaw.plotly.traces.PieTrace in project tablesaw by jtablesaw.

the class PiePlot method create.

public static Figure create(String title, Table table, String groupColName, String numberColName) {
    Layout layout = Layout.builder(title).build();
    PieTrace trace = PieTrace.builder(table.column(groupColName), table.numberColumn(numberColName)).showLegend(true).build();
    return new Figure(layout, trace);
}
Also used : PieTrace(tech.tablesaw.plotly.traces.PieTrace) Layout(tech.tablesaw.plotly.components.Layout) Figure(tech.tablesaw.plotly.components.Figure)

Example 2 with PieTrace

use of tech.tablesaw.plotly.traces.PieTrace in project tablesaw by jtablesaw.

the class PieExample method main.

public static void main(String[] args) throws Exception {
    Table table = Table.read().csv("../data/tornadoes_1950-2014.csv");
    Table t2 = table.countBy(table.categoricalColumn("Scale"));
    PieTrace trace = PieTrace.builder(t2.categoricalColumn("Category"), t2.numberColumn("Count")).build();
    Layout layout = Layout.builder().title("Total fatalities by scale").build();
    Plot.show(new Figure(layout, trace));
}
Also used : Table(tech.tablesaw.api.Table) PieTrace(tech.tablesaw.plotly.traces.PieTrace) Layout(tech.tablesaw.plotly.components.Layout) Figure(tech.tablesaw.plotly.components.Figure)

Example 3 with PieTrace

use of tech.tablesaw.plotly.traces.PieTrace in project tablesaw by jtablesaw.

the class PieTest method testAsJavascript.

@Test
public void testAsJavascript() {
    PieTrace trace = PieTrace.builder(x, y).build();
    System.out.println(trace.asJavascript(1));
}
Also used : PieTrace(tech.tablesaw.plotly.traces.PieTrace) Test(org.junit.jupiter.api.Test)

Example 4 with PieTrace

use of tech.tablesaw.plotly.traces.PieTrace in project tablesaw by jtablesaw.

the class PieTest method show.

@Test
public void show() {
    PieTrace trace = PieTrace.builder(x, y).build();
    Figure figure = new Figure(trace);
    File outputFile = Paths.get("testoutput/output.html").toFile();
    Plot.show(figure, "target", outputFile);
}
Also used : PieTrace(tech.tablesaw.plotly.traces.PieTrace) File(java.io.File) Figure(tech.tablesaw.plotly.components.Figure) Test(org.junit.jupiter.api.Test)

Aggregations

PieTrace (tech.tablesaw.plotly.traces.PieTrace)4 Figure (tech.tablesaw.plotly.components.Figure)3 Test (org.junit.jupiter.api.Test)2 Layout (tech.tablesaw.plotly.components.Layout)2 File (java.io.File)1 Table (tech.tablesaw.api.Table)1