use of com.twosigma.beakerx.chart.xychart.plotitem.Line in project beakerx by twosigma.
the class SimpleTimePlot method setDisplayNames.
public void setDisplayNames(List<String> displayNames) {
this.displayNames = displayNames;
if (displayNames != null) {
List<XYGraphics> graphics = getGraphics();
int i = 0;
for (XYGraphics graphic : graphics) {
if (graphic instanceof Line) {
graphic.setDisplayName(displayNames.get(++i));
}
}
}
}
use of com.twosigma.beakerx.chart.xychart.plotitem.Line in project beakerx by twosigma.
the class GroovyEvaluatorChartTest method parsePlotWithLineScript_returnPlotObjectWithLine.
@Test
public void parsePlotWithLineScript_returnPlotObjectWithLine() {
// when
Object result = parseClassFromScript("def plot = new Plot()\n" + "def ys = [0, 1, 6, 5, 2, 8]\n" + "plot << new Line(y: ys)");
// then
Assertions.assertThat(result instanceof Plot).isTrue();
Plot plot = (Plot) result;
Assertions.assertThat(plot.getGraphics()).isNotEmpty();
Assertions.assertThat(plot.getGraphics().get(0) instanceof Line).isTrue();
}
use of com.twosigma.beakerx.chart.xychart.plotitem.Line in project beakerx by twosigma.
the class GraphicsSerializerTest method initTestStubData.
@Before
public void initTestStubData() throws IOException {
sw = new StringWriter();
jgen = mapper.getJsonFactory().createJsonGenerator(sw);
line = new Line() {
};
line.setX(Arrays.asList(1, 2, 3));
line.setY(Arrays.asList(1, 2, 3));
}
use of com.twosigma.beakerx.chart.xychart.plotitem.Line in project beakerx by twosigma.
the class XYChartSerializerTest method serializeGraphicsOfXYChartPlot_resultJsonHasGraphicsList.
@Test
public void serializeGraphicsOfXYChartPlot_resultJsonHasGraphicsList() throws IOException {
// given
Line line = new Line();
line.setX(Arrays.asList(1, 2, 3));
line.setY(Arrays.asList(2, 3, 4));
plot.add(line);
// when
xyChartSerializer.serialize(plot, jgen, new DefaultSerializerProvider.Impl());
jgen.flush();
// then
JsonNode actualObj = mapper.readTree(sw.toString());
Assertions.assertThat(actualObj.has("graphics_list")).isTrue();
Assertions.assertThat(actualObj.get("graphics_list")).isNotEmpty();
}
use of com.twosigma.beakerx.chart.xychart.plotitem.Line in project beakerx by twosigma.
the class XYChartTest method shouldSendCommMsgWhenAddXYGraphicsByLeftShift.
@Test
public void shouldSendCommMsgWhenAddXYGraphicsByLeftShift() throws Exception {
// given
XYChart xyChart = createWidget();
Line graphics = new Line();
graphics.setX(Collections.singletonList(1));
graphics.setY(Collections.singletonList(1));
// when
xyChart.leftShift(graphics);
// then
List valueAsArray = getValueAsArray(GRAPHICS_LIST);
Map actual = (Map) valueAsArray.get(0);
assertThat(actual.get(GraphicsSerializer.TYPE)).isEqualTo(Line.class.getSimpleName());
}
Aggregations