Search in sources :

Example 1 with CategoryPlot

use of com.twosigma.beakerx.chart.categoryplot.CategoryPlot in project beakerx by twosigma.

the class ChartDetails method getGraphics.

/**
 * Taken from code{@code com.twosigma.beaker.groovy.rest.ChartRest#getGraphics}
 *
 * @param info  GraphicsActionObject
 * @param chart ChartDetails
 * @return list of Graphics for given plot data
 */
protected List<? extends Graphics> getGraphics(GraphicsActionObject info, ChartDetails chart) {
    List<? extends Graphics> graphics = null;
    if (chart instanceof XYChart) {
        graphics = ((XYChart) chart).getGraphics();
    } else if (chart instanceof CategoryPlot) {
        graphics = ((CategoryPlot) chart).getGraphics();
    } else if (chart instanceof CombinedPlot) {
        XYChart subplot = ((CombinedPlot) chart).getSubplots().get(((CombinedPlotActionObject) info).getSubplotIndex());
        graphics = subplot.getGraphics();
    }
    return graphics;
}
Also used : XYChart(com.twosigma.beakerx.chart.xychart.XYChart) CategoryPlot(com.twosigma.beakerx.chart.categoryplot.CategoryPlot) CombinedPlot(com.twosigma.beakerx.chart.xychart.CombinedPlot)

Example 2 with CategoryPlot

use of com.twosigma.beakerx.chart.categoryplot.CategoryPlot in project beakerx by twosigma.

the class PlotObjectSerializerTest method serializeCategoryPlot_returnTrue.

@Test
public void serializeCategoryPlot_returnTrue() throws Exception {
    // when
    boolean result = plotObjectSerializer.writeObject(new CategoryPlot(), jgen, true);
    // then
    Assertions.assertThat(result).isTrue();
}
Also used : CategoryPlot(com.twosigma.beakerx.chart.categoryplot.CategoryPlot) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 3 with CategoryPlot

use of com.twosigma.beakerx.chart.categoryplot.CategoryPlot in project beakerx by twosigma.

the class GroovyEvaluatorChartTest method parseCategoryPlotWithHorizontalOrientationScript_returnCategoryPlotObjectWithHorizontalOrientation.

@Test
public void parseCategoryPlotWithHorizontalOrientationScript_returnCategoryPlotObjectWithHorizontalOrientation() {
    // when
    Object result = parseClassFromScript("def plot = new CategoryPlot(orientation: PlotOrientationType.HORIZONTAL)\n" + "plot << new CategoryBars(value:[[1, 2, 3], [1, 3, 5]])");
    // then
    Assertions.assertThat(result instanceof CategoryPlot).isTrue();
    CategoryPlot categoryPlot = (CategoryPlot) result;
    Assertions.assertThat(categoryPlot.getOrientation()).isEqualTo(PlotOrientationType.HORIZONTAL);
}
Also used : CategoryPlot(com.twosigma.beakerx.chart.categoryplot.CategoryPlot) Test(org.junit.Test)

Example 4 with CategoryPlot

use of com.twosigma.beakerx.chart.categoryplot.CategoryPlot in project beakerx by twosigma.

the class GroovyEvaluatorChartTest method parseCategoryPlotWithCategoryPointsScript_returnCategoryPlotObjectWithCategoryPoints.

@Test
public void parseCategoryPlotWithCategoryPointsScript_returnCategoryPlotObjectWithCategoryPoints() {
    // when
    Object result = parseClassFromScript("new CategoryPlot() << new CategoryPoints(value: [[1, 2, 4], [4, 5, 8]])");
    // then
    Assertions.assertThat(result instanceof CategoryPlot).isTrue();
    CategoryPlot categoryPlot = (CategoryPlot) result;
    Assertions.assertThat(categoryPlot.getGraphics()).isNotEmpty();
}
Also used : CategoryPlot(com.twosigma.beakerx.chart.categoryplot.CategoryPlot) Test(org.junit.Test)

Example 5 with CategoryPlot

use of com.twosigma.beakerx.chart.categoryplot.CategoryPlot in project beakerx by twosigma.

the class GroovyEvaluatorChartTest method parseCategoryPlotWithCategoryBarsScript_returnCategoryPlotObjectWithCategoryBars.

@Test
public void parseCategoryPlotWithCategoryBarsScript_returnCategoryPlotObjectWithCategoryBars() {
    // when
    Object result = parseClassFromScript("def bars = new CategoryBars(value: [[1, 2, 3], [1, 3, 5]])\n" + "new CategoryPlot() << bars");
    // then
    Assertions.assertThat(result instanceof CategoryPlot).isTrue();
    CategoryPlot categoryPlot = (CategoryPlot) result;
    Assertions.assertThat(categoryPlot.getGraphics()).isNotEmpty();
}
Also used : CategoryPlot(com.twosigma.beakerx.chart.categoryplot.CategoryPlot) Test(org.junit.Test)

Aggregations

CategoryPlot (com.twosigma.beakerx.chart.categoryplot.CategoryPlot)15 Test (org.junit.Test)13 KernelTest (com.twosigma.beakerx.KernelTest)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)5 CategoryBars (com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 CategoryPoints (com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryPoints)1 CombinedPlot (com.twosigma.beakerx.chart.xychart.CombinedPlot)1 XYChart (com.twosigma.beakerx.chart.xychart.XYChart)1 Before (org.junit.Before)1