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();
}
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);
}
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();
}
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");
}
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);
}
Aggregations