hiplot-mm 0.0.1__py3-none-any.whl → 0.0.3rc0__py3-none-any.whl

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.
Files changed (58) hide show
  1. hiplot/ipython.py +38 -6
  2. hiplot/pkginfo.py +18 -2
  3. hiplot/server.py +8 -2
  4. hiplot/static/built/hiplot.bundle.js +1 -1
  5. hiplot/static/built/streamlit_component/hiplot_streamlit.bundle.js +1 -1
  6. hiplot/streamlit_helpers.py +11 -2
  7. {hiplot_mm-0.0.1.dist-info → hiplot_mm-0.0.3rc0.dist-info}/METADATA +51 -27
  8. hiplot_mm-0.0.3rc0.dist-info/RECORD +33 -0
  9. {hiplot_mm-0.0.1.dist-info → hiplot_mm-0.0.3rc0.dist-info}/WHEEL +1 -1
  10. {hiplot_mm-0.0.1.dist-info → hiplot_mm-0.0.3rc0.dist-info}/entry_points.txt +0 -1
  11. hiplot/static/built/component.d.ts +0 -109
  12. hiplot/static/built/component.js +0 -528
  13. hiplot/static/built/contextmenu.d.ts +0 -26
  14. hiplot/static/built/contextmenu.js +0 -90
  15. hiplot/static/built/controls.d.ts +0 -52
  16. hiplot/static/built/controls.js +0 -163
  17. hiplot/static/built/filters.d.ts +0 -21
  18. hiplot/static/built/filters.js +0 -96
  19. hiplot/static/built/header.d.ts +0 -39
  20. hiplot/static/built/header.js +0 -176
  21. hiplot/static/built/hiplot-mm-0.0.0.tar.gz +0 -0
  22. hiplot/static/built/hiplot.bundle.js.LICENSE.txt +0 -88
  23. hiplot/static/built/hiplot.bundle.js.map +0 -1
  24. hiplot/static/built/hiplot.d.ts +0 -8
  25. hiplot/static/built/hiplot.js +0 -14
  26. hiplot/static/built/hiplot.lib.js +0 -57712
  27. hiplot/static/built/hiplot.lib.js.map +0 -1
  28. hiplot/static/built/hiplot.licenses.txt +0 -682
  29. hiplot/static/built/hiplot_mm-0.0.0-py3-none-any.whl +0 -0
  30. hiplot/static/built/hiplot_streamlit.bundle.js +0 -3
  31. hiplot/static/built/hiplot_streamlit.bundle.js.LICENSE.txt +0 -97
  32. hiplot/static/built/hiplot_streamlit.bundle.js.map +0 -1
  33. hiplot/static/built/hiplot_streamlit.d.ts +0 -1
  34. hiplot/static/built/hiplot_streamlit.js +0 -85
  35. hiplot/static/built/hiplot_streamlit.licenses.txt +0 -689
  36. hiplot/static/built/hiplot_test.bundle.js +0 -3
  37. hiplot/static/built/hiplot_test.bundle.js.LICENSE.txt +0 -88
  38. hiplot/static/built/hiplot_test.bundle.js.map +0 -1
  39. hiplot/static/built/hiplot_test.d.ts +0 -46
  40. hiplot/static/built/hiplot_test.js +0 -238
  41. hiplot/static/built/hiplot_test.licenses.txt +0 -682
  42. hiplot/static/built/hiplot_web.d.ts +0 -3
  43. hiplot/static/built/hiplot_web.js +0 -54
  44. hiplot/static/built/infertypes.d.ts +0 -38
  45. hiplot/static/built/infertypes.js +0 -316
  46. hiplot/static/built/plotxy.d.ts +0 -62
  47. hiplot/static/built/plotxy.js +0 -602
  48. hiplot/static/built/plugin.d.ts +0 -38
  49. hiplot/static/built/plugin.js +0 -8
  50. hiplot/static/built/rowsdisplaytable.d.ts +0 -35
  51. hiplot/static/built/rowsdisplaytable.js +0 -284
  52. hiplot/static/built/streamlit_component/hiplot.bundle.js +0 -3
  53. hiplot/static/built/types.d.ts +0 -64
  54. hiplot/static/built/types.js +0 -55
  55. hiplot_mm-0.0.1.dist-info/RECORD +0 -77
  56. {hiplot_mm-0.0.1.dist-info → hiplot_mm-0.0.3rc0.dist-info/licenses}/LICENSE +0 -0
  57. {hiplot_mm-0.0.1.dist-info → hiplot_mm-0.0.3rc0.dist-info/licenses}/NOTICE +0 -0
  58. {hiplot_mm-0.0.1.dist-info → hiplot_mm-0.0.3rc0.dist-info}/top_level.txt +0 -0
@@ -1,528 +0,0 @@
1
- /*
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- var __extends = (this && this.__extends) || (function () {
8
- var extendStatics = function (d, b) {
9
- extendStatics = Object.setPrototypeOf ||
10
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12
- return extendStatics(d, b);
13
- };
14
- return function (d, b) {
15
- extendStatics(d, b);
16
- function __() { this.constructor = d; }
17
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18
- };
19
- })();
20
- var __assign = (this && this.__assign) || function () {
21
- __assign = Object.assign || function(t) {
22
- for (var s, i = 1, n = arguments.length; i < n; i++) {
23
- s = arguments[i];
24
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
25
- t[p] = s[p];
26
- }
27
- return t;
28
- };
29
- return __assign.apply(this, arguments);
30
- };
31
- var _a;
32
- import $ from "jquery";
33
- import * as _ from 'underscore';
34
- import React from "react";
35
- import './style/global';
36
- import { ParamType, HiPlotLoadStatus, PSTATE_COLOR_BY, PSTATE_PARAMS, PSTATE_FILTERS } from "./types";
37
- import { RowsDisplayTable } from "./rowsdisplaytable";
38
- import { infertypes, colorScheme } from "./infertypes";
39
- import { PersistentStateInMemory } from "./lib/savedstate";
40
- import { ParallelPlot } from "./parallel/parallel";
41
- import { PlotXY } from "./plotxy";
42
- import { SelectedCountProgressBar } from "./controls";
43
- import { ErrorDisplay, HeaderBar } from "./header";
44
- import { StaticDataProvider } from "./dataproviders/static";
45
- import { uncompress } from "./lib/compress";
46
- import { setupBrowserCompat } from "./lib/browsercompat";
47
- //@ts-ignore
48
- import LogoSVG from "../hiplot/static/logo.svg";
49
- //@ts-ignore
50
- import LogoSVGW from "../hiplot/static/logo-w.svg";
51
- //@ts-ignore
52
- import style from "./hiplot.scss";
53
- import { ContextMenu } from "./contextmenu";
54
- import { HiPlotDistributionPlugin } from "./distribution/plugin";
55
- import { FilterType, apply_filters, apply_filter } from "./filters";
56
- // Exported from HiPlot
57
- export { PlotXY } from "./plotxy";
58
- export { ParallelPlot } from "./parallel/parallel";
59
- export { RowsDisplayTable } from "./rowsdisplaytable";
60
- export { HiPlotLoadStatus } from "./types";
61
- ;
62
- var makeCancelable = function (promise) {
63
- var hasCanceled_ = false;
64
- var wrappedPromise = new Promise(function (resolve, reject) {
65
- promise.then(function (val) { return hasCanceled_ ? reject({ isCanceled: true }) : resolve(val); }, function (error) { return hasCanceled_ ? reject({ isCanceled: true }) : reject(error); });
66
- });
67
- return {
68
- promise: wrappedPromise,
69
- cancel: function () {
70
- hasCanceled_ = true;
71
- }
72
- };
73
- };
74
- ;
75
- function detectIsDarkTheme() {
76
- // Hack: detect dark/light theme in Jupyter Lab
77
- var jupyterLabAttrLightTheme = "data-jp-theme-light";
78
- if (document.body.hasAttribute(jupyterLabAttrLightTheme)) {
79
- return document.body.getAttribute(jupyterLabAttrLightTheme) == "false";
80
- }
81
- return window.matchMedia("(prefers-color-scheme: dark)").matches;
82
- }
83
- export var DefaultPlugins;
84
- (function (DefaultPlugins) {
85
- // Names correspond to values of (python) hip.Displays
86
- DefaultPlugins["PARALLEL_PLOT"] = "PARALLEL_PLOT";
87
- DefaultPlugins["XY"] = "XY";
88
- DefaultPlugins["DISTRIBUTION"] = "DISTRIBUTION";
89
- DefaultPlugins["TABLE"] = "TABLE";
90
- })(DefaultPlugins || (DefaultPlugins = {}));
91
- export var defaultPlugins = (_a = {},
92
- // @ts-ignore
93
- _a[DefaultPlugins.PARALLEL_PLOT] = ParallelPlot,
94
- // @ts-ignore
95
- _a[DefaultPlugins.XY] = PlotXY,
96
- // @ts-ignore
97
- _a[DefaultPlugins.DISTRIBUTION] = HiPlotDistributionPlugin,
98
- // @ts-ignore
99
- _a[DefaultPlugins.TABLE] = RowsDisplayTable,
100
- _a);
101
- export function createDefaultPlugins() {
102
- return Object.assign({}, defaultPlugins);
103
- }
104
- ;
105
- var HiPlot = /** @class */ (function (_super) {
106
- __extends(HiPlot, _super);
107
- function HiPlot(props) {
108
- var _this = _super.call(this, props) || this;
109
- // React refs
110
- _this.contextMenuRef = React.createRef();
111
- _this.rootRef = React.createRef();
112
- _this.plugins_window_state = {};
113
- _this.plugins_ref = {}; // For debugging/tests
114
- _this.callSelectedUidsHooks = _.debounce(function () {
115
- this.sendMessage("selected_uids", function () { return this.state.rows_selected.map(function (row) { return '' + row['uid']; }); }.bind(this));
116
- }.bind(_this), 200);
117
- _this.callFilteredUidsHooks = _.debounce(function () {
118
- this.sendMessage("filtered_uids", function () { return this.state.rows_filtered.map(function (row) { return '' + row['uid']; }); }.bind(this));
119
- }.bind(_this), 200);
120
- _this.state = {
121
- experiment: null,
122
- colormap: null,
123
- loadStatus: HiPlotLoadStatus.None,
124
- loadPromise: null,
125
- error: null,
126
- dp_lookup: {},
127
- rows_all_unfiltered: [],
128
- rows_filtered: [],
129
- rows_filtered_filters: [],
130
- rows_selected: [],
131
- rows_selected_filter: null,
132
- rows_highlighted: [],
133
- params_def: {},
134
- params_def_unfiltered: {},
135
- colorby: null,
136
- dark: _this.props.dark === null ? detectIsDarkTheme() : _this.props.dark,
137
- persistentState: props.persistentState !== undefined && props.persistentState !== null ? props.persistentState : new PersistentStateInMemory("", {}),
138
- dataProvider: _this.props.dataProvider ? _this.props.dataProvider : StaticDataProvider
139
- };
140
- Object.keys(props.plugins).forEach(function (name, index) {
141
- _this.plugins_window_state[name] = {};
142
- _this.plugins_ref[name] = React.createRef();
143
- });
144
- return _this;
145
- }
146
- HiPlot.getDerivedStateFromError = function (error) {
147
- // Update state so the next render will show the fallback UI.
148
- return {
149
- experiment: null,
150
- loadStatus: HiPlotLoadStatus.Error,
151
- error: error.toString()
152
- };
153
- };
154
- HiPlot.prototype.makeDatasets = function (experiment, dp_lookup, initial_filters) {
155
- if (experiment) {
156
- var rows_all_unfiltered = experiment.datapoints.map(function (t) {
157
- var obj_with_uid = $.extend({
158
- "uid": t.uid,
159
- "from_uid": t.from_uid
160
- }, t.values);
161
- dp_lookup[t.uid] = obj_with_uid;
162
- return obj_with_uid;
163
- });
164
- var rows_filtered = rows_all_unfiltered;
165
- try {
166
- rows_filtered = apply_filters(rows_all_unfiltered, initial_filters);
167
- if (!rows_filtered.length) {
168
- rows_filtered = rows_all_unfiltered;
169
- console.log("Not reapplying filters (would filter out all rows)");
170
- }
171
- }
172
- catch (err) {
173
- console.error("Error trying to apply filters", initial_filters, ":", err);
174
- }
175
- return {
176
- rows_all_unfiltered: rows_all_unfiltered,
177
- rows_filtered: rows_filtered,
178
- rows_selected: rows_filtered,
179
- rows_highlighted: []
180
- };
181
- }
182
- return {
183
- rows_all_unfiltered: [],
184
- rows_filtered: [],
185
- rows_selected: [],
186
- rows_highlighted: []
187
- };
188
- };
189
- HiPlot.prototype.sendMessage = function (type, get_data) {
190
- if (this.props.onChange !== null && this.props.onChange[type]) {
191
- var data = get_data();
192
- this.props.onChange[type](type, data);
193
- }
194
- };
195
- HiPlot.prototype._loadExperiment = function (experiment) {
196
- // Uncompress if compressed
197
- if (experiment.datapoints === undefined) {
198
- experiment.datapoints = uncompress(experiment.datapoints_compressed);
199
- }
200
- // Generate dataset for Parallel Plot
201
- var dp_lookup = {};
202
- var initFilters = this.state.persistentState.get(PSTATE_FILTERS, []);
203
- var datasets = this.makeDatasets(experiment, dp_lookup, initFilters);
204
- if (datasets.rows_all_unfiltered == datasets.rows_filtered) {
205
- initFilters = [];
206
- }
207
- var params_def = infertypes(this.state.persistentState.children(PSTATE_PARAMS), datasets.rows_filtered, experiment.parameters_definition);
208
- var params_def_unfiltered = infertypes(this.state.persistentState.children(PSTATE_PARAMS), datasets.rows_all_unfiltered, experiment.parameters_definition);
209
- // Color handling
210
- function get_default_color() {
211
- if (experiment.colorby && params_def[experiment.colorby]) {
212
- return experiment.colorby;
213
- }
214
- function select_as_coloring_score(r) {
215
- var pd = params_def[r];
216
- var score = 0;
217
- if (pd.colors || pd.colormap) {
218
- score += 100;
219
- }
220
- if (pd.type == ParamType.CATEGORICAL) {
221
- score -= 20;
222
- }
223
- if (pd.optional) {
224
- score -= 40;
225
- }
226
- return score;
227
- }
228
- ;
229
- var possibles = Object.keys(params_def).sort(function (a, b) { return select_as_coloring_score(b) - select_as_coloring_score(a); });
230
- return possibles[0];
231
- }
232
- var colorby = this.state.persistentState.get(PSTATE_COLOR_BY, get_default_color());
233
- if (params_def[colorby] === undefined) {
234
- colorby = get_default_color();
235
- }
236
- this.setState(function (state, props) {
237
- return __assign({ experiment: experiment, colormap: experiment.colormap, loadStatus: HiPlotLoadStatus.Loaded, dp_lookup: dp_lookup, colorby: colorby, params_def: params_def, params_def_unfiltered: params_def_unfiltered, rows_filtered_filters: initFilters }, datasets);
238
- });
239
- };
240
- HiPlot.prototype.getColorForRow = function (trial, alpha) {
241
- return colorScheme(this.state.params_def[this.state.colorby], trial[this.state.colorby], alpha, this.state.colormap);
242
- };
243
- ;
244
- HiPlot.prototype.loadWithPromise = function (prom) {
245
- this.setState({
246
- loadStatus: HiPlotLoadStatus.Loading,
247
- loadPromise: makeCancelable(prom)
248
- });
249
- };
250
- HiPlot.prototype.componentWillUnmount = function () {
251
- if (this.contextMenuRef.current) {
252
- this.contextMenuRef.current.removeCallbacks(this);
253
- }
254
- if (this.state.loadPromise) {
255
- this.state.loadPromise.cancel();
256
- }
257
- this.callSelectedUidsHooks.cancel();
258
- this.callFilteredUidsHooks.cancel();
259
- };
260
- HiPlot.prototype.componentDidMount = function () {
261
- setupBrowserCompat(this.rootRef.current);
262
- // Setup contextmenu when we right-click a parameter
263
- this.contextMenuRef.current.addCallback(this.columnContextMenu.bind(this), this);
264
- // Load experiment provided in constructor if any
265
- if (this.props.experiment) {
266
- this.loadWithPromise(new Promise(function (resolve, reject) {
267
- resolve({ experiment: this.props.experiment });
268
- }.bind(this)));
269
- }
270
- };
271
- HiPlot.prototype.componentDidUpdate = function (prevProps, prevState) {
272
- if (prevState.rows_filtered_filters != this.state.rows_filtered_filters) {
273
- this.state.persistentState.set(PSTATE_FILTERS, this.state.rows_filtered_filters);
274
- }
275
- if (prevState.colorby != this.state.colorby && this.state.colorby) {
276
- this.state.persistentState.set(PSTATE_COLOR_BY, this.state.colorby);
277
- }
278
- if (this.state.loadStatus != HiPlotLoadStatus.Loading) {
279
- if (this.props.experiment !== null &&
280
- ((this.state.loadStatus == HiPlotLoadStatus.Error && this.props.experiment !== prevProps.experiment) ||
281
- (this.state.loadStatus != HiPlotLoadStatus.Error && this.props.experiment !== this.state.experiment))) {
282
- this.loadWithPromise(new Promise(function (resolve, reject) {
283
- resolve({ experiment: this.props.experiment });
284
- }.bind(this)));
285
- }
286
- else {
287
- if (prevState.rows_selected != this.state.rows_selected) {
288
- this.callSelectedUidsHooks();
289
- }
290
- if (prevState.rows_filtered != this.state.rows_filtered) {
291
- this.callFilteredUidsHooks();
292
- }
293
- }
294
- }
295
- if (this.state.loadStatus == HiPlotLoadStatus.Loading &&
296
- this.state.loadPromise != prevState.loadPromise) {
297
- var prom = this.state.loadPromise.promise;
298
- var me_1 = this;
299
- prom.then(function (data) {
300
- if (data.error !== undefined) {
301
- console.log("Experiment loading failed", data);
302
- me_1.setState({
303
- loadStatus: HiPlotLoadStatus.Error,
304
- experiment: null,
305
- error: data.error
306
- });
307
- return;
308
- }
309
- me_1._loadExperiment(data.experiment);
310
- })["catch"](function (error) {
311
- if (error.isCanceled) {
312
- return;
313
- }
314
- console.log('Error', error);
315
- me_1.setState({ loadStatus: HiPlotLoadStatus.Error, experiment: null, error: 'HTTP error, check server logs / javascript console' });
316
- throw error;
317
- });
318
- }
319
- };
320
- HiPlot.prototype.columnContextMenu = function (column, cm) {
321
- var _a;
322
- var VAR_TYPE_TO_NAME = (_a = {},
323
- _a[ParamType.CATEGORICAL] = 'Categorical',
324
- _a[ParamType.NUMERIC] = 'Number',
325
- _a[ParamType.NUMERICLOG] = 'Number (log-scale)',
326
- _a[ParamType.NUMERICPERCENTILE] = 'Number (percentile-scale)',
327
- _a[ParamType.TIMESTAMP] = 'Timestamp',
328
- _a);
329
- var contextmenu = $(cm);
330
- contextmenu.append($('<h6 class="dropdown-header">Data scaling</h6>'));
331
- this.state.params_def[column].type_options.forEach(function (possible_type) {
332
- var option = $('<a class="dropdown-item" href="#">').text(VAR_TYPE_TO_NAME[possible_type]);
333
- if (possible_type == this.state.params_def[column].type) {
334
- option.addClass('disabled').css('pointer-events', 'none');
335
- }
336
- option.click(function (event) {
337
- contextmenu.css('display', 'none');
338
- this.setState(function (state, props) {
339
- var _a;
340
- return {
341
- params_def: __assign(__assign({}, state.params_def), (_a = {}, _a[column] = __assign(__assign({}, state.params_def[column]), { type: possible_type }), _a))
342
- };
343
- });
344
- this.state.persistentState.children(PSTATE_PARAMS).children(column).set('type', possible_type);
345
- event.preventDefault();
346
- }.bind(this));
347
- contextmenu.append(option);
348
- }.bind(this));
349
- contextmenu.append($('<div class="dropdown-divider"></div>'));
350
- // Color by
351
- var link_colorize = $('<a class="dropdown-item" href="#">Use for coloring</a>');
352
- link_colorize.click(function (event) {
353
- this.setState({
354
- colorby: column
355
- });
356
- event.preventDefault();
357
- }.bind(this));
358
- if (this.state.colorby == column) {
359
- link_colorize.addClass('disabled').css('pointer-events', 'none');
360
- }
361
- contextmenu.append(link_colorize);
362
- };
363
- HiPlot.prototype.createNewParamsDef = function (rows_filtered) {
364
- var new_pd = Object.assign({}, this.state.params_def);
365
- Object.assign(new_pd, infertypes(this.state.persistentState.children(PSTATE_PARAMS), rows_filtered, this.state.params_def));
366
- return new_pd;
367
- };
368
- HiPlot.prototype.restoreAllRows = function () {
369
- /**
370
- * When we hit `Restore` button
371
- */
372
- this.setState(function (state, props) {
373
- var all_rows = state.rows_all_unfiltered;
374
- var new_pd = this.createNewParamsDef(all_rows);
375
- return {
376
- rows_selected: all_rows,
377
- rows_selected_filter: null,
378
- rows_filtered: all_rows,
379
- rows_filtered_filters: [],
380
- params_def: new_pd
381
- };
382
- }.bind(this));
383
- };
384
- ;
385
- HiPlot.prototype.filterRows = function (keep) {
386
- /**
387
- * When we hit Keep (keep=true), or Exclude (keep=false) buttons
388
- */
389
- this.setState(function (state, props) {
390
- var new_filtered = keep ? state.rows_selected : _.difference(state.rows_filtered, state.rows_selected);
391
- var filter = state.rows_selected_filter;
392
- if (!keep) {
393
- filter = {
394
- type: FilterType.Not,
395
- data: filter
396
- };
397
- }
398
- var new_pd = this.createNewParamsDef(new_filtered);
399
- return {
400
- rows_filtered: new_filtered,
401
- params_def: new_pd,
402
- rows_selected_filter: null,
403
- rows_filtered_filters: state.rows_filtered_filters.concat([filter])
404
- };
405
- }.bind(this));
406
- };
407
- ;
408
- HiPlot.prototype.setSelected = function (rows, filter) {
409
- if (filter === void 0) { filter = null; }
410
- if (filter && _.isEqual(filter, this.state.rows_selected_filter)) {
411
- return;
412
- }
413
- if (filter && this.props.asserts) {
414
- var new_rows = apply_filter(this.state.rows_filtered, filter);
415
- if (new_rows.length != rows.length || _.difference(new_rows, rows).length) {
416
- console.error("Warning! Filter ", filter, " does not match given rows", rows, " Computed rows with filter:", new_rows);
417
- }
418
- }
419
- this.setState({
420
- rows_selected: rows,
421
- rows_selected_filter: filter
422
- });
423
- };
424
- HiPlot.prototype.setHighlighted = function (rows) {
425
- this.setState({ rows_highlighted: rows });
426
- };
427
- HiPlot.prototype.renderRowText = function (row) {
428
- return row.uid;
429
- };
430
- ;
431
- HiPlot.prototype.render = function () {
432
- var datasets = {
433
- rows_all_unfiltered: this.state.rows_all_unfiltered,
434
- rows_filtered: this.state.rows_filtered,
435
- rows_highlighted: this.state.rows_highlighted,
436
- rows_selected: this.state.rows_selected
437
- };
438
- var controlProps = __assign({ restoreAllRows: this.restoreAllRows.bind(this), filterRows: this.filterRows.bind(this) }, datasets);
439
- var createPluginProps = function (name) {
440
- return __assign(__assign(__assign({ ref: this.plugins_ref[name] }, (this.state.experiment.display_data && this.state.experiment.display_data[name] ? this.state.experiment.display_data[name] : {})), datasets), { rows_selected_filter: this.state.rows_selected_filter, name: name, persistentState: this.state.persistentState.children(name), window_state: this.plugins_window_state[name], sendMessage: this.sendMessage.bind(this), get_color_for_row: this.getColorForRow.bind(this), experiment: this.state.experiment, params_def: this.state.params_def, params_def_unfiltered: this.state.params_def_unfiltered, dp_lookup: this.state.dp_lookup, colorby: this.state.colorby, render_row_text: this.renderRowText.bind(this), context_menu_ref: this.contextMenuRef, setSelected: this.setSelected.bind(this), setHighlighted: this.setHighlighted.bind(this), asserts: this.props.asserts });
441
- }.bind(this);
442
- return (React.createElement("div", { ref: this.rootRef, className: "hip_thm--" + (this.state.dark ? "dark" : "light") },
443
- React.createElement("div", { className: style.hiplot },
444
- React.createElement(SelectedCountProgressBar, __assign({}, controlProps)),
445
- React.createElement(HeaderBar, __assign({ weightColumn: this.state.experiment ? this.state.experiment.weightcolumn : undefined, onLoadExperiment: this.loadWithPromise.bind(this), persistentState: this.state.persistentState, dataProvider: this.state.dataProvider, loadStatus: this.state.loadStatus, dark: this.state.dark }, controlProps)),
446
- this.state.loadStatus == HiPlotLoadStatus.Error &&
447
- React.createElement(ErrorDisplay, { error: this.state.error }),
448
- this.state.loadStatus != HiPlotLoadStatus.Loaded &&
449
- React.createElement(DocAndCredits, { dark: this.state.dark }),
450
- React.createElement(ContextMenu, { ref: this.contextMenuRef }),
451
- this.state.loadStatus == HiPlotLoadStatus.Loaded &&
452
- React.createElement("div", null, (this.state.experiment.enabled_displays !== undefined ? this.state.experiment.enabled_displays : Object.keys(this.props.plugins)).map(function (display_name) {
453
- var plugin = this.props.plugins[display_name];
454
- return React.createElement(React.Fragment, { key: display_name }, React.createElement(plugin, createPluginProps(display_name)));
455
- }.bind(this))))));
456
- };
457
- HiPlot.prototype.getPlugin = function (cls) {
458
- var entries = Object.entries(this.props.plugins);
459
- for (var i = 0; i < entries.length; ++i) {
460
- if (entries[i][1] == cls) {
461
- return this.plugins_ref[entries[i][0]].current;
462
- }
463
- }
464
- throw new Error("Can not find plugin" + cls);
465
- };
466
- HiPlot.defaultProps = {
467
- loadURI: null,
468
- comm: null,
469
- dark: false,
470
- asserts: false,
471
- plugins: defaultPlugins,
472
- experiment: null,
473
- dataProvider: null,
474
- onChange: null
475
- };
476
- return HiPlot;
477
- }(React.Component));
478
- export { HiPlot };
479
- ;
480
- var DocAndCredits = /** @class */ (function (_super) {
481
- __extends(DocAndCredits, _super);
482
- function DocAndCredits() {
483
- return _super !== null && _super.apply(this, arguments) || this;
484
- }
485
- DocAndCredits.prototype.render = function () {
486
- return (React.createElement("div", { className: "container hide-when-loaded" },
487
- React.createElement("div", { className: "row" },
488
- React.createElement("div", { className: "col-md-3" }),
489
- React.createElement("div", { className: "col-md-6" },
490
- React.createElement("img", { src: this.props.dark ? LogoSVGW : LogoSVG })),
491
- React.createElement("div", { className: "col-md-3" }),
492
- React.createElement("div", { className: "col-md-6" },
493
- React.createElement("h3", null, "Controls"),
494
- React.createElement("p", null,
495
- React.createElement("strong", null, "Brush"),
496
- ": Drag vertically along an axis.",
497
- React.createElement("br", null),
498
- React.createElement("strong", null, "Remove Brush"),
499
- ": Tap the axis background.",
500
- React.createElement("br", null),
501
- React.createElement("strong", null, "Reorder Axes"),
502
- ": Drag a label horizontally.",
503
- React.createElement("br", null),
504
- React.createElement("strong", null, "Invert Axis"),
505
- ": Tap an axis label.",
506
- React.createElement("br", null),
507
- React.createElement("strong", null, "Remove Axis"),
508
- ": Drag axis label to the left edge.",
509
- React.createElement("br", null))),
510
- React.createElement("div", { className: "cold-md-6" },
511
- React.createElement("h3", null, "Credits & License"),
512
- React.createElement("p", null,
513
- "Adapted from examples by",
514
- React.createElement("br", null),
515
- React.createElement("a", { href: "http://bl.ocks.org/syntagmatic/3150059" }, "Kai"),
516
- ", ",
517
- React.createElement("a", { href: "http://bl.ocks.org/1341021" }, "Mike Bostock"),
518
- " and ",
519
- React.createElement("a", { href: "http://bl.ocks.org/1341281" }, "Jason Davies"),
520
- React.createElement("br", null)),
521
- React.createElement("p", null,
522
- "Released under the ",
523
- React.createElement("strong", null, "MIT License"),
524
- ".")))));
525
- };
526
- return DocAndCredits;
527
- }(React.Component));
528
- ;
@@ -1,26 +0,0 @@
1
- import React from "react";
2
- interface ContextMenuProps {
3
- }
4
- interface ContextMenuState {
5
- visible: boolean;
6
- column: string;
7
- top: number;
8
- left: number;
9
- }
10
- export declare class ContextMenu extends React.Component<ContextMenuProps, ContextMenuState> {
11
- context_menu_div: React.RefObject<HTMLDivElement>;
12
- trigger_callbacks: Array<{
13
- cb: (column: string, element: HTMLDivElement) => void;
14
- obj: any;
15
- }>;
16
- hide: any;
17
- constructor(props: ContextMenuProps);
18
- addCallback(fn: (column: string, element: HTMLDivElement) => void, obj: any): void;
19
- removeCallbacks(obj: any): void;
20
- show(pageX: number, pageY: number, column: string): void;
21
- onContextMenu: any;
22
- componentWillUnmount(): void;
23
- componentDidUpdate(prevProps: Readonly<ContextMenuProps>, prevState: Readonly<ContextMenuState>): void;
24
- render(): JSX.Element;
25
- }
26
- export {};
@@ -1,90 +0,0 @@
1
- /*
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- var __extends = (this && this.__extends) || (function () {
8
- var extendStatics = function (d, b) {
9
- extendStatics = Object.setPrototypeOf ||
10
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12
- return extendStatics(d, b);
13
- };
14
- return function (d, b) {
15
- extendStatics(d, b);
16
- function __() { this.constructor = d; }
17
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
18
- };
19
- })();
20
- import $ from "jquery";
21
- import React from "react";
22
- ;
23
- ;
24
- var ContextMenu = /** @class */ (function (_super) {
25
- __extends(ContextMenu, _super);
26
- function ContextMenu(props) {
27
- var _this = _super.call(this, props) || this;
28
- _this.context_menu_div = React.createRef();
29
- _this.trigger_callbacks = [];
30
- _this.onContextMenu = function (event) {
31
- this.show(event.pageX, event.pageY, '');
32
- event.preventDefault();
33
- event.stopPropagation();
34
- }.bind(_this);
35
- _this.state = {
36
- visible: false,
37
- column: "",
38
- top: 0,
39
- left: 0
40
- };
41
- _this.hide = function () {
42
- if (this.state.visible) {
43
- this.setState({ visible: false });
44
- }
45
- }.bind(_this);
46
- $(window).on("click", _this.hide);
47
- return _this;
48
- }
49
- ContextMenu.prototype.addCallback = function (fn, obj) {
50
- this.trigger_callbacks.push({ cb: fn, obj: obj });
51
- };
52
- ContextMenu.prototype.removeCallbacks = function (obj) {
53
- this.trigger_callbacks = this.trigger_callbacks.filter(function (trigger) { return trigger.obj != obj; });
54
- };
55
- ContextMenu.prototype.show = function (pageX, pageY, column) {
56
- // This assumes parent has `relative` positioning
57
- var parent = $(this.context_menu_div.current.parentElement).offset();
58
- this.setState({
59
- top: Math.max(0, pageY - 10 - parent.top),
60
- left: Math.max(0, pageX - 90 - parent.left),
61
- visible: true,
62
- column: column
63
- });
64
- };
65
- ContextMenu.prototype.componentWillUnmount = function () {
66
- $(window).off("click", this.hide);
67
- };
68
- ContextMenu.prototype.componentDidUpdate = function (prevProps, prevState) {
69
- var cm = this.context_menu_div.current;
70
- cm.style.display = this.state.visible ? 'block' : 'none';
71
- cm.style.top = this.state.top + "px";
72
- cm.style.left = this.state.left + "px";
73
- cm.classList.toggle('show', this.state.visible);
74
- var needsUpdate = (this.state.visible && !prevState.visible) ||
75
- (this.state.column != prevState.column);
76
- if (needsUpdate) {
77
- cm.innerHTML = '';
78
- var me = this;
79
- this.trigger_callbacks.forEach(function (trigger) {
80
- trigger.cb(me.state.column, cm);
81
- });
82
- }
83
- };
84
- ContextMenu.prototype.render = function () {
85
- return (React.createElement("div", { ref: this.context_menu_div, className: "dropdown-menu dropdown-menu-sm context-menu", style: { "fontSize": 16 } }));
86
- };
87
- return ContextMenu;
88
- }(React.Component));
89
- export { ContextMenu };
90
- ;