Search in sources :

Example 6 with Line

use of com.twosigma.beakerx.chart.xychart.plotitem.Line in project beakerx by twosigma.

the class SimpleTimePlot method reinitialize.

private void reinitialize() {
    List<XYGraphics> graphics = getGraphics();
    filter(graphics, new Predicate<XYGraphics>() {

        public boolean test(XYGraphics graphic) {
            return !(graphic instanceof Line || graphic instanceof Points);
        }
    });
    List<Object> xs = new ArrayList<>();
    List<List<Number>> yss = new ArrayList<>();
    Set<String> dataColumnsNames = new HashSet<>();
    if (data != null && columns != null) {
        for (Map<String, Object> row : data) {
            dataColumnsNames.addAll(row.keySet());
            xs.add(getNumberForTimeColumn(row.get(timeColumn)));
            for (int i = 0; i < columns.size(); i++) {
                String column = columns.get(i);
                if (i >= yss.size()) {
                    yss.add(new ArrayList<Number>());
                }
                yss.get(i).add(getNumberForTimeColumn(row.get(column)));
            }
        }
        final HashSet<String> columnsWithoutData = getColumnsWithoutData(dataColumnsNames);
        if (!columnsWithoutData.isEmpty()) {
            throw new IllegalArgumentException(String.format("Chart data not found for columns: %s", columnsWithoutData));
        }
        List<Color> colors = getChartColors();
        for (int i = 0; i < yss.size(); i++) {
            List<Number> ys = yss.get(i);
            if (displayLines) {
                Line line = new Line();
                line.setX(xs);
                line.setY(ys);
                if (displayNames != null && i < displayNames.size()) {
                    line.setDisplayName(displayNames.get(i));
                } else {
                    line.setDisplayName(columns.get(i));
                }
                if (i < colors.size()) {
                    line.setColor(colors.get(i));
                }
                add(line);
            }
            if (displayPoints) {
                Points points = new Points();
                points.setX(xs);
                points.setY(ys);
                if (displayNames != null && i < displayNames.size()) {
                    points.setDisplayName(displayNames.get(i));
                } else {
                    points.setDisplayName(columns.get(i));
                }
                if (i < colors.size()) {
                    points.setColor(colors.get(i));
                }
                add(points);
            }
        }
    }
}
Also used : Color(com.twosigma.beakerx.chart.Color) XYGraphics(com.twosigma.beakerx.chart.xychart.plotitem.XYGraphics) Line(com.twosigma.beakerx.chart.xychart.plotitem.Line) Points(com.twosigma.beakerx.chart.xychart.plotitem.Points)

Example 7 with Line

use of com.twosigma.beakerx.chart.xychart.plotitem.Line in project beakerx by twosigma.

the class XYGraphicsSerializerTest 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 8 with Line

use of com.twosigma.beakerx.chart.xychart.plotitem.Line in project beakerx by twosigma.

the class LineSerializerTest 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 9 with Line

use of com.twosigma.beakerx.chart.xychart.plotitem.Line in project beakerx by twosigma.

the class PlotTest method initStubData.

@Before
public void initStubData() {
    plot = new Plot();
    line = new Line();
    line.setX(Arrays.asList(1, 2, 3));
    line.setY(Arrays.asList(2, 3, 4));
    area = new Area();
    area.setX(Arrays.asList(1, 2, 3));
    area.setY(Arrays.asList(2, 3, 4));
}
Also used : Line(com.twosigma.beakerx.chart.xychart.plotitem.Line) ConstantLine(com.twosigma.beakerx.chart.xychart.plotitem.ConstantLine) Area(com.twosigma.beakerx.chart.xychart.plotitem.Area) Before(org.junit.Before)

Example 10 with Line

use of com.twosigma.beakerx.chart.xychart.plotitem.Line in project beakerx by twosigma.

the class NanoPlotTest method initStubData.

@Before
public void initStubData() {
    BigInteger val1 = new BigInteger("12345678901234567891000");
    BigInteger val2 = new BigInteger("12345678901234567892000");
    points = new Points();
    points.setX(Arrays.asList(val1, val2));
    points.setY(Arrays.asList(2, 3));
    line = new Line();
    line.setX(Arrays.asList(val1, val1));
    line.setY(Arrays.asList(2, 3));
}
Also used : Line(com.twosigma.beakerx.chart.xychart.plotitem.Line) Points(com.twosigma.beakerx.chart.xychart.plotitem.Points) BigInteger(java.math.BigInteger) Before(org.junit.Before)

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