@deephaven/js-plugin-plotly-express 0.3.2-deephaven-ui.216 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PlotlyExpressChart.d.ts +6 -0
- package/dist/PlotlyExpressChart.d.ts.map +1 -0
- package/dist/PlotlyExpressChart.js +36 -0
- package/dist/PlotlyExpressChart.js.map +1 -0
- package/dist/PlotlyExpressChartModel.d.ts +50 -13
- package/dist/PlotlyExpressChartModel.d.ts.map +1 -1
- package/dist/PlotlyExpressChartModel.js +202 -63
- package/dist/PlotlyExpressChartModel.js.map +1 -1
- package/dist/PlotlyExpressChartPanel.d.ts +3 -9
- package/dist/PlotlyExpressChartPanel.d.ts.map +1 -1
- package/dist/PlotlyExpressChartPanel.js +9 -45
- package/dist/PlotlyExpressChartPanel.js.map +1 -1
- package/dist/PlotlyExpressChartUtils.d.ts +17 -18
- package/dist/PlotlyExpressChartUtils.d.ts.map +1 -1
- package/dist/PlotlyExpressChartUtils.js +7 -10
- package/dist/PlotlyExpressChartUtils.js.map +1 -1
- package/dist/PlotlyExpressPlugin.d.ts +5 -0
- package/dist/PlotlyExpressPlugin.d.ts.map +1 -0
- package/dist/PlotlyExpressPlugin.js +14 -0
- package/dist/PlotlyExpressPlugin.js.map +1 -0
- package/dist/bundle/index.js +66290 -68973
- package/dist/bundle/style.css +654 -1170
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/useHandleSceneTicks.d.ts +4 -0
- package/dist/useHandleSceneTicks.d.ts.map +1 -0
- package/dist/useHandleSceneTicks.js +36 -0
- package/dist/useHandleSceneTicks.js.map +1 -0
- package/package.json +13 -11
- package/dist/DashboardPlugin.d.ts +0 -5
- package/dist/DashboardPlugin.d.ts.map +0 -1
- package/dist/DashboardPlugin.js +0 -39
- package/dist/DashboardPlugin.js.map +0 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { Widget } from '@deephaven/jsapi-types';
|
|
3
|
+
import { type WidgetComponentProps } from '@deephaven/plugin';
|
|
4
|
+
export declare function PlotlyExpressChart(props: WidgetComponentProps<Widget>): JSX.Element | null;
|
|
5
|
+
export default PlotlyExpressChart;
|
|
6
|
+
//# sourceMappingURL=PlotlyExpressChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlotlyExpressChart.d.ts","sourceRoot":"","sources":["../src/PlotlyExpressChart.tsx"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAK9D,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,oBAAoB,CAAC,MAAM,CAAC,GAClC,GAAG,CAAC,OAAO,GAAG,IAAI,CAiCpB;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Plotly from 'plotly.js-dist-min';
|
|
4
|
+
import { Chart } from '@deephaven/chart';
|
|
5
|
+
import { useApi } from '@deephaven/jsapi-bootstrap';
|
|
6
|
+
import PlotlyExpressChartModel from './PlotlyExpressChartModel.js';
|
|
7
|
+
import { useHandleSceneTicks } from './useHandleSceneTicks.js';
|
|
8
|
+
export function PlotlyExpressChart(props) {
|
|
9
|
+
const dh = useApi();
|
|
10
|
+
const { fetch } = props;
|
|
11
|
+
const containerRef = useRef(null);
|
|
12
|
+
const [model, setModel] = useState();
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
let cancelled = false;
|
|
15
|
+
async function init() {
|
|
16
|
+
const widgetData = await fetch();
|
|
17
|
+
if (!cancelled) {
|
|
18
|
+
setModel(new PlotlyExpressChartModel(dh, widgetData, fetch));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
init();
|
|
22
|
+
return () => {
|
|
23
|
+
cancelled = true;
|
|
24
|
+
};
|
|
25
|
+
}, [dh, fetch]);
|
|
26
|
+
useHandleSceneTicks(model, containerRef.current);
|
|
27
|
+
return model ? (_jsx(Chart
|
|
28
|
+
// eslint-disable-next-line react/jsx-props-no-spreading, @typescript-eslint/ban-ts-comment
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
, {
|
|
31
|
+
// eslint-disable-next-line react/jsx-props-no-spreading, @typescript-eslint/ban-ts-comment
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
containerRef: containerRef, model: model, Plotly: Plotly })) : null;
|
|
34
|
+
}
|
|
35
|
+
export default PlotlyExpressChart;
|
|
36
|
+
//# sourceMappingURL=PlotlyExpressChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlotlyExpressChart.js","sourceRoot":"","sources":["../src/PlotlyExpressChart.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,uBAAuB,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,UAAU,kBAAkB,CAChC,KAAmC;IAEnC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IACpB,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IACxB,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAClD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAA2B,CAAC;IAE9D,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,KAAK,UAAU,IAAI;YACjB,MAAM,UAAU,GAAG,MAAM,KAAK,EAAE,CAAC;YACjC,IAAI,CAAC,SAAS,EAAE;gBACd,QAAQ,CAAC,IAAI,uBAAuB,CAAC,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;aAC9D;QACH,CAAC;QAED,IAAI,EAAE,CAAC;QAEP,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;IAEhB,mBAAmB,CAAC,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAEjD,OAAO,KAAK,CAAC,CAAC,CAAC,CACb,KAAC,KAAK;IACJ,2FAA2F;IAC3F,aAAa;;QADb,2FAA2F;QAC3F,aAAa;QACb,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,GACd,CACH,CAAC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,30 +1,67 @@
|
|
|
1
1
|
import type { Layout, Data } from 'plotly.js';
|
|
2
|
-
import type { dh as DhType, ChartData, Table, TableSubscription } from '@deephaven/jsapi-types';
|
|
2
|
+
import type { dh as DhType, ChartData, Widget, Table, TableSubscription, TableData } from '@deephaven/jsapi-types';
|
|
3
3
|
import { ChartModel, ChartUtils, ChartTheme } from '@deephaven/chart';
|
|
4
|
+
import { PlotlyChartWidgetData } from './PlotlyExpressChartUtils.js';
|
|
4
5
|
export declare class PlotlyExpressChartModel extends ChartModel {
|
|
5
|
-
constructor(dh: DhType,
|
|
6
|
+
constructor(dh: DhType, widget: Widget, refetch: () => Promise<Widget>, theme?: ChartTheme);
|
|
7
|
+
isSubscribed: boolean;
|
|
6
8
|
chartUtils: ChartUtils;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
refetch: () => Promise<Widget>;
|
|
10
|
+
widget?: Widget;
|
|
11
|
+
widgetUnsubscribe?: () => void;
|
|
12
|
+
/**
|
|
13
|
+
* Map of table index to Table object.
|
|
14
|
+
*/
|
|
15
|
+
tableReferenceMap: Map<number, Table>;
|
|
16
|
+
/**
|
|
17
|
+
* Map of table index to TableSubscription object.
|
|
18
|
+
*/
|
|
19
|
+
tableSubscriptionMap: Map<number, TableSubscription>;
|
|
20
|
+
/**
|
|
21
|
+
* Map of table index to cleanup function for the subscription.
|
|
22
|
+
*/
|
|
23
|
+
subscriptionCleanupMap: Map<number, () => void>;
|
|
24
|
+
/**
|
|
25
|
+
* Map of table index to map of column names to array of paths where the data should be replaced.
|
|
26
|
+
*/
|
|
27
|
+
tableColumnReplacementMap: Map<number, Map<string, string[]>>;
|
|
28
|
+
/**
|
|
29
|
+
* Map of table index to ChartData object. Used to handle data delta updates.
|
|
30
|
+
*/
|
|
31
|
+
chartDataMap: Map<number, ChartData>;
|
|
32
|
+
/**
|
|
33
|
+
* Map of table index to object where the keys are column names and the values are arrays of data.
|
|
34
|
+
* This data is the full array of data for the column since ChartData doesn't have a clean way to get it at any time.
|
|
35
|
+
*/
|
|
36
|
+
tableDataMap: Map<number, {
|
|
37
|
+
[key: string]: unknown[];
|
|
38
|
+
}>;
|
|
39
|
+
theme: ChartTheme;
|
|
40
|
+
plotlyData: Data[];
|
|
13
41
|
layout: Partial<Layout>;
|
|
14
42
|
plotlyLayout: Partial<Layout>;
|
|
15
43
|
isPaused: boolean;
|
|
16
44
|
hasPendingUpdate: boolean;
|
|
45
|
+
hasInitialLoadCompleted: boolean;
|
|
17
46
|
getData(): Partial<Data>[];
|
|
18
47
|
getLayout(): Partial<Layout>;
|
|
19
|
-
|
|
48
|
+
close(): void;
|
|
49
|
+
subscribe(callback: (event: CustomEvent) => void): Promise<void>;
|
|
20
50
|
unsubscribe(callback: (event: CustomEvent) => void): void;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
51
|
+
updateLayout(data: PlotlyChartWidgetData): void;
|
|
52
|
+
handleWidgetUpdated(data: PlotlyChartWidgetData, references: Widget['exportedObjects']): void;
|
|
53
|
+
handleFigureUpdated(event: CustomEvent<TableData>, tableId: number): void;
|
|
54
|
+
addTable(id: number, table: Table): void;
|
|
55
|
+
subscribeTable(id: number): void;
|
|
56
|
+
removeTable(id: number): void;
|
|
24
57
|
fireUpdate(data: unknown): void;
|
|
25
58
|
pauseUpdates(): void;
|
|
26
59
|
resumeUpdates(): void;
|
|
27
|
-
|
|
60
|
+
shouldPauseOnUserInteraction(): boolean;
|
|
61
|
+
hasScene(): boolean;
|
|
62
|
+
hasGeo(): boolean;
|
|
63
|
+
hasMapbox(): boolean;
|
|
64
|
+
hasPolar(): boolean;
|
|
28
65
|
getPlotWidth(): number;
|
|
29
66
|
getPlotHeight(): number;
|
|
30
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlotlyExpressChartModel.d.ts","sourceRoot":"","sources":["../src/PlotlyExpressChartModel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EACV,EAAE,IAAI,MAAM,EACZ,SAAS,EACT,KAAK,EACL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"PlotlyExpressChartModel.d.ts","sourceRoot":"","sources":["../src/PlotlyExpressChartModel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EACV,EAAE,IAAI,MAAM,EACZ,SAAS,EACT,MAAM,EACN,KAAK,EACL,iBAAiB,EACjB,SAAS,EACV,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,UAAU,EACV,UAAU,EACV,UAAU,EAEX,MAAM,kBAAkB,C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AkC1B,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAI5B,KAAK;IAMC,SAAS,CACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GACrC,OAAO,CAAC,IAAI,CAAC;IAgCP,WAAW,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,IAAI;IAclE,YAAY,CAAC,IAAI,EAAE,qBAAqB;IAqBxC,mBAAmB,CACjB,IAAI,EAAE,qBAAqB,EAC3B,UAAU,EAAE,MAAM,CAAC,iBAAiB,CAAC,GACpC,IAAI;IA2BP,mBAAmB,CAAC,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAiCzE,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;IAYjC,cAAc,CAAC,EAAE,EAAE,MAAM;IAyBzB,WAAW,CAAC,EAAE,EAAE,MAAM;IAYb,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IAcxC,YAAY,IAAI,IAAI;IAIpB,aAAa,IAAI,IAAI;IAOrB,4BAA4B,IAAI,OAAO;IAMvC,QAAQ,IAAI,OAAO;IAInB,MAAM,IAAI,OAAO;IAIjB,SAAS,IAAI,OAAO;IAIpB,QAAQ,IAAI,OAAO;IAInB,YAAY,IAAI,MAAM;IAatB,aAAa,IAAI,MAAM;CAYxB;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -1,99 +1,226 @@
|
|
|
1
|
-
import { ChartModel, ChartUtils,
|
|
1
|
+
import { ChartModel, ChartUtils, defaultChartTheme, } from '@deephaven/chart';
|
|
2
2
|
import Log from '@deephaven/log';
|
|
3
|
-
import { applyColorwayToData } from './PlotlyExpressChartUtils.js';
|
|
3
|
+
import { applyColorwayToData, getDataMappings, getWidgetData, } from './PlotlyExpressChartUtils.js';
|
|
4
4
|
const log = Log.module('@deephaven/js-plugin-plotly-express.ChartModel');
|
|
5
5
|
export class PlotlyExpressChartModel extends ChartModel {
|
|
6
|
-
constructor(dh,
|
|
7
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
6
|
+
constructor(dh, widget, refetch, theme = defaultChartTheme()) {
|
|
8
7
|
super(dh);
|
|
9
|
-
this.
|
|
8
|
+
this.isSubscribed = false;
|
|
9
|
+
/**
|
|
10
|
+
* Map of table index to Table object.
|
|
11
|
+
*/
|
|
12
|
+
this.tableReferenceMap = new Map();
|
|
13
|
+
/**
|
|
14
|
+
* Map of table index to TableSubscription object.
|
|
15
|
+
*/
|
|
16
|
+
this.tableSubscriptionMap = new Map();
|
|
17
|
+
/**
|
|
18
|
+
* Map of table index to cleanup function for the subscription.
|
|
19
|
+
*/
|
|
20
|
+
this.subscriptionCleanupMap = new Map();
|
|
21
|
+
/**
|
|
22
|
+
* Map of table index to map of column names to array of paths where the data should be replaced.
|
|
23
|
+
*/
|
|
24
|
+
this.tableColumnReplacementMap = new Map();
|
|
25
|
+
/**
|
|
26
|
+
* Map of table index to ChartData object. Used to handle data delta updates.
|
|
27
|
+
*/
|
|
28
|
+
this.chartDataMap = new Map();
|
|
29
|
+
/**
|
|
30
|
+
* Map of table index to object where the keys are column names and the values are arrays of data.
|
|
31
|
+
* This data is the full array of data for the column since ChartData doesn't have a clean way to get it at any time.
|
|
32
|
+
*/
|
|
33
|
+
this.tableDataMap = new Map();
|
|
34
|
+
this.plotlyData = [];
|
|
35
|
+
this.layout = {};
|
|
36
|
+
this.plotlyLayout = {};
|
|
10
37
|
this.isPaused = false;
|
|
11
38
|
this.hasPendingUpdate = false;
|
|
12
|
-
this.
|
|
39
|
+
this.hasInitialLoadCompleted = false;
|
|
40
|
+
this.widget = widget;
|
|
41
|
+
this.refetch = refetch;
|
|
13
42
|
this.chartUtils = new ChartUtils(dh);
|
|
14
|
-
this.tableColumnReplacementMap = new Map(tableColumnReplacementMap);
|
|
15
|
-
this.chartDataMap = new Map();
|
|
16
|
-
this.tableSubscriptionMap = new Map();
|
|
17
43
|
this.theme = theme;
|
|
18
|
-
this.
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
this.plotlyLayout = plotlyLayout;
|
|
26
|
-
this.layout = Object.assign(Object.assign({}, plotlyLayout), { template });
|
|
27
|
-
applyColorwayToData((_g = (_f = (_e = (_d = this.layout) === null || _d === void 0 ? void 0 : _d.template) === null || _e === void 0 ? void 0 : _e.layout) === null || _f === void 0 ? void 0 : _f.colorway) !== null && _g !== void 0 ? _g : [], (_l = (_k = (_j = (_h = this.plotlyLayout) === null || _h === void 0 ? void 0 : _h.template) === null || _j === void 0 ? void 0 : _j.layout) === null || _k === void 0 ? void 0 : _k.colorway) !== null && _l !== void 0 ? _l : [], this.data);
|
|
44
|
+
this.handleFigureUpdated = this.handleFigureUpdated.bind(this);
|
|
45
|
+
this.handleWidgetUpdated = this.handleWidgetUpdated.bind(this);
|
|
46
|
+
// This is mostly used for setting the initial layout.
|
|
47
|
+
// Chart only fetches the model layout once on init, so it needs to be set
|
|
48
|
+
// before the widget is subscribed to.
|
|
49
|
+
this.handleWidgetUpdated(getWidgetData(widget), widget.exportedObjects);
|
|
28
50
|
this.setTitle(this.getDefaultTitle());
|
|
29
51
|
}
|
|
30
52
|
getData() {
|
|
31
|
-
|
|
53
|
+
const hydratedData = [...this.plotlyData];
|
|
54
|
+
this.tableColumnReplacementMap.forEach((columnReplacements, tableId) => {
|
|
55
|
+
const tableData = this.tableDataMap.get(tableId);
|
|
56
|
+
if (tableData == null) {
|
|
57
|
+
throw new Error(`No tableData for table ID ${tableId}`);
|
|
58
|
+
}
|
|
59
|
+
// Replace placeholder arrays with actual data
|
|
60
|
+
columnReplacements.forEach((paths, columnName) => {
|
|
61
|
+
paths.forEach(destination => {
|
|
62
|
+
var _a;
|
|
63
|
+
// The JSON pointer starts w/ /plotly/data and we don't need that part
|
|
64
|
+
const parts = destination
|
|
65
|
+
.split('/')
|
|
66
|
+
.filter(part => part !== '' && part !== 'plotly' && part !== 'data');
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
|
+
let selector = hydratedData;
|
|
69
|
+
for (let i = 0; i < parts.length; i += 1) {
|
|
70
|
+
if (i !== parts.length - 1) {
|
|
71
|
+
selector = selector[parts[i]];
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
selector[parts[i]] = (_a = tableData[columnName]) !== null && _a !== void 0 ? _a : [];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
return hydratedData;
|
|
32
81
|
}
|
|
33
82
|
getLayout() {
|
|
34
83
|
return this.layout;
|
|
35
84
|
}
|
|
36
|
-
|
|
85
|
+
close() {
|
|
86
|
+
var _a;
|
|
87
|
+
super.close();
|
|
88
|
+
(_a = this.widget) === null || _a === void 0 ? void 0 : _a.close();
|
|
89
|
+
this.widget = undefined;
|
|
90
|
+
}
|
|
91
|
+
async subscribe(callback) {
|
|
92
|
+
if (this.isSubscribed) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
37
95
|
super.subscribe(callback);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
96
|
+
if (this.widget == null) {
|
|
97
|
+
this.widget = await this.refetch();
|
|
98
|
+
const widgetData = getWidgetData(this.widget);
|
|
99
|
+
this.handleWidgetUpdated(widgetData, this.widget.exportedObjects);
|
|
100
|
+
}
|
|
101
|
+
this.isSubscribed = true;
|
|
102
|
+
this.widgetUnsubscribe = this.widget.addEventListener(this.dh.Widget.EVENT_MESSAGE, ({ detail }) => {
|
|
103
|
+
this.handleWidgetUpdated(JSON.parse(detail.getDataAsString()), detail.exportedObjects);
|
|
44
104
|
});
|
|
45
|
-
this.
|
|
105
|
+
this.tableReferenceMap.forEach((_, id) => this.subscribeTable(id));
|
|
106
|
+
// If there are no tables to fetch data from, the chart is ready to render
|
|
107
|
+
// Normally this event only fires once at least 1 table has fetched data
|
|
108
|
+
// Without this, the chart shows an infinite loader if there are no tables
|
|
109
|
+
if (this.tableColumnReplacementMap.size === 0) {
|
|
110
|
+
this.fireUpdate(this.getData());
|
|
111
|
+
}
|
|
46
112
|
}
|
|
47
113
|
unsubscribe(callback) {
|
|
114
|
+
var _a, _b;
|
|
115
|
+
if (!this.isSubscribed) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
48
118
|
super.unsubscribe(callback);
|
|
49
|
-
this.
|
|
50
|
-
this.
|
|
51
|
-
this.
|
|
119
|
+
(_a = this.widgetUnsubscribe) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
120
|
+
this.isSubscribed = false;
|
|
121
|
+
this.tableReferenceMap.forEach((_, id) => this.removeTable(id));
|
|
122
|
+
(_b = this.widget) === null || _b === void 0 ? void 0 : _b.close();
|
|
123
|
+
this.widget = undefined;
|
|
52
124
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
125
|
+
updateLayout(data) {
|
|
126
|
+
var _a, _b, _c;
|
|
127
|
+
const { figure } = data;
|
|
128
|
+
const { plotly, deephaven } = figure;
|
|
129
|
+
const { layout: plotlyLayout = {} } = plotly;
|
|
130
|
+
const template = { layout: this.chartUtils.makeDefaultLayout(this.theme) };
|
|
131
|
+
// For now we will only use the plotly theme colorway since most plotly themes are light mode
|
|
132
|
+
if (deephaven.is_user_set_template) {
|
|
133
|
+
template.layout.colorway =
|
|
134
|
+
(_c = (_b = (_a = plotlyLayout.template) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.colorway) !== null && _c !== void 0 ? _c : template.layout.colorway;
|
|
135
|
+
}
|
|
136
|
+
this.plotlyLayout = plotlyLayout;
|
|
137
|
+
this.layout = Object.assign(Object.assign({}, plotlyLayout), { template });
|
|
138
|
+
}
|
|
139
|
+
handleWidgetUpdated(data, references) {
|
|
140
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
141
|
+
const { figure, new_references: newReferences, removed_references: removedReferences, } = data;
|
|
142
|
+
const { plotly } = figure;
|
|
143
|
+
this.tableColumnReplacementMap = getDataMappings(data);
|
|
144
|
+
this.plotlyData = plotly.data;
|
|
145
|
+
this.updateLayout(data);
|
|
146
|
+
applyColorwayToData((_d = (_c = (_b = (_a = this.layout) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.layout) === null || _c === void 0 ? void 0 : _c.colorway) !== null && _d !== void 0 ? _d : [], (_h = (_g = (_f = (_e = this.plotlyLayout) === null || _e === void 0 ? void 0 : _e.template) === null || _f === void 0 ? void 0 : _f.layout) === null || _g === void 0 ? void 0 : _g.colorway) !== null && _h !== void 0 ? _h : [], this.plotlyData);
|
|
147
|
+
newReferences.forEach(async (id, i) => {
|
|
148
|
+
this.tableDataMap.set(id, {}); // Plot may render while tables are being fetched. Set this to avoid a render error
|
|
149
|
+
const table = (await references[i].fetch());
|
|
150
|
+
this.addTable(id, table);
|
|
151
|
+
});
|
|
152
|
+
removedReferences.forEach(id => this.removeTable(id));
|
|
153
|
+
}
|
|
154
|
+
handleFigureUpdated(event, tableId) {
|
|
155
|
+
const chartData = this.chartDataMap.get(tableId);
|
|
156
|
+
const tableData = this.tableDataMap.get(tableId);
|
|
157
|
+
if (chartData == null) {
|
|
158
|
+
log.warn('Unknown chartData for this event. Skipping update');
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (tableData == null) {
|
|
162
|
+
log.warn('No tableData for this event. Skipping update');
|
|
56
163
|
return;
|
|
57
164
|
}
|
|
58
165
|
const { detail: figureUpdateEvent } = event;
|
|
59
166
|
chartData.update(figureUpdateEvent);
|
|
60
|
-
|
|
61
|
-
const columnData = chartData.getColumn(column, val => this.chartUtils.unwrapValue(val), figureUpdateEvent);
|
|
62
|
-
|
|
63
|
-
// The JSON pointer starts w/ /plotly and we don't need that part
|
|
64
|
-
const parts = destination
|
|
65
|
-
.split('/')
|
|
66
|
-
.filter(part => part !== '' && part !== 'plotly');
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias, @typescript-eslint/no-explicit-any
|
|
68
|
-
let selector = this;
|
|
69
|
-
for (let i = 0; i < parts.length; i += 1) {
|
|
70
|
-
if (i !== parts.length - 1) {
|
|
71
|
-
selector = selector[parts[i]];
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
selector[parts[i]] = columnData;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
});
|
|
167
|
+
figureUpdateEvent.columns.forEach(column => {
|
|
168
|
+
const columnData = chartData.getColumn(column.name, val => this.chartUtils.unwrapValue(val), figureUpdateEvent);
|
|
169
|
+
tableData[column.name] = columnData;
|
|
78
170
|
});
|
|
79
|
-
const { data } = this;
|
|
80
171
|
if (this.isPaused) {
|
|
81
172
|
this.hasPendingUpdate = true;
|
|
82
173
|
return;
|
|
83
174
|
}
|
|
84
|
-
this.fireUpdate(
|
|
175
|
+
this.fireUpdate(this.getData());
|
|
85
176
|
}
|
|
86
|
-
|
|
87
|
-
this.
|
|
88
|
-
|
|
89
|
-
}
|
|
177
|
+
addTable(id, table) {
|
|
178
|
+
if (this.tableReferenceMap.has(id)) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
this.tableReferenceMap.set(id, table);
|
|
182
|
+
this.tableDataMap.set(id, {});
|
|
183
|
+
if (this.isSubscribed) {
|
|
184
|
+
this.subscribeTable(id);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
subscribeTable(id) {
|
|
188
|
+
const table = this.tableReferenceMap.get(id);
|
|
189
|
+
const columnReplacements = this.tableColumnReplacementMap.get(id);
|
|
190
|
+
if (table != null &&
|
|
191
|
+
columnReplacements != null &&
|
|
192
|
+
columnReplacements.size > 0 &&
|
|
193
|
+
!this.tableSubscriptionMap.has(id)) {
|
|
194
|
+
this.chartDataMap.set(id, new this.dh.plot.ChartData(table));
|
|
195
|
+
const columnNames = new Set(columnReplacements.keys());
|
|
196
|
+
const columns = table.columns.filter(({ name }) => columnNames.has(name));
|
|
197
|
+
const subscription = table.subscribe(columns);
|
|
198
|
+
this.tableSubscriptionMap.set(id, subscription);
|
|
199
|
+
this.subscriptionCleanupMap.set(id, subscription.addEventListener(this.dh.Table.EVENT_UPDATED, e => this.handleFigureUpdated(e, id)));
|
|
200
|
+
}
|
|
90
201
|
}
|
|
91
|
-
|
|
92
|
-
|
|
202
|
+
removeTable(id) {
|
|
203
|
+
var _a, _b;
|
|
204
|
+
(_a = this.subscriptionCleanupMap.get(id)) === null || _a === void 0 ? void 0 : _a();
|
|
205
|
+
(_b = this.tableSubscriptionMap.get(id)) === null || _b === void 0 ? void 0 : _b.close();
|
|
206
|
+
this.tableReferenceMap.delete(id);
|
|
207
|
+
this.subscriptionCleanupMap.delete(id);
|
|
208
|
+
this.tableSubscriptionMap.delete(id);
|
|
209
|
+
this.chartDataMap.delete(id);
|
|
210
|
+
this.tableDataMap.delete(id);
|
|
211
|
+
this.tableColumnReplacementMap.delete(id);
|
|
93
212
|
}
|
|
94
213
|
fireUpdate(data) {
|
|
95
214
|
super.fireUpdate(data);
|
|
96
215
|
this.hasPendingUpdate = false;
|
|
216
|
+
// TODO: This will fire on first call to `fireUpdate` even though other data
|
|
217
|
+
// may still be loading. We should consider making this smarter to fire after
|
|
218
|
+
// all initial data has loaded.
|
|
219
|
+
// https://github.com/deephaven/deephaven-plugins/issues/267
|
|
220
|
+
if (!this.hasInitialLoadCompleted) {
|
|
221
|
+
this.fireLoadFinished();
|
|
222
|
+
this.hasInitialLoadCompleted = true;
|
|
223
|
+
}
|
|
97
224
|
}
|
|
98
225
|
pauseUpdates() {
|
|
99
226
|
this.isPaused = true;
|
|
@@ -101,11 +228,23 @@ export class PlotlyExpressChartModel extends ChartModel {
|
|
|
101
228
|
resumeUpdates() {
|
|
102
229
|
this.isPaused = false;
|
|
103
230
|
if (this.hasPendingUpdate) {
|
|
104
|
-
this.fireUpdate(this.
|
|
231
|
+
this.fireUpdate(this.getData());
|
|
105
232
|
}
|
|
106
233
|
}
|
|
107
|
-
|
|
108
|
-
return this.
|
|
234
|
+
shouldPauseOnUserInteraction() {
|
|
235
|
+
return (this.hasScene() || this.hasGeo() || this.hasMapbox() || this.hasPolar());
|
|
236
|
+
}
|
|
237
|
+
hasScene() {
|
|
238
|
+
return this.plotlyData.some(d => 'scene' in d && d.scene != null);
|
|
239
|
+
}
|
|
240
|
+
hasGeo() {
|
|
241
|
+
return this.plotlyData.some(d => 'geo' in d && d.geo != null);
|
|
242
|
+
}
|
|
243
|
+
hasMapbox() {
|
|
244
|
+
return this.plotlyData.some(({ type }) => type === null || type === void 0 ? void 0 : type.includes('mapbox'));
|
|
245
|
+
}
|
|
246
|
+
hasPolar() {
|
|
247
|
+
return this.plotlyData.some(({ type }) => type === null || type === void 0 ? void 0 : type.includes('polar'));
|
|
109
248
|
}
|
|
110
249
|
getPlotWidth() {
|
|
111
250
|
var _a, _b, _c, _d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlotlyExpressChartModel.js","sourceRoot":"","sources":["../src/PlotlyExpressChartModel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PlotlyExpressChartModel.js","sourceRoot":"","sources":["../src/PlotlyExpressChartModel.ts"],"names":[],"mappings":"AASA,OAAO,EACL,UAAU,EACV,UAAU,EAEV,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,GAAG,MAAM,gBAAgB,CAAC;AACjC,OAAO,EAEL,mBAAmB,EACnB,eAAe,EACf,aAAa,GACd,MAAM,8BAA8B,CAAC;AAEtC,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,gDAAgD,CAAC,CAAC;AAEzE,MAAM,OAAO,uBAAwB,SAAQ,UAAU;IACrD,YACE,EAAU,EACV,MAAc,EACd,OAA8B,EAC9B,QAAoB,iBAAiB,EAAE;QAEvC,KAAK,CAAC,EAAE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A,MAAA,IAAI,CAAC,MAAM,CAAC,MAAM,0CAAE,CAAC,mCAAI,CAAC,CAAC,EAC9B,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
import { type
|
|
4
|
-
export
|
|
5
|
-
fetch(): Promise<PlotlyChartWidget>;
|
|
6
|
-
}
|
|
7
|
-
declare function PlotlyExpressChartPanel(props: PlotlyExpressChartPanelProps): JSX.Element;
|
|
8
|
-
declare namespace PlotlyExpressChartPanel {
|
|
9
|
-
var displayName: string;
|
|
10
|
-
}
|
|
2
|
+
import type { Widget } from '@deephaven/jsapi-types';
|
|
3
|
+
import { type WidgetPanelProps } from '@deephaven/plugin';
|
|
4
|
+
export declare function PlotlyExpressChartPanel(props: WidgetPanelProps<Widget>): JSX.Element;
|
|
11
5
|
export default PlotlyExpressChartPanel;
|
|
12
6
|
//# sourceMappingURL=PlotlyExpressChartPanel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlotlyExpressChartPanel.d.ts","sourceRoot":"","sources":["../src/PlotlyExpressChartPanel.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"PlotlyExpressChartPanel.d.ts","sourceRoot":"","sources":["../src/PlotlyExpressChartPanel.tsx"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAK1D,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,gBAAgB,CAAC,MAAM,CAAC,eAyBtE;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -10,63 +10,27 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { useCallback,
|
|
13
|
+
import { useCallback, useRef, useState } from 'react';
|
|
14
14
|
import Plotly from 'plotly.js-dist-min';
|
|
15
|
-
import { ChartPanel
|
|
16
|
-
import { ChartTheme } from '@deephaven/chart';
|
|
15
|
+
import { ChartPanel } from '@deephaven/dashboard-core-plugins';
|
|
17
16
|
import { useApi } from '@deephaven/jsapi-bootstrap';
|
|
18
17
|
import PlotlyExpressChartModel from './PlotlyExpressChartModel.js';
|
|
19
|
-
import {
|
|
20
|
-
function PlotlyExpressChartPanel(props) {
|
|
18
|
+
import { useHandleSceneTicks } from './useHandleSceneTicks.js';
|
|
19
|
+
export function PlotlyExpressChartPanel(props) {
|
|
21
20
|
const dh = useApi();
|
|
22
|
-
const { fetch } = props, rest = __rest(props, ["fetch"]);
|
|
21
|
+
const { fetch, metadata = {} } = props, rest = __rest(props, ["fetch", "metadata"]);
|
|
23
22
|
const containerRef = useRef(null);
|
|
24
23
|
const [model, setModel] = useState();
|
|
25
24
|
const makeModel = useCallback(async () => {
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const data = getWidgetData(widgetInfo);
|
|
29
|
-
const { plotly, deephaven } = data;
|
|
30
|
-
const isDefaultTemplate = !deephaven.is_user_set_template;
|
|
31
|
-
const tableColumnReplacementMap = await getDataMappings(widgetInfo);
|
|
32
|
-
const m = new PlotlyExpressChartModel(dh, tableColumnReplacementMap, plotly.data, (_a = plotly.layout) !== null && _a !== void 0 ? _a : {}, isDefaultTemplate, ChartTheme);
|
|
25
|
+
const widgetData = await fetch();
|
|
26
|
+
const m = new PlotlyExpressChartModel(dh, widgetData, fetch);
|
|
33
27
|
setModel(m);
|
|
34
28
|
return m;
|
|
35
29
|
}, [dh, fetch]);
|
|
36
|
-
|
|
37
|
-
if (!model || !containerRef.current || !model.has3D()) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const container = containerRef.current;
|
|
41
|
-
function handleMouseDown() {
|
|
42
|
-
model === null || model === void 0 ? void 0 : model.pauseUpdates();
|
|
43
|
-
// The once option removes the listener after it is called
|
|
44
|
-
window.addEventListener('mouseup', handleMouseUp, { once: true });
|
|
45
|
-
}
|
|
46
|
-
function handleMouseUp() {
|
|
47
|
-
model === null || model === void 0 ? void 0 : model.resumeUpdates();
|
|
48
|
-
}
|
|
49
|
-
let wheelTimeout = 0;
|
|
50
|
-
function handleWheel() {
|
|
51
|
-
model === null || model === void 0 ? void 0 : model.pauseUpdates();
|
|
52
|
-
window.clearTimeout(wheelTimeout);
|
|
53
|
-
wheelTimeout = window.setTimeout(() => {
|
|
54
|
-
model === null || model === void 0 ? void 0 : model.resumeUpdates();
|
|
55
|
-
}, 300);
|
|
56
|
-
}
|
|
57
|
-
container.addEventListener('mousedown', handleMouseDown);
|
|
58
|
-
container.addEventListener('wheel', handleWheel);
|
|
59
|
-
return () => {
|
|
60
|
-
window.clearTimeout(wheelTimeout);
|
|
61
|
-
window.removeEventListener('mouseup', handleMouseUp);
|
|
62
|
-
container.removeEventListener('mousedown', handleMouseDown);
|
|
63
|
-
container.removeEventListener('wheel', handleWheel);
|
|
64
|
-
};
|
|
65
|
-
}, [model]);
|
|
30
|
+
useHandleSceneTicks(model, containerRef.current);
|
|
66
31
|
return (_jsx(ChartPanel
|
|
67
32
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
68
|
-
, Object.assign({}, rest, { containerRef: containerRef, makeModel: makeModel, Plotly: Plotly })));
|
|
33
|
+
, Object.assign({}, rest, { containerRef: containerRef, makeModel: makeModel, Plotly: Plotly, metadata: metadata })));
|
|
69
34
|
}
|
|
70
|
-
PlotlyExpressChartPanel.displayName = 'PlotlyExpressChartPanel';
|
|
71
35
|
export default PlotlyExpressChartPanel;
|
|
72
36
|
//# sourceMappingURL=PlotlyExpressChartPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlotlyExpressChartPanel.js","sourceRoot":"","sources":["../src/PlotlyExpressChartPanel.tsx"],"names":[],"mappings":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