Search in sources :

Example 6 with CategoryBars

use of com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars in project beakerx by twosigma.

the class CategoryBarsSerializerTest method serializeLabelPositionCategoryBars_resultJsonHasLabelPosition.

@Test
public void serializeLabelPositionCategoryBars_resultJsonHasLabelPosition() throws IOException {
    // when
    CategoryBars categoryBars = new CategoryBars();
    categoryBars.setLabelPosition(LabelPositionType.CENTER);
    categoryBarsSerializer.serialize(categoryBars, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("labelPosition")).isTrue();
    Assertions.assertThat(actualObj.get("labelPosition").asText()).isEqualTo("CENTER");
}
Also used : CategoryBars(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars) DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 7 with CategoryBars

use of com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars in project beakerx by twosigma.

the class GroovyEvaluatorChartTest method parseCategoryBarsWithLabelPositionScript_returnCategoryBarsObjectWithLabelPosition.

@Test
public void parseCategoryBarsWithLabelPositionScript_returnCategoryBarsObjectWithLabelPosition() {
    // when
    Object result = parseClassFromScript("def p = new CategoryPlot()\n" + "p << new CategoryBars(value: [[1500, 2200, 2500, 4000]], width: 0.6,\n" + "                      color: Color.PINK, yAxis: \"Volume\", showItemLabel: true,\n" + "                      labelPosition: LabelPositionType.VALUE_INSIDE)");
    // then
    Assertions.assertThat(result instanceof CategoryPlot).isTrue();
    CategoryPlot categoryPlot = (CategoryPlot) result;
    Assertions.assertThat(categoryPlot.getGraphics()).isNotEmpty();
    CategoryBars categoryBars = (CategoryBars) categoryPlot.getGraphics().get(0);
    Assertions.assertThat(categoryBars.getLabelPosition()).isEqualTo(LabelPositionType.VALUE_INSIDE);
}
Also used : CategoryBars(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars) CategoryPlot(com.twosigma.beakerx.chart.categoryplot.CategoryPlot) Test(org.junit.Test)

Example 8 with CategoryBars

use of com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars in project beakerx by twosigma.

the class CategoryBarsSerializerTest method serializeOutlineColorCategoryBars_resultJsonHasOutlineColor.

@Test
public void serializeOutlineColorCategoryBars_resultJsonHasOutlineColor() throws IOException {
    // when
    CategoryBars categoryBars = new CategoryBars();
    categoryBars.setOutlineColor(Color.GREEN);
    categoryBarsSerializer.serialize(categoryBars, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("outline_color")).isTrue();
    Assertions.assertThat(actualObj.get("outline_color").get("rgb").asInt()).isEqualTo(Color.GREEN.getRGB());
}
Also used : CategoryBars(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars) DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 9 with CategoryBars

use of com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars in project beakerx by twosigma.

the class CategoryBarsSerializerTest method serializeBaseCategoryBars_resultJsonHasBase.

@Test
public void serializeBaseCategoryBars_resultJsonHasBase() throws IOException {
    // when
    CategoryBars categoryBars = new CategoryBars();
    categoryBars.setBase(11);
    categoryBarsSerializer.serialize(categoryBars, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("base")).isTrue();
    Assertions.assertThat(actualObj.get("base").asInt()).isEqualTo(11);
}
Also used : CategoryBars(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars) DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Example 10 with CategoryBars

use of com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars in project beakerx by twosigma.

the class CategoryBarsSerializerTest method serializeDrawOutlineCategoryBars_resultJsonHasOutline.

@Test
public void serializeDrawOutlineCategoryBars_resultJsonHasOutline() throws IOException {
    // when
    CategoryBars categoryBars = new CategoryBars();
    categoryBars.setDrawOutline(true);
    categoryBarsSerializer.serialize(categoryBars, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("outline")).isTrue();
    Assertions.assertThat(actualObj.get("outline").asBoolean()).isTrue();
}
Also used : CategoryBars(com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars) DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test)

Aggregations

CategoryBars (com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars)16 Test (org.junit.Test)14 JsonNode (com.fasterxml.jackson.databind.JsonNode)12 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)12 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)6 CategoryPlot (com.twosigma.beakerx.chart.categoryplot.CategoryPlot)3 CategoryPoints (com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryPoints)2 Before (org.junit.Before)2 KernelTest (com.twosigma.beakerx.KernelTest)1 AbstractChartTest (com.twosigma.beakerx.chart.AbstractChartTest)1 CategoryLines (com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryLines)1 CategoryStems (com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryStems)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1