Search in sources :

Example 16 with Plot

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

the class ScalaEvaluatorTest method evaluatePlot_shouldCreatePlotObject.

@Test
public void evaluatePlot_shouldCreatePlotObject() throws Exception {
    // given
    String code = "import com.twosigma.beakerx.chart.xychart.Plot;\n" + "val plot = new Plot();\n" + "plot.setTitle(\"test title\");";
    SimpleEvaluationObject seo = new SimpleEvaluationObject(code);
    // when
    TryResult evaluate = scalaEvaluator.evaluate(seo, code);
    // then
    assertThat(evaluate.result() instanceof Plot).isTrue();
    assertThat(((Plot) evaluate.result()).getTitle()).isEqualTo("test title");
}
Also used : TryResult(com.twosigma.beakerx.TryResult) Plot(com.twosigma.beakerx.chart.xychart.Plot) SimpleEvaluationObject(com.twosigma.beakerx.jvm.object.SimpleEvaluationObject) Test(org.junit.Test)

Example 17 with Plot

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

the class CombinedPlotSerializerTest method serializePlotTypeOfCombinedPlot_resultJsonHasPlotType.

@Test
public void serializePlotTypeOfCombinedPlot_resultJsonHasPlotType() throws IOException {
    // when
    CombinedPlot combinedPlot = new CombinedPlot();
    combinedPlot.add(new Plot());
    combinedPlot.add(new Plot());
    combinedPlotSerializer.serialize(combinedPlot, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("plot_type")).isTrue();
    Assertions.assertThat(actualObj.get("plot_type").asText()).isEqualTo("Plot");
}
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 18 with Plot

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

the class CombinedPlotSerializerTest method serializePlotsOfCombinedPlot_resultJsonHasPlots.

@Test
public void serializePlotsOfCombinedPlot_resultJsonHasPlots() throws IOException {
    // when
    CombinedPlot combinedPlot = new CombinedPlot();
    combinedPlot.add(new Plot());
    combinedPlot.add(new Plot());
    combinedPlotSerializer.serialize(combinedPlot, jgen, new DefaultSerializerProvider.Impl());
    jgen.flush();
    // then
    JsonNode actualObj = mapper.readTree(sw.toString());
    Assertions.assertThat(actualObj.has("plots")).isTrue();
    Assertions.assertThat(actualObj.get("plots")).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 19 with Plot

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

the class ChartObjectManagerTest method registerChart_containsThatChart.

@Test
public void registerChart_containsThatChart() {
    Chart chart = new Plot();
    // when
    chartObjectManager.registerChart("id1", chart);
    // then
    Assertions.assertThat(chartObjectManager.getChart("id1")).isEqualTo(chart);
}
Also used : Plot(com.twosigma.beakerx.chart.xychart.Plot) Chart(com.twosigma.beakerx.chart.Chart) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 20 with Plot

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

the class GroovyEvaluatorChartTest method parsePlotWithTitleScript_returnPlotObjectWithTitle.

@Test
public void parsePlotWithTitleScript_returnPlotObjectWithTitle() {
    // when
    Object result = parseClassFromScript("def plot = new Plot(title: \"Setting line properties\")");
    // then
    Assertions.assertThat(result instanceof Plot).isTrue();
    Plot plot = (Plot) result;
    Assertions.assertThat(plot.getTitle()).isEqualTo("Setting line properties");
}
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