use of com.twosigma.beakerx.chart.xychart.plotitem.Points in project beakerx by twosigma.
the class GroovyEvaluatorChartTest method parsePlotWithPointsScript_returnPlotObjectWithPoints.
@Test
public void parsePlotWithPointsScript_returnPlotObjectWithPoints() {
// when
Object result = parseClassFromScript("def plot = new Plot();\n" + "def y1 = [6, 7, 12, 11, 8, 14]\n" + "plot << new Points(y: y1)");
// then
Assertions.assertThat(result instanceof Plot).isTrue();
Plot plot = (Plot) result;
Assertions.assertThat(plot.getGraphics()).isNotEmpty();
Assertions.assertThat(plot.getGraphics().get(0) instanceof Points).isTrue();
}
use of com.twosigma.beakerx.chart.xychart.plotitem.Points in project beakerx by twosigma.
the class PointsSerializerTest method initTestStubData.
@Before
public void initTestStubData() throws IOException {
sw = new StringWriter();
jgen = mapper.getJsonFactory().createJsonGenerator(sw);
points = new Points();
points.setX(Arrays.asList(1, 2, 3));
points.setY(Arrays.asList(1, 2, 3));
}
use of com.twosigma.beakerx.chart.xychart.plotitem.Points in project beakerx by twosigma.
the class SimpleTimePlot method reinitialize.
private void reinitialize() {
List<XYGraphics> graphics = getGraphics();
filter(graphics, new Predicate<XYGraphics>() {
public boolean test(XYGraphics graphic) {
return !(graphic instanceof Line || graphic instanceof Points);
}
});
List<Object> xs = new ArrayList<>();
List<List<Number>> yss = new ArrayList<>();
Set<String> dataColumnsNames = new HashSet<>();
if (data != null && columns != null) {
for (Map<String, Object> row : data) {
dataColumnsNames.addAll(row.keySet());
xs.add(getNumberForTimeColumn(row.get(timeColumn)));
for (int i = 0; i < columns.size(); i++) {
String column = columns.get(i);
if (i >= yss.size()) {
yss.add(new ArrayList<Number>());
}
yss.get(i).add(getNumberForTimeColumn(row.get(column)));
}
}
final HashSet<String> columnsWithoutData = getColumnsWithoutData(dataColumnsNames);
if (!columnsWithoutData.isEmpty()) {
throw new IllegalArgumentException(String.format("Chart data not found for columns: %s", columnsWithoutData));
}
List<Color> colors = getChartColors();
for (int i = 0; i < yss.size(); i++) {
List<Number> ys = yss.get(i);
if (displayLines) {
Line line = new Line();
line.setX(xs);
line.setY(ys);
if (displayNames != null && i < displayNames.size()) {
line.setDisplayName(displayNames.get(i));
} else {
line.setDisplayName(columns.get(i));
}
if (i < colors.size()) {
line.setColor(colors.get(i));
}
add(line);
}
if (displayPoints) {
Points points = new Points();
points.setX(xs);
points.setY(ys);
if (displayNames != null && i < displayNames.size()) {
points.setDisplayName(displayNames.get(i));
} else {
points.setDisplayName(columns.get(i));
}
if (i < colors.size()) {
points.setColor(colors.get(i));
}
add(points);
}
}
}
}
use of com.twosigma.beakerx.chart.xychart.plotitem.Points in project beakerx by twosigma.
the class NanoPlotTest method initStubData.
@Before
public void initStubData() {
BigInteger val1 = new BigInteger("12345678901234567891000");
BigInteger val2 = new BigInteger("12345678901234567892000");
points = new Points();
points.setX(Arrays.asList(val1, val2));
points.setY(Arrays.asList(2, 3));
line = new Line();
line.setX(Arrays.asList(val1, val1));
line.setY(Arrays.asList(2, 3));
}
use of com.twosigma.beakerx.chart.xychart.plotitem.Points in project beakerx by twosigma.
the class GroovyEvaluatorChartTest method parsePlotWithCircleShapePointsScript_returnPlotObjectWithCircleShapePoints.
@Test
public void parsePlotWithCircleShapePointsScript_returnPlotObjectWithCircleShapePoints() {
// when
Object result = parseClassFromScript("def plot = new Plot();\n" + "def y1 = [1.5, 1, 6, 5, 2, 8]\n" + "plot << new Points(y: y1, shape: ShapeType.CIRCLE)");
// then
Assertions.assertThat(result instanceof Plot).isTrue();
Plot plot = (Plot) result;
Assertions.assertThat(plot.getGraphics()).isNotEmpty();
Assertions.assertThat(((Points) plot.getGraphics().get(0)).getShape()).isEqualTo(ShapeType.CIRCLE);
}
Aggregations