Search in sources :

Example 11 with CategoryPlot

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

the class CategoryPlotSerializerTest method serializeGraphicsListCategoryPlot_resultJsonHasGraphicsList.

@Test
public void serializeGraphicsListCategoryPlot_resultJsonHasGraphicsList() throws IOException {
    // when
    CategoryPlot categoryPlot = new CategoryPlot();
    categoryPlot.add(Arrays.asList(new CategoryBars(), new CategoryPoints()));
    categoryPlotSerializer.serialize(categoryPlot, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("graphics_list")).isTrue();
    ArrayNode arrayNode = (ArrayNode) actualObj.get("graphics_list");
    Assertions.assertThat(arrayNode.size()).isEqualTo(2);
}
Also used : CategoryBars(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars) DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) CategoryPoints(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryPoints) CategoryPlot(com.twosigma.beakerx.chart.categoryplot.CategoryPlot) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 12 with CategoryPlot

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

the class CategoryPlotSerializerTest method serializeCategoryMarginOfCategoryPlot_resultJsonHasCategoryMargin.

@Test
public void serializeCategoryMarginOfCategoryPlot_resultJsonHasCategoryMargin() throws IOException {
    // when
    CategoryPlot categoryPlot = new CategoryPlot();
    categoryPlot.setCategoryMargin(0.5);
    categoryPlotSerializer.serialize(categoryPlot, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("category_margin")).isTrue();
    Assertions.assertThat(actualObj.get("category_margin").asDouble()).isEqualTo(0.5);
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) CategoryPlot(com.twosigma.beakerx.chart.categoryplot.CategoryPlot) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 13 with CategoryPlot

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

the class CategoryPlotSerializerTest method serializeOrientationCategoryPlot_resultJsonHasOrientation.

@Test
public void serializeOrientationCategoryPlot_resultJsonHasOrientation() throws IOException {
    // when
    CategoryPlot categoryPlot = new CategoryPlot();
    categoryPlot.setOrientation(PlotOrientationType.VERTICAL);
    categoryPlotSerializer.serialize(categoryPlot, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("orientation")).isTrue();
    Assertions.assertThat(actualObj.get("orientation").asText()).isEqualTo("VERTICAL");
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) CategoryPlot(com.twosigma.beakerx.chart.categoryplot.CategoryPlot) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 14 with CategoryPlot

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

the class ItemLabelBuilderTest method setUp.

@Before
public void setUp() throws Exception {
    categoryGraphics = new CategoryBars();
    categoryGraphics.setValue(new Integer[] { new Integer(1), new Integer(2) });
    categoryGraphics.setSeriesNames(Arrays.asList("test series name"));
    categoryPlot = new CategoryPlot();
    categoryPlot.setCategoryNames(Arrays.asList("test category name"));
    categoryPlot.add(Arrays.asList(categoryGraphics));
}
Also used : CategoryBars(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars) CategoryPlot(com.twosigma.beakerx.chart.categoryplot.CategoryPlot) Before(org.junit.Before)

Example 15 with CategoryPlot

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

the class GroovyEvaluatorChartTest method parseCategoryPlotWithCategoryLinesScript_returnCategoryPlotObjectWithCategoryLines.

@Test
public void parseCategoryPlotWithCategoryLinesScript_returnCategoryPlotObjectWithCategoryLines() {
    // when
    Object result = parseClassFromScript("new CategoryPlot() << new CategoryLines(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)

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