Search in sources :

Example 1 with Line

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));
            }
        }
    }
}
Also used : Line(com.twosigma.beakerx.chart.xychart.plotitem.Line) XYGraphics(com.twosigma.beakerx.chart.xychart.plotitem.XYGraphics)

Example 2 with Line

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();
}
Also used : Line(com.twosigma.beakerx.chart.xychart.plotitem.Line) TimePlot(com.twosigma.beakerx.chart.xychart.TimePlot) SimpleTimePlot(com.twosigma.beakerx.chart.xychart.SimpleTimePlot) CombinedPlot(com.twosigma.beakerx.chart.xychart.CombinedPlot) Plot(com.twosigma.beakerx.chart.xychart.Plot) CategoryPlot(com.twosigma.beakerx.chart.categoryplot.CategoryPlot) NanoPlot(com.twosigma.beakerx.chart.xychart.NanoPlot) Test(org.junit.Test)

Example 3 with Line

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));
}
Also used : Line(com.twosigma.beakerx.chart.xychart.plotitem.Line) StringWriter(java.io.StringWriter) Before(org.junit.Before)

Example 4 with Line

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();
}
Also used : Line(com.twosigma.beakerx.chart.xychart.plotitem.Line) ConstantLine(com.twosigma.beakerx.chart.xychart.plotitem.ConstantLine) DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 5 with Line

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());
}
Also used : ConstantLine(com.twosigma.beakerx.chart.xychart.plotitem.ConstantLine) Line(com.twosigma.beakerx.chart.xychart.plotitem.Line) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) AbstractChartTest(com.twosigma.beakerx.chart.AbstractChartTest) Test(org.junit.Test)

Aggregations

Line (com.twosigma.beakerx.chart.xychart.plotitem.Line)10 Before (org.junit.Before)5 ConstantLine (com.twosigma.beakerx.chart.xychart.plotitem.ConstantLine)3 StringWriter (java.io.StringWriter)3 Test (org.junit.Test)3 Points (com.twosigma.beakerx.chart.xychart.plotitem.Points)2 XYGraphics (com.twosigma.beakerx.chart.xychart.plotitem.XYGraphics)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)1 KernelTest (com.twosigma.beakerx.KernelTest)1 AbstractChartTest (com.twosigma.beakerx.chart.AbstractChartTest)1 Color (com.twosigma.beakerx.chart.Color)1 CategoryPlot (com.twosigma.beakerx.chart.categoryplot.CategoryPlot)1 CombinedPlot (com.twosigma.beakerx.chart.xychart.CombinedPlot)1 NanoPlot (com.twosigma.beakerx.chart.xychart.NanoPlot)1 Plot (com.twosigma.beakerx.chart.xychart.Plot)1 SimpleTimePlot (com.twosigma.beakerx.chart.xychart.SimpleTimePlot)1 TimePlot (com.twosigma.beakerx.chart.xychart.TimePlot)1 Area (com.twosigma.beakerx.chart.xychart.plotitem.Area)1 BigInteger (java.math.BigInteger)1