Search in sources :

Example 1 with Plot

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

the class PlotObjectSerializerTest method serializeXYChart_returnTrue.

@Test
public void serializeXYChart_returnTrue() throws Exception {
    // when
    boolean result = plotObjectSerializer.writeObject(new Plot(), jgen, true);
    // then
    Assertions.assertThat(result).isTrue();
}
Also used : CombinedPlot(com.twosigma.beakerx.chart.xychart.CombinedPlot) Plot(com.twosigma.beakerx.chart.xychart.Plot) CategoryPlot(com.twosigma.beakerx.chart.categoryplot.CategoryPlot) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 2 with Plot

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

the class CombinedPlotSerializerTest method serializeWeightsOfCombinedPlot_resultJsonHasWeights.

@Test
public void serializeWeightsOfCombinedPlot_resultJsonHasWeights() throws IOException {
    // when
    CombinedPlot combinedPlot = new CombinedPlot();
    combinedPlot.add(new Plot(), 3);
    combinedPlot.add(new Plot(), 3);
    combinedPlotSerializer.serialize(combinedPlot, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("weights")).isTrue();
    Assertions.assertThat(actualObj.get("weights")).isNotEmpty();
}
Also used : SimpleTimePlot(com.twosigma.beakerx.chart.xychart.SimpleTimePlot) CombinedPlot(com.twosigma.beakerx.chart.xychart.CombinedPlot) Plot(com.twosigma.beakerx.chart.xychart.Plot) DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) JsonNode(com.fasterxml.jackson.databind.JsonNode) CombinedPlot(com.twosigma.beakerx.chart.xychart.CombinedPlot) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 3 with Plot

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

the class GroovyEvaluatorChartTest method parsePlotWithRedColorLineScript_returnPlotObjectWithRedLine.

@Test
public void parsePlotWithRedColorLineScript_returnPlotObjectWithRedLine() {
    // when
    Object result = parseClassFromScript("def plot = new Plot()\n" + "def ys = [0, 1, 6, 5, 2, 8]\n" + "plot << new Line(y: ys, color: Color.red)");
    // then
    Assertions.assertThat(result instanceof Plot).isTrue();
    Plot plot = (Plot) result;
    Assertions.assertThat(plot.getGraphics()).isNotEmpty();
    Assertions.assertThat(plot.getGraphics().get(0).getColor()).isEqualTo(Color.RED);
}
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 4 with Plot

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

the class GroovyEvaluatorChartTest method parsePlotWithAreaScript_returnPlotObjectWithArea.

@Test
public void parsePlotWithAreaScript_returnPlotObjectWithArea() {
    // when
    Object result = parseClassFromScript("def plot = new Plot()\n" + "def ys = [3, 5, 2, 3]\n" + "def xs = [0, 1, 2, 3]\n" + "plot << new Area(x: xs, 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 Area).isTrue();
}
Also used : Area(com.twosigma.beakerx.chart.xychart.plotitem.Area) 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 5 with Plot

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

the class GroovyEvaluatorChartTest method parseLodFilterScript_returnLineObjectWithLodFilter.

@Test
public void parseLodFilterScript_returnLineObjectWithLodFilter() {
    // when
    Object result = parseClassFromScript("new Plot() << new Line(y: (0..10), lodFilter: Filter.LINE); ");
    // then
    Assertions.assertThat(result instanceof Plot).isTrue();
    Plot plot = (Plot) result;
    Assertions.assertThat(plot.getGraphics()).isNotEmpty();
}
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