@deephaven/js-plugin-matplotlib 0.4.1 → 0.5.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/index.js +76 -8
- package/package.json +13 -11
package/dist/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
2
3
|
const plugin = require("@deephaven/plugin");
|
|
3
4
|
const icons = require("@deephaven/icons");
|
|
4
5
|
const require$$1 = require("react");
|
|
5
6
|
const jsapiBootstrap = require("@deephaven/jsapi-bootstrap");
|
|
6
7
|
const Log = require("@deephaven/log");
|
|
8
|
+
const dashboard = require("@deephaven/dashboard");
|
|
7
9
|
var jsxRuntimeExports = {};
|
|
8
10
|
var jsxRuntime = {
|
|
9
11
|
get exports() {
|
|
@@ -117,7 +119,7 @@ reactJsxRuntime_production_min.jsxs = q;
|
|
|
117
119
|
module2.exports = reactJsxRuntime_production_min;
|
|
118
120
|
}
|
|
119
121
|
})(jsxRuntime);
|
|
120
|
-
const log = Log.module("@deephaven/js-plugin-matplotlib.MatplotlibView");
|
|
122
|
+
const log$1 = Log.module("@deephaven/js-plugin-matplotlib.MatplotlibView");
|
|
121
123
|
const MatplotlibViewStyle = {
|
|
122
124
|
height: "100%",
|
|
123
125
|
width: "100%",
|
|
@@ -136,12 +138,12 @@ function MatplotlibView(props) {
|
|
|
136
138
|
const dh = jsapiBootstrap.useApi();
|
|
137
139
|
require$$1.useEffect(
|
|
138
140
|
function initInputTable() {
|
|
139
|
-
if (
|
|
141
|
+
if (inputTable == null) {
|
|
140
142
|
return;
|
|
141
143
|
}
|
|
142
144
|
const table = inputTable;
|
|
143
145
|
async function openTable() {
|
|
144
|
-
log.debug("openTable");
|
|
146
|
+
log$1.debug("openTable");
|
|
145
147
|
const keyColumn = table.findColumn(
|
|
146
148
|
"key"
|
|
147
149
|
/* key */
|
|
@@ -160,7 +162,7 @@ function MatplotlibView(props) {
|
|
|
160
162
|
dh.Table.EVENT_UPDATED,
|
|
161
163
|
({ detail: data }) => {
|
|
162
164
|
const newRevision = data.rows[0].get(valueColumn);
|
|
163
|
-
log.debug("New revision", newRevision);
|
|
165
|
+
log$1.debug("New revision", newRevision);
|
|
164
166
|
setRevision(newRevision);
|
|
165
167
|
}
|
|
166
168
|
);
|
|
@@ -168,7 +170,7 @@ function MatplotlibView(props) {
|
|
|
168
170
|
}
|
|
169
171
|
openTable();
|
|
170
172
|
return function closeTable() {
|
|
171
|
-
log.debug("closeTable");
|
|
173
|
+
log$1.debug("closeTable");
|
|
172
174
|
table.close();
|
|
173
175
|
};
|
|
174
176
|
},
|
|
@@ -177,12 +179,12 @@ function MatplotlibView(props) {
|
|
|
177
179
|
require$$1.useEffect(
|
|
178
180
|
function updateData() {
|
|
179
181
|
async function fetchData() {
|
|
180
|
-
log.debug("fetchData");
|
|
182
|
+
log$1.debug("fetchData");
|
|
181
183
|
const widget = await fetch();
|
|
182
184
|
const imageData = widget.getDataAsBase64();
|
|
183
185
|
setImageSrc(`data:image/png;base64,${imageData}`);
|
|
184
186
|
if (revision <= 0) {
|
|
185
|
-
log.debug("Getting new input table");
|
|
187
|
+
log$1.debug("Getting new input table");
|
|
186
188
|
const newInputTable = await widget.exportedObjects[0].fetch();
|
|
187
189
|
setInputTable(newInputTable);
|
|
188
190
|
}
|
|
@@ -202,9 +204,75 @@ function MatplotlibView(props) {
|
|
|
202
204
|
}
|
|
203
205
|
const MatplotlibPlugin = {
|
|
204
206
|
name: "@deephaven/js-plugin-matplotlib",
|
|
207
|
+
title: "Matplotlib Figure",
|
|
205
208
|
type: plugin.PluginType.WIDGET_PLUGIN,
|
|
206
209
|
supportedTypes: "matplotlib.figure.Figure",
|
|
207
210
|
component: MatplotlibView,
|
|
208
211
|
icon: icons.vsGraph
|
|
209
212
|
};
|
|
210
|
-
|
|
213
|
+
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
214
|
+
let nanoid = (size = 21) => {
|
|
215
|
+
let id = "";
|
|
216
|
+
let bytes = crypto.getRandomValues(new Uint8Array(size));
|
|
217
|
+
while (size--) {
|
|
218
|
+
id += urlAlphabet[bytes[size] & 63];
|
|
219
|
+
}
|
|
220
|
+
return id;
|
|
221
|
+
};
|
|
222
|
+
function MatplotlibPanel(props) {
|
|
223
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(MatplotlibView, { ...props });
|
|
224
|
+
}
|
|
225
|
+
MatplotlibPanel.COMPONENT = "MatPlotLibPanel";
|
|
226
|
+
const VARIABLE_TYPE = "matplotlib.figure.Figure";
|
|
227
|
+
const log = Log.module("@deephaven/js-plugin-matplotlib.DashboardPlugin");
|
|
228
|
+
function DashboardPlugin({
|
|
229
|
+
id,
|
|
230
|
+
layout,
|
|
231
|
+
registerComponent
|
|
232
|
+
}) {
|
|
233
|
+
const handlePanelOpen = require$$1.useCallback(
|
|
234
|
+
({
|
|
235
|
+
dragEvent,
|
|
236
|
+
fetch,
|
|
237
|
+
metadata = {},
|
|
238
|
+
panelId = nanoid(),
|
|
239
|
+
widget
|
|
240
|
+
}) => {
|
|
241
|
+
const { name, type } = widget;
|
|
242
|
+
if (type !== VARIABLE_TYPE) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
log.info("Panel opened of type", type);
|
|
246
|
+
const config = {
|
|
247
|
+
type: "react-component",
|
|
248
|
+
component: MatplotlibPanel.COMPONENT,
|
|
249
|
+
props: {
|
|
250
|
+
localDashboardId: id,
|
|
251
|
+
id: panelId,
|
|
252
|
+
metadata: {
|
|
253
|
+
...metadata,
|
|
254
|
+
...widget
|
|
255
|
+
},
|
|
256
|
+
fetch
|
|
257
|
+
},
|
|
258
|
+
title: name ?? void 0,
|
|
259
|
+
id: panelId
|
|
260
|
+
};
|
|
261
|
+
const { root } = layout;
|
|
262
|
+
dashboard.LayoutUtils.openComponent({ root, config, dragEvent });
|
|
263
|
+
},
|
|
264
|
+
[id, layout]
|
|
265
|
+
);
|
|
266
|
+
require$$1.useEffect(() => {
|
|
267
|
+
const cleanups = [
|
|
268
|
+
registerComponent(MatplotlibPanel.COMPONENT, MatplotlibPanel)
|
|
269
|
+
];
|
|
270
|
+
return () => {
|
|
271
|
+
cleanups.forEach((cleanup) => cleanup());
|
|
272
|
+
};
|
|
273
|
+
}, [registerComponent]);
|
|
274
|
+
dashboard.useListener(layout.eventHub, "PanelEvent.OPEN", handlePanelOpen);
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
exports.DashboardPlugin = DashboardPlugin;
|
|
278
|
+
exports.default = MatplotlibPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/js-plugin-matplotlib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Deephaven Matplotlib plugin",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Deephaven",
|
|
@@ -30,21 +30,23 @@
|
|
|
30
30
|
"@types/react-dom": "^17.0.2",
|
|
31
31
|
"@vitejs/plugin-react-swc": "^3.0.0",
|
|
32
32
|
"react": "^17.0.2",
|
|
33
|
+
"react-dom": "^17.0.2",
|
|
33
34
|
"typescript": "^4.5.4",
|
|
34
35
|
"vite": "~4.1.4"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
|
-
"react": "^17.0.2"
|
|
38
|
+
"react": "^17.0.2",
|
|
39
|
+
"react-dom": "^17.0.2"
|
|
38
40
|
},
|
|
39
41
|
"dependencies": {
|
|
40
|
-
"@deephaven/components": "^0.
|
|
41
|
-
"@deephaven/dashboard": "^0.
|
|
42
|
-
"@deephaven/icons": "^0.
|
|
43
|
-
"@deephaven/jsapi-bootstrap": "^0.
|
|
44
|
-
"@deephaven/jsapi-types": "
|
|
45
|
-
"@deephaven/log": "^0.
|
|
46
|
-
"@deephaven/plugin": "^0.
|
|
47
|
-
"
|
|
42
|
+
"@deephaven/components": "^0.87.0",
|
|
43
|
+
"@deephaven/dashboard": "^0.86.0",
|
|
44
|
+
"@deephaven/icons": "^0.87.0",
|
|
45
|
+
"@deephaven/jsapi-bootstrap": "^0.87.0",
|
|
46
|
+
"@deephaven/jsapi-types": "1.0.0-dev0.35.2",
|
|
47
|
+
"@deephaven/log": "^0.87.0",
|
|
48
|
+
"@deephaven/plugin": "^0.86.0",
|
|
49
|
+
"nanoid": "^5.0.7"
|
|
48
50
|
},
|
|
49
51
|
"publishConfig": {
|
|
50
52
|
"access": "public"
|
|
@@ -52,5 +54,5 @@
|
|
|
52
54
|
"files": [
|
|
53
55
|
"dist/index.js"
|
|
54
56
|
],
|
|
55
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "3dca56477c94548ab595116a53652d70d454827d"
|
|
56
58
|
}
|