Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MultiXYErrorBarSeries, MultiOHLCSeries figures #4763

Merged
merged 7 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,26 @@ public OHLCDataSeriesInternal createSeries(String seriesName, final BaseTable t,
timeCol, openCol, highCol, lowCol, closeCol);
}

public String getTimeCol() {
return timeCol;
}

public String getOpenCol() {
return openCol;
}

public String getHighCol() {
return highCol;
}

public String getLowCol() {
return lowCol;
}

public String getCloseCol() {
return closeCol;
}

////////////////////////////// CODE BELOW HERE IS GENERATED -- DO NOT EDIT BY HAND //////////////////////////////
////////////////////////////// TO REGENERATE RUN GenerateMultiSeries //////////////////////////////
////////////////////////////// AND THEN RUN GenerateFigureImmutable //////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,30 @@ public XYErrorBarDataSeriesInternal createSeries(String seriesName, final BaseTa
drawXError, drawYError);
}

public boolean getDrawXError() {
return drawXError;
}

public boolean getDrawYError() {
return drawYError;
}

public String getXLow() {
return xLow;
}

public String getXHigh() {
return xHigh;
}

public String getYLow() {
return yLow;
}

public String getYHigh() {
return yHigh;
}

////////////////////////////// CODE BELOW HERE IS GENERATED -- DO NOT EDIT BY HAND //////////////////////////////
////////////////////////////// TO REGENERATE RUN GenerateMultiSeries //////////////////////////////
////////////////////////////// AND THEN RUN GenerateFigureImmutable //////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import io.deephaven.plot.datasets.multiseries.AbstractMultiSeries;
import io.deephaven.plot.datasets.multiseries.AbstractPartitionedTableHandleMultiSeries;
import io.deephaven.plot.datasets.multiseries.MultiCatSeries;
import io.deephaven.plot.datasets.multiseries.MultiOHLCSeries;
import io.deephaven.plot.datasets.multiseries.MultiXYErrorBarSeries;
import io.deephaven.plot.datasets.multiseries.MultiXYSeries;
import io.deephaven.plot.datasets.ohlc.OHLCDataSeriesArray;
import io.deephaven.plot.datasets.xy.AbstractXYDataSeries;
Expand Down Expand Up @@ -518,6 +520,119 @@ private FigureDescriptor.ChartDescriptor translate(ChartImpl chart) {
clientSeries.setPointShape(stringMapWithDefault(mergeShapes(
multiCatSeries.pointShapeSeriesNameToStringMap(),
multiCatSeries.pointShapeSeriesNameToShapeMap())));
} else if (partitionedTableMultiSeries instanceof MultiXYErrorBarSeries) {
MultiXYErrorBarSeries multiXYErrorBarSeries =
(MultiXYErrorBarSeries) partitionedTableMultiSeries;

clientAxes.add(makePartitionedTableSourceDescriptor(
plotHandle, multiXYErrorBarSeries.getX(), SourceType.X, xAxis));
if (multiXYErrorBarSeries.getDrawXError()) {
clientAxes.add(makePartitionedTableSourceDescriptor(
plotHandle, multiXYErrorBarSeries.getXLow(), SourceType.X_LOW, xAxis));
clientAxes.add(makePartitionedTableSourceDescriptor(
plotHandle, multiXYErrorBarSeries.getXHigh(), SourceType.X_HIGH,
xAxis));
}

clientAxes.add(makePartitionedTableSourceDescriptor(
plotHandle, multiXYErrorBarSeries.getY(), SourceType.Y, yAxis));
if (multiXYErrorBarSeries.getDrawYError()) {
clientAxes.add(makePartitionedTableSourceDescriptor(
plotHandle, multiXYErrorBarSeries.getYLow(), SourceType.Y_LOW, yAxis));
clientAxes.add(makePartitionedTableSourceDescriptor(
plotHandle, multiXYErrorBarSeries.getYHigh(), SourceType.Y_HIGH,
yAxis));
}

clientSeries.setLineColor(stringMapWithDefault(mergeColors(
multiXYErrorBarSeries.lineColorSeriesNameTointMap(),
multiXYErrorBarSeries.lineColorSeriesNameToStringMap(),
multiXYErrorBarSeries.lineColorSeriesNameToPaintMap())));
Comment on lines +548 to +550
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of these methods seem to be shared by all the AbstractPartitionedTableHandleMultiSeries types, and could probably be cleaned up further. I haven't done that, as I didn't want to change too much in this change, and I'm not entirely sure how the autogenerated parts of these series works.

clientSeries.setPointColor(stringMapWithDefault(mergeColors(
multiXYErrorBarSeries.pointColorSeriesNameTointMap(),
multiXYErrorBarSeries.pointColorSeriesNameToStringMap(),
multiXYErrorBarSeries.pointColorSeriesNameToPaintMap())));
clientSeries.setLinesVisible(
boolMapWithDefault(
multiXYErrorBarSeries.linesVisibleSeriesNameToBooleanMap()));
clientSeries.setPointsVisible(
boolMapWithDefault(
multiXYErrorBarSeries.pointsVisibleSeriesNameToBooleanMap()));
clientSeries.setGradientVisible(
boolMapWithDefault(
multiXYErrorBarSeries.gradientVisibleSeriesNameTobooleanMap()));
clientSeries.setPointLabelFormat(stringMapWithDefault(
multiXYErrorBarSeries.pointLabelFormatSeriesNameToStringMap()));
clientSeries.setXToolTipPattern(
stringMapWithDefault(
multiXYErrorBarSeries.xToolTipPatternSeriesNameToStringMap()));
clientSeries.setYToolTipPattern(
stringMapWithDefault(
multiXYErrorBarSeries.yToolTipPatternSeriesNameToStringMap()));
clientSeries.setPointLabel(stringMapWithDefault(
multiXYErrorBarSeries.pointLabelSeriesNameToObjectMap(),
Objects::toString));
clientSeries.setPointSize(doubleMapWithDefault(
multiXYErrorBarSeries.pointSizeSeriesNameToNumberMap(),
number -> number == null ? null : number.doubleValue()));

clientSeries.setPointShape(stringMapWithDefault(mergeShapes(
multiXYErrorBarSeries.pointShapeSeriesNameToStringMap(),
multiXYErrorBarSeries.pointShapeSeriesNameToShapeMap())));
} else if (partitionedTableMultiSeries instanceof MultiOHLCSeries) {
MultiOHLCSeries multiOHLCSeries =
(MultiOHLCSeries) partitionedTableMultiSeries;

clientAxes.add(makePartitionedTableSourceDescriptor(
plotHandle, multiOHLCSeries.getTimeCol(), SourceType.TIME, xAxis));
clientAxes.add(makePartitionedTableSourceDescriptor(
plotHandle, multiOHLCSeries.getOpenCol(), SourceType.OPEN, yAxis));
clientAxes.add(makePartitionedTableSourceDescriptor(
plotHandle, multiOHLCSeries.getCloseCol(), SourceType.CLOSE, yAxis));
clientAxes.add(makePartitionedTableSourceDescriptor(
plotHandle, multiOHLCSeries.getHighCol(), SourceType.HIGH, yAxis));
clientAxes.add(makePartitionedTableSourceDescriptor(
plotHandle, multiOHLCSeries.getLowCol(), SourceType.LOW, yAxis));

clientSeries.setLineColor(stringMapWithDefault(mergeColors(
multiOHLCSeries.lineColorSeriesNameTointMap(),
multiOHLCSeries.lineColorSeriesNameToStringMap(),
multiOHLCSeries.lineColorSeriesNameToPaintMap())));
clientSeries.setPointColor(stringMapWithDefault(mergeColors(
multiOHLCSeries.pointColorSeriesNameTointMap(),
multiOHLCSeries.pointColorSeriesNameToStringMap(),
multiOHLCSeries.pointColorSeriesNameToPaintMap())));
clientSeries.setLinesVisible(
boolMapWithDefault(
multiOHLCSeries.linesVisibleSeriesNameToBooleanMap()));
clientSeries.setPointsVisible(
boolMapWithDefault(
multiOHLCSeries.pointsVisibleSeriesNameToBooleanMap()));
clientSeries.setGradientVisible(
boolMapWithDefault(
multiOHLCSeries.gradientVisibleSeriesNameTobooleanMap()));
clientSeries.setPointLabelFormat(stringMapWithDefault(
multiOHLCSeries.pointLabelFormatSeriesNameToStringMap()));
clientSeries.setXToolTipPattern(
stringMapWithDefault(
multiOHLCSeries.xToolTipPatternSeriesNameToStringMap()));
clientSeries.setYToolTipPattern(
stringMapWithDefault(
multiOHLCSeries.yToolTipPatternSeriesNameToStringMap()));
clientSeries.setPointLabel(stringMapWithDefault(
multiOHLCSeries.pointLabelSeriesNameToObjectMap(),
Objects::toString));
clientSeries.setPointSize(doubleMapWithDefault(
multiOHLCSeries.pointSizeSeriesNameToNumberMap(),
number -> number == null ? null : number.doubleValue()));

clientSeries.setPointShape(stringMapWithDefault(mergeShapes(
multiOHLCSeries.pointShapeSeriesNameToStringMap(),
multiOHLCSeries.pointShapeSeriesNameToShapeMap())));
} else {
errorList.add(
"OpenAPI presently does not support series of type "
+ partitionedTableMultiSeries.getClass());
}
} else {
errorList.add(
Expand All @@ -530,7 +645,6 @@ private FigureDescriptor.ChartDescriptor translate(ChartImpl chart) {
} else {
errorList.add(
"OpenAPI presently does not support series of type " + seriesInternal.getClass());
// TODO handle multi-series, possibly transformed case?
}
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ public String toString() {

private JsChart[] charts;

private JsArray<String> errors;

private JsTable[] tables;
private Map<Integer, JsTable> plotHandlesToTables;

Expand Down Expand Up @@ -201,6 +203,8 @@ public Promise<JsFigure> refetch() {
.map(chartDescriptor -> new JsChart(chartDescriptor, this)).toArray(JsChart[]::new);
JsObject.freeze(charts);

errors = JsObject.freeze(descriptor.getErrorsList().slice());

return this.tableFetch.fetch(this, response);
}).then(tableFetchData -> {
// all tables are wired up, need to map them to the series instances
Expand Down Expand Up @@ -324,8 +328,9 @@ public JsChart[] getCharts() {
return charts;
}

public String[] getErrors() {
return Js.uncheckedCast(descriptor.getErrorsList().slice());
@JsProperty
public JsArray<String> getErrors() {
return errors;
}

/**
Expand Down
Loading