Search in sources :

Example 6 with CategoryPlot

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

the class GroovyEvaluatorChartTest method parseCategoryPlotWithCategoryStemsScript_returnCategoryPlotObjectWithCategoryStems.

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

use of com.twosigma.beakerx.chart.categoryplot.CategoryPlot 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 CategoryPlot

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

the class GroovyEvaluatorChartTest method parseCategoryPlotWithYAxisScript_returnCategoryPlotObjectWithYAxis.

@Test
public void parseCategoryPlotWithYAxisScript_returnCategoryPlotObjectWithYAxis() {
    // when
    Object result = parseClassFromScript("def p = new CategoryPlot()\n" + "p << new YAxis(label: \"Volume\", upperMargin: 1)");
    // then
    Assertions.assertThat(result instanceof CategoryPlot).isTrue();
    CategoryPlot categoryPlot = (CategoryPlot) result;
    Assertions.assertThat(categoryPlot.getYAxes()).isNotEmpty();
}
Also used : CategoryPlot(com.twosigma.beakerx.chart.categoryplot.CategoryPlot) Test(org.junit.Test)

Example 9 with CategoryPlot

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

the class CategoryPlotSerializerTest method serializeCategoryNamesOfCategoryPlot_resultJsonHasCategoryNames.

@Test
public void serializeCategoryNamesOfCategoryPlot_resultJsonHasCategoryNames() throws IOException {
    // when
    CategoryPlot categoryPlot = new CategoryPlot();
    categoryPlot.setCategoryNames(Arrays.asList("name1", "name2"));
    categoryPlotSerializer.serialize(categoryPlot, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("categoryNames")).isTrue();
    ArrayNode arrayNode = (ArrayNode) actualObj.get("categoryNames");
    Assertions.assertThat(arrayNode.get(1).asText()).isEqualTo("name2");
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) CategoryPlot(com.twosigma.beakerx.chart.categoryplot.CategoryPlot) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 10 with CategoryPlot

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

the class CategoryPlotSerializerTest method serializeCategoryNamesLabelAngleOfCategoryPlot_resultJsonHasCategoryNamesLabelAngle.

@Test
public void serializeCategoryNamesLabelAngleOfCategoryPlot_resultJsonHasCategoryNamesLabelAngle() throws IOException {
    // when
    CategoryPlot categoryPlot = new CategoryPlot();
    categoryPlot.setCategoryNamesLabelAngle(0.5);
    categoryPlotSerializer.serialize(categoryPlot, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("categoryNamesLabelAngle")).isTrue();
    Assertions.assertThat(actualObj.get("categoryNamesLabelAngle").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)

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