use of com.twosigma.beakerx.chart.xychart.plotitem.XYGraphics in project beakerx by twosigma.
the class SimpleTimePlot method setDisplayNames.
public void setDisplayNames(List<String> displayNames) {
this.displayNames = displayNames;
if (displayNames != null) {
List<XYGraphics> graphics = getGraphics();
int i = 0;
for (XYGraphics graphic : graphics) {
if (graphic instanceof Line) {
graphic.setDisplayName(displayNames.get(++i));
}
}
}
}
use of com.twosigma.beakerx.chart.xychart.plotitem.XYGraphics in project beakerx by twosigma.
the class ChartToJson method serializeXYGraphics.
public static Map<Object, Object> serializeXYGraphics(List<XYGraphics> xyGraphics) {
List result = new ArrayList();
for (XYGraphics item : xyGraphics) {
result.add(toJson(item));
}
Map<Object, Object> value = new LinkedHashMap<>();
value.put(XYChartSerializer.GRAPHICS_LIST, toJsonList(result));
return value;
}
use of com.twosigma.beakerx.chart.xychart.plotitem.XYGraphics in project beakerx by twosigma.
the class MIMEContainerFactory method createMIMEContainersFromObject.
private static List<MIMEContainer> createMIMEContainersFromObject(final Object data) {
Object input = DisplayerDataMapper.convert(data);
if (input instanceof DisplayableWidget) {
((DisplayableWidget) input).display();
return HIDDEN_MIME;
}
TableDisplay table = getTableDisplay(input);
if (table != null) {
table.display();
return HIDDEN_MIME;
}
if (input instanceof Collection) {
return singletonList(MIMEContainer.Text(collectionToString((Collection<?>) input)));
}
if (input instanceof XYGraphics) {
new Plot().add((XYGraphics) input).display();
return HIDDEN_MIME;
}
if (input instanceof MIMEContainer) {
return singletonList((MIMEContainer) input);
}
return Displayers.display(input).entrySet().stream().map(item -> new MIMEContainer(item.getKey(), item.getValue())).collect(Collectors.toList());
}
use of com.twosigma.beakerx.chart.xychart.plotitem.XYGraphics 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);
}
}
}
}
Aggregations