Search in sources :

Example 1 with SimpleTimePlot

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

the class CombinedPlotSerializerTest method serializeTimePlotTypeOfCombinedPlot_resultJsonHasTimePlotType.

@Test
public void serializeTimePlotTypeOfCombinedPlot_resultJsonHasTimePlotType() throws IOException {
    // when
    CombinedPlot combinedPlot = new CombinedPlot();
    combinedPlot.add(new SimpleTimePlot(createDataForSimpleTimePlot(), Arrays.asList("m3", "time")));
    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("TimePlot");
}
Also used : DefaultSerializerProvider(com.fasterxml.jackson.databind.ser.DefaultSerializerProvider) SimpleTimePlot(com.twosigma.beakerx.chart.xychart.SimpleTimePlot) JsonNode(com.fasterxml.jackson.databind.JsonNode) CombinedPlot(com.twosigma.beakerx.chart.xychart.CombinedPlot) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Example 2 with SimpleTimePlot

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

the class GroovyEvaluatorChartTest method parseSimpleTimePlotScript_returnSimpleTimePlotObjectWithData.

@Test
public void parseSimpleTimePlotScript_returnSimpleTimePlotObjectWithData() {
    // when
    Object result = parseClassFromScript("def rates = (1..10).collect{[\"y1\": 1 + it, \"y10\": 2 + it, \"time\" : 633733200000 + 10000*it]}\n" + "new SimpleTimePlot(rates, [\"y1\", \"y10\"],\n" + "                   yLabel: \"Price\", \n" + "                   displayNames: [\"1 Year\", \"10 Year\"])");
    // then
    Assertions.assertThat(result instanceof SimpleTimePlot).isTrue();
    SimpleTimePlot simpleTimePlot = (SimpleTimePlot) result;
    Assertions.assertThat(simpleTimePlot.getData()).isNotEmpty();
}
Also used : SimpleTimePlot(com.twosigma.beakerx.chart.xychart.SimpleTimePlot) Test(org.junit.Test)

Example 3 with SimpleTimePlot

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

the class DisplayOutputContainerTest method display_shouldDisplayOutputContainerWithTabLayout.

@Test
public void display_shouldDisplayOutputContainerWithTabLayout() throws Exception {
    // given
    List<Map<String, Object>> values = ResourceLoaderTest.readAsList("tableRowsTest.csv");
    OutputContainer oc = new OutputContainer();
    SimpleTimePlot simpleTimePlot = new SimpleTimePlot(values, Arrays.asList("m3", "y1"));
    oc.setLayoutManager(new TabbedOutputContainerLayoutManager());
    oc.addItem(simpleTimePlot, "Scatter with History");
    // when
    oc.display();
    // then
    verifyTabLayout(kernel.getPublishedMessages());
}
Also used : SimpleTimePlot(com.twosigma.beakerx.chart.xychart.SimpleTimePlot) Map(java.util.Map) ResourceLoaderTest(com.twosigma.beakerx.ResourceLoaderTest) Test(org.junit.Test) KernelTest(com.twosigma.beakerx.KernelTest)

Aggregations

SimpleTimePlot (com.twosigma.beakerx.chart.xychart.SimpleTimePlot)3 Test (org.junit.Test)3 KernelTest (com.twosigma.beakerx.KernelTest)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)1 ResourceLoaderTest (com.twosigma.beakerx.ResourceLoaderTest)1 CombinedPlot (com.twosigma.beakerx.chart.xychart.CombinedPlot)1 Map (java.util.Map)1