Search in sources :

Example 21 with Plot

use of com.twosigma.beakerx.chart.xychart.Plot 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);
}
Also used : Points(com.twosigma.beakerx.chart.xychart.plotitem.Points) 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 22 with Plot

use of com.twosigma.beakerx.chart.xychart.Plot in project beakerx by twosigma.

the class GroovyEvaluatorChartTest method parsePlotWithConstantLineScript_returnPlotObjectWithConstantLine.

@Test
public void parsePlotWithConstantLineScript_returnPlotObjectWithConstantLine() {
    // when
    Object result = parseClassFromScript("def plot = new Plot ()\n" + "plot << new ConstantLine(x: 0.65)");
    // then
    Assertions.assertThat(result instanceof Plot).isTrue();
    Plot plot = (Plot) result;
    Assertions.assertThat(plot.getConstantLines()).isNotEmpty();
    Assertions.assertThat(plot.getConstantLines().get(0)).isNotNull();
}
Also used : 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 23 with Plot

use of com.twosigma.beakerx.chart.xychart.Plot in project beakerx by twosigma.

the class GroovyEvaluatorChartTest method parsePlotWithBaseOfAreaScript_returnPlotObjectWithBaseOfArea.

@Test
public void parsePlotWithBaseOfAreaScript_returnPlotObjectWithBaseOfArea() {
    // when
    Object result = parseClassFromScript("def plot = new Plot()\n" + "def y = [3, 5, 2, 3]\n" + "def x0 = [0, 1, 2, 3]\n" + "plot << new Area(x: x0, y: y, base: 1)");
    // then
    Assertions.assertThat(result instanceof Plot).isTrue();
    Plot plot = (Plot) result;
    Assertions.assertThat(((Area) plot.getGraphics().get(0)).getBase().intValue()).isGreaterThan(0);
}
Also used : 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 24 with Plot

use of com.twosigma.beakerx.chart.xychart.Plot in project beakerx by twosigma.

the class GroovyEvaluatorChartTest method parsePlotWithStemsScript_returnPlotObjectWithStems.

@Test
public void parsePlotWithStemsScript_returnPlotObjectWithStems() {
    // when
    Object result = parseClassFromScript("def plot = new Plot();\n" + "def y1 = [1.5, 1, 6, 5, 2, 8]\n" + "plot << new Stems(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 Stems).isTrue();
}
Also used : 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) Stems(com.twosigma.beakerx.chart.xychart.plotitem.Stems) Test(org.junit.Test)

Example 25 with Plot

use of com.twosigma.beakerx.chart.xychart.Plot in project beakerx by twosigma.

the class GroovyEvaluatorChartTest method parsePlotWithCrosshairScript_returnPlotObjectWithCrosshair.

@Test
public void parsePlotWithCrosshairScript_returnPlotObjectWithCrosshair() {
    // when
    Object result = parseClassFromScript("def plot = new Plot(crosshair: new Crosshair(color: Color.BLUE))");
    // then
    Assertions.assertThat(result instanceof Plot).isTrue();
    Plot plot = (Plot) result;
    Assertions.assertThat(plot.getCrosshair()).isNotNull();
}
Also used : 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)

Aggregations

Plot (com.twosigma.beakerx.chart.xychart.Plot)29 Test (org.junit.Test)27 CombinedPlot (com.twosigma.beakerx.chart.xychart.CombinedPlot)23 SimpleTimePlot (com.twosigma.beakerx.chart.xychart.SimpleTimePlot)22 CategoryPlot (com.twosigma.beakerx.chart.categoryplot.CategoryPlot)20 NanoPlot (com.twosigma.beakerx.chart.xychart.NanoPlot)19 TimePlot (com.twosigma.beakerx.chart.xychart.TimePlot)19 KernelTest (com.twosigma.beakerx.KernelTest)7 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)3 TryResult (com.twosigma.beakerx.TryResult)2 Points (com.twosigma.beakerx.chart.xychart.plotitem.Points)2 Stems (com.twosigma.beakerx.chart.xychart.plotitem.Stems)2 SimpleEvaluationObject (com.twosigma.beakerx.jvm.object.SimpleEvaluationObject)2 Map (java.util.Map)2 Chart (com.twosigma.beakerx.chart.Chart)1 CategoryBars (com.twosigma.beakerx.chart.categoryplot.plotitem.CategoryBars)1 Area (com.twosigma.beakerx.chart.xychart.plotitem.Area)1 Bars (com.twosigma.beakerx.chart.xychart.plotitem.Bars)1 Line (com.twosigma.beakerx.chart.xychart.plotitem.Line)1