Class JsFigure
The Deephaven JS API supports automatic lossless downsampling of time-series data, when that data is plotted in one
or more line series. Using a scatter plot or a X-axis of some type other than DateTime will prevent this feature from
being applied to a series. To enable this feature, invoke Axis.range to
specify the length in pixels of the axis on the screen, and the range of values that are visible, and the server will
use that width (and range, if any) to reduce the number of points sent to the client.
Downsampling can also be controlled when calling either Figure.subscribe or
Series.subscribe - both can be given an optional
DownsampleOptions argument. Presently only two valid values exist, DownsampleOptions.DEFAULT and
DownsampleOptions.DISABLE, and if no argument is specified, DEFAULT is assumed. If there are more
than 30,000 rows in a table, downsampling will be encouraged - data will not load without calling
subscribe(DISABLE) or enabling downsampling via Axis.range. If
there are more than 200,000 rows, data will refuse to load without downsampling and subscribe(DISABLE) would
have no effect.
Downsampled data looks like normal data, except that select items have been removed if they would be redundant in the UI given the current configuration. Individual rows are intact, so that a tooltip or some other UI item is sure to be accurate and consistent, and at least the highest and lowest value for each axis will be retained as well, to ensure that the "important" values are visible.
Four events exist to help with interacting with downsampled data, all fired from the Figure instance itself.
First, EVENT_DOWNSAMPLENEEDED indicates that more than 30,000 rows would be fetched, and so specifying
downsampling is no longer optional - it must either be enabled (calling Axis.range), or disabled. If the figure is configured for downsampling, when a change takes place that requires that
the server perform some downsampling work, the EVENT_DOWNSAMPLESTARTED event will first be fired, which can
be used to present a brief loading message, indicating to the user why data is not ready yet - when the server side
process is complete, EVENT_DOWNSAMPLEFINISHED will be fired. These events will repeat when the range
changes, such as when zooming, panning, or resizing the figure. Finally, EVENT_DOWNSAMPLEFAILED indicates
that something went wrong when downsampling, or possibly that downsampling cannot be disabled due to the number of
rows in the table.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classTracks ranges that an axis has registered for.static classstatic interfaceclassError details for a failed figure fetch.classIndicates that a series data source could not be resolved or used for this figure.static interfacestatic classNested classes/interfaces inherited from class io.deephaven.web.client.api.event.HasEventHandling
HasEventHandling.EventPair<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThis figure has lost its connection to the server.static final StringDownsampling failed for some reason on one or more series.static final StringDownsampling has finished on the givenSeriesinstances, and data will arrive shortly.static final StringThere are too many points to be drawn in the table which backs these series, and downsampling should be enabled.static final StringThe API is updating how downsampling works on this Figure, probably in response to a call toAxis.rangeorsubscribe.static final StringThis figure has reconnected to the server, and all of its tables are ready to deliver data again.static final StringThis figure failed to reconnect to the server, and is no longer usable.static final StringA series used within this figure was added as part of a multi-series in a chart.static final StringThe data within this figure was updated.Fields inherited from class io.deephaven.web.client.api.event.HasEventHandling
INTERNAL_EVENT_RELEASED -
Constructor Summary
ConstructorsConstructorDescriptionJsFigure(WorkerConnection connection, Supplier<elemental2.promise.Promise<FetchObjectResponse>> fetch) JsFigure(Supplier<elemental2.promise.Promise<FetchObjectResponse>> fetch, JsFigure.FigureTableFetch tableFetch) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the figure, and clean up subscriptions.voiddownsampleFailed(String message, Set<JsSeries> series, double tableSize) voiddownsampleNeeded(String message, Set<JsSeries> series, double tableSize) voidJsChart[]The charts to draw.intgetCols()The number of columns in this figure's chart layout.elemental2.core.JsArray<String> Any errors that the server reported while building this figure.intgetRows()The number of rows in this figure's chart layout.@JsNullable StringgetTitle()The title of the figure, or null if no title was set.The color to use when drawing the figure's title.The font to use when drawing the figure's title.doubleThe update interval of this figure, in milliseconds.voidAsks the figure to fire a reconnect event after its tables are ready.elemental2.promise.Promise<JsFigure> refetch()Indicate that a new session has been created on the server, and this object should re-create its corresponding server-side object if possible.intregisterTable(JsTable table) voidEnable updates for all series in this figure.voidsubscribe(@JsNullable DownsampleOptions forceDisableDownsample) Subscribe to the underlying tables to receive updates for all series in this figure.voidDisable updates for all series in this figure.voidupdateDownsampleRange(FigureDescriptor.AxisDescriptor axis, Integer pixels, Long min, Long max) voidVerifies that the underlying tables have the columns the series are expected.Methods inherited from class io.deephaven.web.client.api.lifecycle.HasLifecycle
die, disconnected, nextReconnectMethods inherited from class io.deephaven.web.client.api.event.HasEventHandling
addEventListener, addEventListenerOneShot, addEventListenerOneShot, failureHandled, fireCriticalEvent, fireCriticalEvent, fireEvent, fireEvent, fireEvent, hasListener, hasListeners, isSuppress, logPrefix, nextEvent, removeEventListener, suppressEvents, unsuppressEvents
-
Field Details
-
EVENT_UPDATED
The data within this figure was updated.event.detailisFigureUpdateEventData.- See Also:
-
EVENT_SERIES_ADDED
A series used within this figure was added as part of a multi-series in a chart. The series instance is the detail for this event.- See Also:
-
EVENT_DISCONNECT
This figure has lost its connection to the server. No further events will be fired, and no data will update, until either the connection is reestablished andEVENT_RECONNECTis fired, orEVENT_RECONNECTFAILEDfires, indicating that it wasn't possible to reconnect and the figure should be recreated/refetched.- See Also:
-
EVENT_RECONNECT
This figure has reconnected to the server, and all of its tables are ready to deliver data again. Any subscriptions that were active before the disconnect are restored.- See Also:
-
EVENT_RECONNECTFAILED
This figure failed to reconnect to the server, and is no longer usable. Theevent.detailvalue is aFigureFetchErrordescribing what went wrong.- See Also:
-
EVENT_DOWNSAMPLESTARTED
The API is updating how downsampling works on this Figure, probably in response to a call toAxis.rangeorsubscribe. Theevent.detailvalue is an array ofSeriesinstances which are affected by this.- See Also:
-
EVENT_DOWNSAMPLEFINISHED
Downsampling has finished on the givenSeriesinstances, and data will arrive shortly. Theevent.detailvalue is the array ofSeriesinstances.- See Also:
-
EVENT_DOWNSAMPLEFAILED
Downsampling failed for some reason on one or more series. Theevent.detailobject has three properties: themessagestring describing what went wrong, thesizenumber showing the full size of the table, and theseriesproperty, an array ofSeriesinstances affected.- See Also:
-
EVENT_DOWNSAMPLENEEDED
There are too many points to be drawn in the table which backs these series, and downsampling should be enabled. As an alternative, downsampling can be explicitly disabled, provided there are less than 200,000 rows in the table. Theevent.detailobject has the same properties asEVENT_DOWNSAMPLEFAILED.- See Also:
-
-
Constructor Details
-
JsFigure
@JsIgnore public JsFigure(WorkerConnection connection, Supplier<elemental2.promise.Promise<FetchObjectResponse>> fetch) -
JsFigure
@JsIgnore public JsFigure(Supplier<elemental2.promise.Promise<FetchObjectResponse>> fetch, JsFigure.FigureTableFetch tableFetch)
-
-
Method Details
-
refetch
Description copied from class:HasLifecycleIndicate that a new session has been created on the server, and this object should re-create its corresponding server-side object if possible. Override this to implement custom behavior, being sure to call reconnect() when finished.- Overrides:
refetchin classHasLifecycle- Returns:
- a promise that will resolve when this object is reconnected
-
reconnect
@JsIgnore public void reconnect()Asks the figure to fire a reconnect event after its tables are ready.- Overrides:
reconnectin classHasLifecycle
-
getTitle
The title of the figure, or null if no title was set. -
getTitleFont
The font to use when drawing the figure's title. -
getTitleColor
The color to use when drawing the figure's title. -
getUpdateInterval
@JsProperty public double getUpdateInterval()The update interval of this figure, in milliseconds. -
getCols
@JsProperty public int getCols()The number of columns in this figure's chart layout. -
getRows
@JsProperty public int getRows()The number of rows in this figure's chart layout. -
getCharts
The charts to draw. -
getErrors
Any errors that the server reported while building this figure. -
subscribe
@JsIgnore public void subscribe()Enable updates for all series in this figure. -
subscribe
Subscribe to the underlying tables to receive updates for all series in this figure.- Parameters:
forceDisableDownsample- the downsampling behavior to use for every series in this figure. PassDownsampleOptions.DISABLEto load all data without downsampling, or omit the argument to useDownsampleOptions.DEFAULT.
-
unsubscribe
public void unsubscribe()Disable updates for all series in this figure. -
downsampleNeeded
-
downsampleFailed
-
enqueueSubscriptionCheck
@JsIgnore public void enqueueSubscriptionCheck() -
verifyTables
@JsIgnore public void verifyTables()Verifies that the underlying tables have the columns the series are expected. Throws an FigureSourceException if not found -
close
public void close()Close the figure, and clean up subscriptions. -
registerTable
-
updateDownsampleRange
@JsIgnore public void updateDownsampleRange(FigureDescriptor.AxisDescriptor axis, Integer pixels, Long min, Long max)
-