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.
- hiplot/ipython.py +38 -6
- hiplot/pkginfo.py +18 -2
- hiplot/server.py +8 -2
- hiplot/static/built/hiplot.bundle.js +1 -1
- hiplot/static/built/streamlit_component/hiplot_streamlit.bundle.js +1 -1
- hiplot/streamlit_helpers.py +11 -2
- {hiplot_mm-0.0.1.dist-info → hiplot_mm-0.0.3rc0.dist-info}/METADATA +51 -27
- hiplot_mm-0.0.3rc0.dist-info/RECORD +33 -0
- {hiplot_mm-0.0.1.dist-info → hiplot_mm-0.0.3rc0.dist-info}/WHEEL +1 -1
- {hiplot_mm-0.0.1.dist-info → hiplot_mm-0.0.3rc0.dist-info}/entry_points.txt +0 -1
- hiplot/static/built/component.d.ts +0 -109
- hiplot/static/built/component.js +0 -528
- hiplot/static/built/contextmenu.d.ts +0 -26
- hiplot/static/built/contextmenu.js +0 -90
- hiplot/static/built/controls.d.ts +0 -52
- hiplot/static/built/controls.js +0 -163
- hiplot/static/built/filters.d.ts +0 -21
- hiplot/static/built/filters.js +0 -96
- hiplot/static/built/header.d.ts +0 -39
- hiplot/static/built/header.js +0 -176
- hiplot/static/built/hiplot-mm-0.0.0.tar.gz +0 -0
- hiplot/static/built/hiplot.bundle.js.LICENSE.txt +0 -88
- hiplot/static/built/hiplot.bundle.js.map +0 -1
- hiplot/static/built/hiplot.d.ts +0 -8
- hiplot/static/built/hiplot.js +0 -14
- hiplot/static/built/hiplot.lib.js +0 -57712
- hiplot/static/built/hiplot.lib.js.map +0 -1
- hiplot/static/built/hiplot.licenses.txt +0 -682
- hiplot/static/built/hiplot_mm-0.0.0-py3-none-any.whl +0 -0
- hiplot/static/built/hiplot_streamlit.bundle.js +0 -3
- hiplot/static/built/hiplot_streamlit.bundle.js.LICENSE.txt +0 -97
- hiplot/static/built/hiplot_streamlit.bundle.js.map +0 -1
- hiplot/static/built/hiplot_streamlit.d.ts +0 -1
- hiplot/static/built/hiplot_streamlit.js +0 -85
- hiplot/static/built/hiplot_streamlit.licenses.txt +0 -689
- hiplot/static/built/hiplot_test.bundle.js +0 -3
- hiplot/static/built/hiplot_test.bundle.js.LICENSE.txt +0 -88
- hiplot/static/built/hiplot_test.bundle.js.map +0 -1
- hiplot/static/built/hiplot_test.d.ts +0 -46
- hiplot/static/built/hiplot_test.js +0 -238
- hiplot/static/built/hiplot_test.licenses.txt +0 -682
- hiplot/static/built/hiplot_web.d.ts +0 -3
- hiplot/static/built/hiplot_web.js +0 -54
- hiplot/static/built/infertypes.d.ts +0 -38
- hiplot/static/built/infertypes.js +0 -316
- hiplot/static/built/plotxy.d.ts +0 -62
- hiplot/static/built/plotxy.js +0 -602
- hiplot/static/built/plugin.d.ts +0 -38
- hiplot/static/built/plugin.js +0 -8
- hiplot/static/built/rowsdisplaytable.d.ts +0 -35
- hiplot/static/built/rowsdisplaytable.js +0 -284
- hiplot/static/built/streamlit_component/hiplot.bundle.js +0 -3
- hiplot/static/built/types.d.ts +0 -64
- hiplot/static/built/types.js +0 -55
- hiplot_mm-0.0.1.dist-info/RECORD +0 -77
- {hiplot_mm-0.0.1.dist-info → hiplot_mm-0.0.3rc0.dist-info/licenses}/LICENSE +0 -0
- {hiplot_mm-0.0.1.dist-info → hiplot_mm-0.0.3rc0.dist-info/licenses}/NOTICE +0 -0
- {hiplot_mm-0.0.1.dist-info → hiplot_mm-0.0.3rc0.dist-info}/top_level.txt +0 -0
hiplot/static/built/plotxy.js
DELETED
|
@@ -1,602 +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
|
-
import $ from "jquery";
|
|
32
|
-
import * as d3 from "d3";
|
|
33
|
-
import { create_d3_scale } from "./infertypes";
|
|
34
|
-
import style from "./hiplot.scss";
|
|
35
|
-
import React from "react";
|
|
36
|
-
import { ResizableH } from "./lib/resizable";
|
|
37
|
-
import _ from "underscore";
|
|
38
|
-
import { foCreateAxisLabel, foDynamicSizeFitContent } from "./lib/svghelpers";
|
|
39
|
-
import { ContextMenu } from "./contextmenu";
|
|
40
|
-
;
|
|
41
|
-
;
|
|
42
|
-
;
|
|
43
|
-
var HIGHLIGHT_PARENT = 'parent';
|
|
44
|
-
var HIGHLIGHT_CHILDREN = 'children';
|
|
45
|
-
;
|
|
46
|
-
var PlotXY = /** @class */ (function (_super) {
|
|
47
|
-
__extends(PlotXY, _super);
|
|
48
|
-
function PlotXY(props) {
|
|
49
|
-
var _this = _super.call(this, props) || this;
|
|
50
|
-
_this.root_ref = React.createRef();
|
|
51
|
-
_this.container_ref = React.createRef();
|
|
52
|
-
_this.canvas_lines_ref = React.createRef();
|
|
53
|
-
_this.canvas_highlighted_ref = React.createRef();
|
|
54
|
-
_this.plotXYcontextMenuRef = React.createRef();
|
|
55
|
-
_this.onResize = _.debounce(function (height, width) {
|
|
56
|
-
if (this.state.height != height || this.state.width != width) {
|
|
57
|
-
this.setState({ height: height, width: width });
|
|
58
|
-
}
|
|
59
|
-
}.bind(_this), 100);
|
|
60
|
-
_this.drawSelected = function () {
|
|
61
|
-
if (this.plot) {
|
|
62
|
-
this.plot.draw_selected_rows();
|
|
63
|
-
}
|
|
64
|
-
}.bind(_this);
|
|
65
|
-
_this.drawSelectedThrottled = _.throttle(_this.drawSelected, 100);
|
|
66
|
-
var height;
|
|
67
|
-
if (props.window_state.height) {
|
|
68
|
-
height = props.window_state.height;
|
|
69
|
-
}
|
|
70
|
-
else if (props.height) {
|
|
71
|
-
height = props.height;
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
height = d3.min([d3.max([document.body.clientHeight - 540, 240]), 500]);
|
|
75
|
-
}
|
|
76
|
-
// Load default X/Y axis
|
|
77
|
-
var plotConfig = _this.props;
|
|
78
|
-
function get_default_axis(axis_name) {
|
|
79
|
-
var value = props.persistentState.get(axis_name, props[axis_name]);
|
|
80
|
-
if (value === undefined) {
|
|
81
|
-
value = null;
|
|
82
|
-
}
|
|
83
|
-
if (value != null && props.params_def[value] === undefined) {
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
return value;
|
|
87
|
-
}
|
|
88
|
-
var state = __assign(__assign({}, plotConfig), { axis_x: get_default_axis('axis_x'), axis_y: get_default_axis('axis_y'), width: 0, height: height, initialHeight: height });
|
|
89
|
-
_this.state = __assign(__assign({}, state), { hover_uid: null, highlightType: _this.props.persistentState.get("highlightType", HIGHLIGHT_PARENT) });
|
|
90
|
-
return _this;
|
|
91
|
-
}
|
|
92
|
-
PlotXY.prototype.componentDidMount = function () {
|
|
93
|
-
if (this.props.context_menu_ref && this.props.context_menu_ref.current) {
|
|
94
|
-
var me_1 = this;
|
|
95
|
-
this.props.context_menu_ref.current.addCallback(function (column, cm) {
|
|
96
|
-
var contextmenu = $(cm);
|
|
97
|
-
contextmenu.append($('<div class="dropdown-divider"></div>'));
|
|
98
|
-
contextmenu.append($("<h6 class=\"dropdown-header\">" + me_1.props.name + "</h6>"));
|
|
99
|
-
['axis_x', 'axis_y'].forEach(function (dat, index) {
|
|
100
|
-
var label = "Set as " + ['X', 'Y'][index] + ' axis';
|
|
101
|
-
var option = $('<a class="dropdown-item" href="#">').text(label);
|
|
102
|
-
if (me_1.state[dat] == column) {
|
|
103
|
-
option.addClass('disabled').css('pointer-events', 'none');
|
|
104
|
-
}
|
|
105
|
-
option.click(function (event) {
|
|
106
|
-
if (index == 0) {
|
|
107
|
-
me_1.setState({ axis_x: column });
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
me_1.setState({ axis_y: column });
|
|
111
|
-
}
|
|
112
|
-
event.preventDefault();
|
|
113
|
-
});
|
|
114
|
-
contextmenu.append(option);
|
|
115
|
-
});
|
|
116
|
-
}, this);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
PlotXY.prototype.mountPlotXY = function () {
|
|
120
|
-
var me = this;
|
|
121
|
-
me.plotXYcontextMenuRef.current.removeCallbacks(this);
|
|
122
|
-
me.plotXYcontextMenuRef.current.addCallback(function (column, cm) {
|
|
123
|
-
var contextmenu = $(cm);
|
|
124
|
-
[HIGHLIGHT_PARENT, HIGHLIGHT_CHILDREN].forEach(function (dat) {
|
|
125
|
-
var option = $('<a class="dropdown-item" href="#">').text("Highlight: " + dat);
|
|
126
|
-
if (me.state.highlightType == dat) {
|
|
127
|
-
option.addClass('disabled').css('pointer-events', 'none');
|
|
128
|
-
}
|
|
129
|
-
option.click(function (event) {
|
|
130
|
-
me.setState({ highlightType: dat });
|
|
131
|
-
event.preventDefault();
|
|
132
|
-
});
|
|
133
|
-
contextmenu.append(option);
|
|
134
|
-
});
|
|
135
|
-
}, me);
|
|
136
|
-
var div = d3.select(this.root_ref.current);
|
|
137
|
-
me.svg = div.select("svg");
|
|
138
|
-
var currently_displayed = [];
|
|
139
|
-
var zoom_brush;
|
|
140
|
-
// Lines
|
|
141
|
-
var graph_lines = this.canvas_lines_ref.current.getContext('2d');
|
|
142
|
-
graph_lines.globalCompositeOperation = "destination-over";
|
|
143
|
-
// Highlights
|
|
144
|
-
var highlights = this.canvas_highlighted_ref.current.getContext('2d');
|
|
145
|
-
highlights.globalCompositeOperation = "destination-over";
|
|
146
|
-
var margin = { top: 40, right: 20, bottom: 70, left: 60 };
|
|
147
|
-
var x_scale, y_scale, yAxis, xAxis;
|
|
148
|
-
var x_scale_orig, y_scale_orig;
|
|
149
|
-
function redraw_axis_and_rerender() {
|
|
150
|
-
redraw_axis();
|
|
151
|
-
clear_canvas();
|
|
152
|
-
me.drawSelectedThrottled();
|
|
153
|
-
}
|
|
154
|
-
function create_scale(param, range) {
|
|
155
|
-
var scale = create_d3_scale(me.props.params_def[param]);
|
|
156
|
-
scale.range(range);
|
|
157
|
-
return scale;
|
|
158
|
-
}
|
|
159
|
-
function redraw_axis() {
|
|
160
|
-
me.svg.selectAll(".axis_render").remove();
|
|
161
|
-
me.svg.selectAll(".brush").remove();
|
|
162
|
-
me.svg.attr("viewBox", [0, 0, me.state.width, me.state.height]);
|
|
163
|
-
me.svg.append("g").attr('class', 'axis_render').call(xAxis);
|
|
164
|
-
me.svg.append("g").attr('class', 'axis_render').call(yAxis);
|
|
165
|
-
me.svg.append("g").attr("class", "brush").call(zoom_brush);
|
|
166
|
-
}
|
|
167
|
-
function recompute_scale(force) {
|
|
168
|
-
if (force === void 0) { force = false; }
|
|
169
|
-
if (!force && !me.isEnabled()) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
var insideGraphMargin = Math.max(me.props.dots_thickness, me.props.dots_highlighed_thickness, 0);
|
|
173
|
-
x_scale_orig = x_scale = create_scale(me.state.axis_x, [margin.left + insideGraphMargin, me.state.width - margin.right - insideGraphMargin]);
|
|
174
|
-
y_scale_orig = y_scale = create_scale(me.state.axis_y, [me.state.height - margin.bottom - insideGraphMargin, margin.top + insideGraphMargin]);
|
|
175
|
-
zoom_brush = d3.brush().extent([[margin.left, margin.top], [me.state.width - margin.right, me.state.height - margin.bottom]]).on("end", brushended);
|
|
176
|
-
yAxis = function (g) { return g
|
|
177
|
-
.attr("transform", "translate(" + (margin.left - 10) + ",0)")
|
|
178
|
-
.call(d3.axisLeft(y_scale).ticks(1 + me.state.height / 40).tickSizeInner(margin.left + margin.right - me.state.width))
|
|
179
|
-
.call(function (g) { return g.select(".domain").remove(); })
|
|
180
|
-
.call(function (g) { return g.select(".tick:last-of-type").append(function () {
|
|
181
|
-
var label = foCreateAxisLabel(me.props.params_def[me.state.axis_y], me.props.context_menu_ref);
|
|
182
|
-
d3.select(label).attr("y", "" + (-this.transform.baseVal[0].matrix.f + 10));
|
|
183
|
-
return label;
|
|
184
|
-
})
|
|
185
|
-
.attr("x", 3)
|
|
186
|
-
.attr("text-anchor", "start")
|
|
187
|
-
.attr("font-weight", "bold")
|
|
188
|
-
.classed("plotxy-label", true); })
|
|
189
|
-
.attr("font-size", null)
|
|
190
|
-
.call(function (g) { return g.selectAll(".plotxy-label").each(function () { foDynamicSizeFitContent(this); }); }); };
|
|
191
|
-
xAxis = function (g) { return g
|
|
192
|
-
.attr("transform", "translate(0," + (me.state.height - margin.bottom) + ")")
|
|
193
|
-
.call(d3.axisBottom(x_scale).ticks(1 + me.state.width / 80).tickSizeInner(margin.bottom + margin.top - me.state.height))
|
|
194
|
-
.call(function (g) { return g.select(".tick:last-of-type").each(function () {
|
|
195
|
-
var fo = foCreateAxisLabel(me.props.params_def[me.state.axis_x], me.props.context_menu_ref, /* label */ null);
|
|
196
|
-
d3.select(fo)
|
|
197
|
-
.attr("y", 40)
|
|
198
|
-
.attr("text-anchor", "end")
|
|
199
|
-
.attr("font-weight", "bold")
|
|
200
|
-
.classed("plotxy-label", true);
|
|
201
|
-
var clone = this.cloneNode(false);
|
|
202
|
-
clone.appendChild(fo);
|
|
203
|
-
this.parentElement.appendChild(clone);
|
|
204
|
-
}); })
|
|
205
|
-
// Make odd ticks below (to prevent overlap when very long labels)
|
|
206
|
-
.call(function (g) { return g
|
|
207
|
-
.selectAll(".tick")
|
|
208
|
-
.each(function (d, i) {
|
|
209
|
-
var line = this.children[0];
|
|
210
|
-
if (this.childElementCount == 2 && this.children[1].textLength.baseVal.value && line.nodeName == "line") {
|
|
211
|
-
this.transform.baseVal.getItem(0).matrix.f += 20 * (i % 2);
|
|
212
|
-
line.setAttribute("y2", "" + (parseFloat(line.getAttribute("y2")) - 20 * (i % 2)));
|
|
213
|
-
}
|
|
214
|
-
}); })
|
|
215
|
-
.attr("font-size", null)
|
|
216
|
-
.call(function (g) { return g.selectAll(".plotxy-label").each(function () { foDynamicSizeFitContent(this); }); }); };
|
|
217
|
-
div.selectAll("canvas")
|
|
218
|
-
.attr("width", me.state.width - margin.left - margin.right)
|
|
219
|
-
.attr("height", me.state.height - margin.top - margin.bottom);
|
|
220
|
-
div.selectAll("svg")
|
|
221
|
-
.attr("width", me.state.width)
|
|
222
|
-
.attr("height", me.state.height);
|
|
223
|
-
div.style("height", me.state.height + "px");
|
|
224
|
-
div.selectAll('canvas').style('margin', margin.top + 'px ' + margin.right + 'px ' + margin.bottom + 'px ' + margin.left + 'px');
|
|
225
|
-
redraw_axis();
|
|
226
|
-
}
|
|
227
|
-
function on_move() {
|
|
228
|
-
var pos_top = $(me.root_ref.current).position().top;
|
|
229
|
-
var pos_left = $(me.root_ref.current).position().left;
|
|
230
|
-
div.selectAll("canvas").style("top", pos_top + "px").style("left", pos_left + "px");
|
|
231
|
-
me.svg.style("top", pos_top + "px").style("left", pos_left + "px");
|
|
232
|
-
}
|
|
233
|
-
function brushended(event) {
|
|
234
|
-
var s = event.selection;
|
|
235
|
-
if (!s) {
|
|
236
|
-
if (x_scale === x_scale_orig && y_scale === y_scale_orig) {
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
x_scale = x_scale_orig;
|
|
240
|
-
y_scale = y_scale_orig;
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
if (x_scale.invert !== undefined) {
|
|
244
|
-
var xrange = [x_scale.invert(s[0][0]), x_scale.invert(s[1][0])];
|
|
245
|
-
x_scale = create_scale(me.state.axis_x, [margin.left, me.state.width - margin.right]);
|
|
246
|
-
x_scale.domain(xrange);
|
|
247
|
-
}
|
|
248
|
-
if (y_scale.invert !== undefined) {
|
|
249
|
-
var yrange = [y_scale.invert(s[1][1]), y_scale.invert(s[0][1])];
|
|
250
|
-
y_scale = create_scale(me.state.axis_y, [me.state.height - margin.bottom, margin.top]);
|
|
251
|
-
y_scale.domain(yrange);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
redraw_axis_and_rerender();
|
|
255
|
-
}
|
|
256
|
-
on_move();
|
|
257
|
-
function hover(svg, path) {
|
|
258
|
-
var dot = me.svg.append("g")
|
|
259
|
-
.attr("display", "none");
|
|
260
|
-
dot.append("circle")
|
|
261
|
-
.attr("r", 2.5);
|
|
262
|
-
dot.append("text")
|
|
263
|
-
.style("font", "10px sans-serif")
|
|
264
|
-
.attr("text-anchor", "middle")
|
|
265
|
-
.attr("y", -8);
|
|
266
|
-
if ("ontouchstart" in document)
|
|
267
|
-
svg
|
|
268
|
-
.style("-webkit-tap-highlight-color", "transparent")
|
|
269
|
-
.on("touchmove", moved)
|
|
270
|
-
.on("touchstart", entered)
|
|
271
|
-
.on("touchend", left);
|
|
272
|
-
else
|
|
273
|
-
svg
|
|
274
|
-
.on("mousemove", moved)
|
|
275
|
-
.on("mouseenter", entered)
|
|
276
|
-
.on("mouseleave", left);
|
|
277
|
-
function moved(event) {
|
|
278
|
-
event.preventDefault();
|
|
279
|
-
var closest = null;
|
|
280
|
-
var closest_dist = null;
|
|
281
|
-
$.each(currently_displayed, function (_, dp) {
|
|
282
|
-
var dist = Math.pow((dp['layerX'] - event.layerX), 2) + Math.pow((dp['layerY'] - event.layerY), 2);
|
|
283
|
-
if (closest_dist == null || dist < closest_dist) {
|
|
284
|
-
closest_dist = dist;
|
|
285
|
-
closest = dp;
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
if (closest === null) {
|
|
289
|
-
dot.attr("transform", "translate(" + event.layerX + "," + event.layerY + ")");
|
|
290
|
-
dot.select("text").text("No point found?!");
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
me.setState({
|
|
294
|
-
hover_uid: closest['dp'].uid
|
|
295
|
-
});
|
|
296
|
-
dot.attr("transform", "translate(" + closest["layerX"] + "," + closest["layerY"] + ")");
|
|
297
|
-
dot.select("text").text(me.props.render_row_text(closest['dp']));
|
|
298
|
-
}
|
|
299
|
-
function entered() {
|
|
300
|
-
dot.attr("display", null);
|
|
301
|
-
}
|
|
302
|
-
function left() {
|
|
303
|
-
me.setState({
|
|
304
|
-
hover_uid: null
|
|
305
|
-
});
|
|
306
|
-
dot.attr("display", "none");
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
;
|
|
310
|
-
me.svg.call(hover);
|
|
311
|
-
function render_dp(dp, ctx, c) {
|
|
312
|
-
if (c.lines_color)
|
|
313
|
-
ctx.strokeStyle = c.lines_color;
|
|
314
|
-
if (c.dots_color)
|
|
315
|
-
ctx.fillStyle = c.dots_color;
|
|
316
|
-
if (c.lines_width)
|
|
317
|
-
ctx.lineWidth = c.lines_width;
|
|
318
|
-
var pdx = me.props.params_def[me.state.axis_x];
|
|
319
|
-
var pdy = me.props.params_def[me.state.axis_y];
|
|
320
|
-
function is_err(value, scaled_value, def) {
|
|
321
|
-
return value === undefined || value === null || isNaN(scaled_value) || (def.numeric && (value == 'inf' || value == '-inf'));
|
|
322
|
-
}
|
|
323
|
-
function render_point_position(dp) {
|
|
324
|
-
var x = x_scale(dp[me.state.axis_x]);
|
|
325
|
-
var y = y_scale(dp[me.state.axis_y]);
|
|
326
|
-
x -= margin.left;
|
|
327
|
-
y -= margin.top;
|
|
328
|
-
var err = is_err(dp[me.state.axis_x], x, pdx) || is_err(dp[me.state.axis_y], y, pdy);
|
|
329
|
-
if (err) {
|
|
330
|
-
return null;
|
|
331
|
-
}
|
|
332
|
-
if (c.remember) {
|
|
333
|
-
currently_displayed.push({
|
|
334
|
-
'layerX': x + margin.left,
|
|
335
|
-
'layerY': y + margin.top,
|
|
336
|
-
'dp': dp
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
return { x: x, y: y };
|
|
340
|
-
}
|
|
341
|
-
var pos = render_point_position(dp);
|
|
342
|
-
if (pos === null) {
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
if (dp.from_uid && c.lines_width > 0.0) {
|
|
346
|
-
var dp_prev = me.props.dp_lookup[dp.from_uid];
|
|
347
|
-
if (dp_prev) {
|
|
348
|
-
var prev_pos = render_point_position(dp_prev);
|
|
349
|
-
if (prev_pos !== null) {
|
|
350
|
-
ctx.beginPath();
|
|
351
|
-
ctx.moveTo(prev_pos.x, prev_pos.y);
|
|
352
|
-
ctx.lineTo(pos.x, pos.y);
|
|
353
|
-
ctx.stroke();
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
else {
|
|
357
|
-
console.log('DataPoint with id ' + dp.from_uid + ' not found (dp.from_uid)', dp);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
if (c.dots_thickness > 0) {
|
|
361
|
-
ctx.beginPath();
|
|
362
|
-
ctx.arc(pos.x, pos.y, c.dots_thickness, 0, 2 * Math.PI, true);
|
|
363
|
-
ctx.fill();
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
;
|
|
367
|
-
function draw_selected_rows() {
|
|
368
|
-
if (!me.isEnabled()) {
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
clear_canvas();
|
|
372
|
-
var xp_config = me.props;
|
|
373
|
-
var area = me.state.height * me.state.width / 400000;
|
|
374
|
-
var lines_opacity = xp_config.lines_opacity !== null ? xp_config.lines_opacity : d3.min([3 * area / Math.pow(me.props.rows_selected.length, 0.3), 1]);
|
|
375
|
-
var dots_opacity = xp_config.dots_opacity !== null ? xp_config.dots_opacity : d3.min([4 * area / Math.pow(me.props.rows_selected.length, 0.3), 1]);
|
|
376
|
-
me.props.rows_selected.forEach(function (dp) {
|
|
377
|
-
render_dp(dp, graph_lines, {
|
|
378
|
-
'lines_color': me.props.get_color_for_row(dp, lines_opacity),
|
|
379
|
-
'lines_width': xp_config.lines_thickness,
|
|
380
|
-
'dots_color': me.props.get_color_for_row(dp, dots_opacity),
|
|
381
|
-
'dots_thickness': xp_config.dots_thickness,
|
|
382
|
-
'remember': true
|
|
383
|
-
});
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
function clear_canvas() {
|
|
387
|
-
graph_lines.clearRect(0, 0, me.state.width, me.state.height);
|
|
388
|
-
highlights.clearRect(0, 0, me.state.width, me.state.height);
|
|
389
|
-
currently_displayed = [];
|
|
390
|
-
}
|
|
391
|
-
;
|
|
392
|
-
function lookupParent(dp) {
|
|
393
|
-
if (dp.from_uid === null) {
|
|
394
|
-
return [];
|
|
395
|
-
}
|
|
396
|
-
var nextDp = me.props.dp_lookup[dp.from_uid];
|
|
397
|
-
return nextDp === undefined ? [] : [nextDp];
|
|
398
|
-
}
|
|
399
|
-
;
|
|
400
|
-
var childrenLookup = {};
|
|
401
|
-
function lookupChildren(dp) {
|
|
402
|
-
var next = childrenLookup[dp.uid];
|
|
403
|
-
return next ? next : [];
|
|
404
|
-
}
|
|
405
|
-
;
|
|
406
|
-
// Draw highlights
|
|
407
|
-
function draw_highlighted() {
|
|
408
|
-
var _a;
|
|
409
|
-
if (!me.isEnabled()) {
|
|
410
|
-
return;
|
|
411
|
-
}
|
|
412
|
-
var highlighted = me.props.rows_highlighted;
|
|
413
|
-
highlights.clearRect(0, 0, me.state.width, me.state.height);
|
|
414
|
-
d3.select(me.canvas_highlighted_ref.current).style("opacity", "0");
|
|
415
|
-
d3.select(me.canvas_lines_ref.current).style("opacity", "1.0");
|
|
416
|
-
if (!highlighted.length) { // Stop highlight
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
d3.select(me.canvas_highlighted_ref.current).style("opacity", "1.0");
|
|
420
|
-
d3.select(me.canvas_lines_ref.current).style("opacity", "0.5");
|
|
421
|
-
childrenLookup = {};
|
|
422
|
-
if (me.state.highlightType == HIGHLIGHT_CHILDREN) {
|
|
423
|
-
// Pre-compute graph of children - TODO: maybe we could cache that
|
|
424
|
-
me.props.rows_filtered.forEach(function (dp) {
|
|
425
|
-
if (dp.from_uid !== null) {
|
|
426
|
-
if (childrenLookup[dp.from_uid] === undefined) {
|
|
427
|
-
childrenLookup[dp.from_uid] = [dp];
|
|
428
|
-
}
|
|
429
|
-
else {
|
|
430
|
-
childrenLookup[dp.from_uid].push(dp);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
var lookupNextDp = (_a = {},
|
|
436
|
-
_a[HIGHLIGHT_CHILDREN] = lookupChildren,
|
|
437
|
-
_a[HIGHLIGHT_PARENT] = lookupParent,
|
|
438
|
-
_a)[me.state.highlightType];
|
|
439
|
-
// Find all runs + parents
|
|
440
|
-
var todo = new Set(highlighted);
|
|
441
|
-
var allHighlighted = new Set();
|
|
442
|
-
while (todo.size) {
|
|
443
|
-
var oldTodo = todo;
|
|
444
|
-
todo = new Set();
|
|
445
|
-
oldTodo.forEach(function (dp) {
|
|
446
|
-
if (allHighlighted.has(dp)) {
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
allHighlighted.add(dp);
|
|
450
|
-
lookupNextDp(dp).forEach(function (newDp) { todo.add(newDp); });
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
allHighlighted.forEach(function (dp) {
|
|
454
|
-
var color = me.props.get_color_for_row(dp, 1.0).split(',');
|
|
455
|
-
render_dp(dp, highlights, {
|
|
456
|
-
'lines_color': [color[0], color[1], color[2], 1.0 + ')'].join(','),
|
|
457
|
-
'lines_width': 4,
|
|
458
|
-
'dots_color': [color[0], color[1], color[2], 0.8 + ')'].join(','),
|
|
459
|
-
'dots_thickness': me.props.dots_highlighed_thickness
|
|
460
|
-
});
|
|
461
|
-
});
|
|
462
|
-
}
|
|
463
|
-
// Change axis
|
|
464
|
-
function update_axis() {
|
|
465
|
-
recompute_scale(true);
|
|
466
|
-
clear_canvas();
|
|
467
|
-
me.drawSelectedThrottled();
|
|
468
|
-
}
|
|
469
|
-
;
|
|
470
|
-
update_axis();
|
|
471
|
-
// Initial lines right now
|
|
472
|
-
draw_selected_rows();
|
|
473
|
-
me.drawSelectedThrottled.cancel();
|
|
474
|
-
return {
|
|
475
|
-
clear_canvas: clear_canvas,
|
|
476
|
-
update_axis: update_axis,
|
|
477
|
-
recompute_scale: recompute_scale,
|
|
478
|
-
draw_selected_rows: draw_selected_rows,
|
|
479
|
-
draw_highlighted: draw_highlighted,
|
|
480
|
-
on_resize: _.debounce(function () {
|
|
481
|
-
if (this.isEnabled()) {
|
|
482
|
-
recompute_scale();
|
|
483
|
-
draw_selected_rows();
|
|
484
|
-
}
|
|
485
|
-
}.bind(this), 150)
|
|
486
|
-
};
|
|
487
|
-
};
|
|
488
|
-
PlotXY.prototype.disable = function () {
|
|
489
|
-
this.setState({ axis_x: null, axis_y: null, height: this.state.initialHeight });
|
|
490
|
-
};
|
|
491
|
-
PlotXY.prototype.render = function () {
|
|
492
|
-
var _a;
|
|
493
|
-
if (!this.isEnabled()) {
|
|
494
|
-
return [];
|
|
495
|
-
}
|
|
496
|
-
return (React.createElement(ResizableH, { initialHeight: this.state.height, onResize: this.onResize, onRemove: this.disable.bind(this) },
|
|
497
|
-
React.createElement(ContextMenu, { ref: this.plotXYcontextMenuRef }),
|
|
498
|
-
this.state.width > 0 && React.createElement("div", { onContextMenu: (_a = this.plotXYcontextMenuRef.current) === null || _a === void 0 ? void 0 : _a.onContextMenu, ref: this.root_ref, style: { "height": this.state.height } },
|
|
499
|
-
React.createElement("canvas", { ref: this.canvas_lines_ref, className: style["plotxy-graph-lines"], style: { position: 'absolute' } }),
|
|
500
|
-
React.createElement("canvas", { ref: this.canvas_highlighted_ref, className: style["plotxy-graph-highlights"], style: { position: 'absolute' } }),
|
|
501
|
-
React.createElement("svg", { className: style["plotxy-graph-svg"], style: { position: 'absolute' } }))));
|
|
502
|
-
};
|
|
503
|
-
PlotXY.prototype.componentWillUnmount = function () {
|
|
504
|
-
if (this.plot) {
|
|
505
|
-
this.plot.clear_canvas();
|
|
506
|
-
this.plot.on_resize.cancel();
|
|
507
|
-
this.svg.selectAll("*").remove();
|
|
508
|
-
}
|
|
509
|
-
if (this.props.context_menu_ref && this.props.context_menu_ref.current) {
|
|
510
|
-
this.props.context_menu_ref.current.removeCallbacks(this);
|
|
511
|
-
}
|
|
512
|
-
this.drawSelectedThrottled.cancel();
|
|
513
|
-
this.onResize.cancel();
|
|
514
|
-
if (this.plotXYcontextMenuRef.current) {
|
|
515
|
-
this.plotXYcontextMenuRef.current.removeCallbacks(this);
|
|
516
|
-
}
|
|
517
|
-
};
|
|
518
|
-
;
|
|
519
|
-
PlotXY.prototype.isEnabled = function () {
|
|
520
|
-
return this.state.axis_x !== null && this.state.axis_y !== null;
|
|
521
|
-
};
|
|
522
|
-
PlotXY.prototype.componentDidUpdate = function (prevProps, prevState) {
|
|
523
|
-
var anyAxisChanged = false;
|
|
524
|
-
['axis_x', 'axis_y'].forEach(function (d) {
|
|
525
|
-
if (prevState[d] != this.state[d]) {
|
|
526
|
-
this.props.persistentState.set(d, this.state[d]);
|
|
527
|
-
anyAxisChanged = true;
|
|
528
|
-
}
|
|
529
|
-
}.bind(this));
|
|
530
|
-
if (this.state.highlightType != prevState.highlightType) {
|
|
531
|
-
this.props.persistentState.set("highlightType", this.state.highlightType);
|
|
532
|
-
}
|
|
533
|
-
if (this.state.width == 0) {
|
|
534
|
-
return; // Loading...
|
|
535
|
-
}
|
|
536
|
-
if (this.isEnabled() && !this.plot) {
|
|
537
|
-
this.plot = this.mountPlotXY();
|
|
538
|
-
}
|
|
539
|
-
if (prevState.height != this.state.height || prevState.width != this.state.width) {
|
|
540
|
-
if (this.plot) {
|
|
541
|
-
this.plot.on_resize();
|
|
542
|
-
this.props.sendMessage("height_changed", function () { return null; });
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
if (!this.isEnabled()) {
|
|
546
|
-
if (this.plot !== null) {
|
|
547
|
-
this.plot = null;
|
|
548
|
-
this.props.sendMessage("height_changed", function () { return null; });
|
|
549
|
-
}
|
|
550
|
-
if (this.state.hover_uid !== null) {
|
|
551
|
-
this.setState({
|
|
552
|
-
hover_uid: null
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
else {
|
|
557
|
-
if (anyAxisChanged) {
|
|
558
|
-
this.plot.update_axis();
|
|
559
|
-
this.props.sendMessage("height_changed", function () { return null; });
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
if (this.state.hover_uid != prevState.hover_uid) {
|
|
563
|
-
if (this.state.hover_uid === null) {
|
|
564
|
-
this.props.setHighlighted([]);
|
|
565
|
-
}
|
|
566
|
-
else {
|
|
567
|
-
this.props.setHighlighted([this.props.dp_lookup[this.state.hover_uid]]);
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
// Check if data changed
|
|
571
|
-
if (this.plot) {
|
|
572
|
-
var scaleRecomputed = false;
|
|
573
|
-
var colorByChange = this.props.params_def[this.props.colorby] != prevProps.params_def[prevProps.colorby];
|
|
574
|
-
if (this.props.params_def[this.state.axis_x] != prevProps.params_def[this.state.axis_x] ||
|
|
575
|
-
this.props.params_def[this.state.axis_y] != prevProps.params_def[this.state.axis_y]) {
|
|
576
|
-
this.plot.recompute_scale();
|
|
577
|
-
scaleRecomputed = true;
|
|
578
|
-
}
|
|
579
|
-
if (this.props.rows_selected != prevProps.rows_selected || scaleRecomputed || colorByChange) {
|
|
580
|
-
this.drawSelectedThrottled();
|
|
581
|
-
}
|
|
582
|
-
if (this.props.rows_highlighted != prevProps.rows_highlighted || scaleRecomputed ||
|
|
583
|
-
colorByChange ||
|
|
584
|
-
this.state.highlightType != prevState.highlightType) {
|
|
585
|
-
this.plot.draw_highlighted();
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
this.props.window_state.height = this.state.height;
|
|
589
|
-
};
|
|
590
|
-
PlotXY.defaultProps = {
|
|
591
|
-
axis_x: null,
|
|
592
|
-
axis_y: null,
|
|
593
|
-
lines_thickness: 1.2,
|
|
594
|
-
lines_opacity: null,
|
|
595
|
-
dots_highlighed_thickness: 5.0,
|
|
596
|
-
dots_thickness: 1.4,
|
|
597
|
-
dots_opacity: null,
|
|
598
|
-
data: {}
|
|
599
|
-
};
|
|
600
|
-
return PlotXY;
|
|
601
|
-
}(React.Component));
|
|
602
|
-
export { PlotXY };
|
hiplot/static/built/plugin.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ParamDefMap } from "./infertypes";
|
|
3
|
-
import { IDatasets, DatapointLookup, Datapoint, HiPlotExperiment, HiPlotLoadStatus } from "./types";
|
|
4
|
-
import { ContextMenu } from "./contextmenu";
|
|
5
|
-
import { PersistentState } from "./lib/savedstate";
|
|
6
|
-
import { Filter } from "./filters";
|
|
7
|
-
export interface HiPlotPluginDataWithoutDatasets {
|
|
8
|
-
experiment: HiPlotExperiment;
|
|
9
|
-
params_def: ParamDefMap;
|
|
10
|
-
params_def_unfiltered: ParamDefMap;
|
|
11
|
-
get_color_for_row: (uid: Datapoint, opacity: number) => string;
|
|
12
|
-
render_row_text: (rows: Datapoint) => string;
|
|
13
|
-
dp_lookup: DatapointLookup;
|
|
14
|
-
context_menu_ref?: React.RefObject<ContextMenu>;
|
|
15
|
-
colorby: string;
|
|
16
|
-
name: string;
|
|
17
|
-
rows_selected_filter: Filter;
|
|
18
|
-
window_state: any;
|
|
19
|
-
persistentState: PersistentState;
|
|
20
|
-
sendMessage: (type: string, data: () => any) => void;
|
|
21
|
-
setSelected: (new_selected: Array<Datapoint>, filter: Filter | null) => void;
|
|
22
|
-
setHighlighted: (new_highlighted: Array<Datapoint>) => void;
|
|
23
|
-
asserts: boolean;
|
|
24
|
-
}
|
|
25
|
-
export interface HiPlotPluginData extends IDatasets, HiPlotPluginDataWithoutDatasets {
|
|
26
|
-
}
|
|
27
|
-
export interface DataProviderProps {
|
|
28
|
-
persistentState: PersistentState;
|
|
29
|
-
loadStatus: HiPlotLoadStatus;
|
|
30
|
-
hasFocus: boolean;
|
|
31
|
-
onFocusChange: (hasFocus: boolean) => void;
|
|
32
|
-
onLoadExperiment: (load_promise: Promise<any>) => void;
|
|
33
|
-
}
|
|
34
|
-
export declare type DataProviderComponent = React.Component<DataProviderProps, any>;
|
|
35
|
-
export declare type DataProviderComponentClass = React.ComponentClass<DataProviderProps>;
|
|
36
|
-
export declare type DataProviderClass = React.ClassType<DataProviderProps, DataProviderComponent, DataProviderComponentClass> & {
|
|
37
|
-
refresh?: any;
|
|
38
|
-
};
|
hiplot/static/built/plugin.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Datapoint } from "./types";
|
|
3
|
-
import { HiPlotPluginData } from "./plugin";
|
|
4
|
-
import _ from "underscore";
|
|
5
|
-
interface RowsDisplayTableState {
|
|
6
|
-
}
|
|
7
|
-
export interface TableDisplayData {
|
|
8
|
-
hide: Array<string>;
|
|
9
|
-
order_by: Array<[string, string]>;
|
|
10
|
-
order?: Array<string>;
|
|
11
|
-
}
|
|
12
|
-
interface TablePluginProps extends HiPlotPluginData, TableDisplayData {
|
|
13
|
-
}
|
|
14
|
-
export declare class RowsDisplayTable extends React.Component<TablePluginProps, RowsDisplayTableState> {
|
|
15
|
-
table_ref: React.RefObject<HTMLTableElement>;
|
|
16
|
-
table_container: React.RefObject<HTMLDivElement>;
|
|
17
|
-
dt: any;
|
|
18
|
-
ordered_cols: Array<string>;
|
|
19
|
-
empty: boolean;
|
|
20
|
-
setSelected_debounced: ((selected: Array<Datapoint>) => void) & _.Cancelable;
|
|
21
|
-
static defaultProps: {
|
|
22
|
-
hide: any[];
|
|
23
|
-
order_by: string[][];
|
|
24
|
-
};
|
|
25
|
-
constructor(props: TablePluginProps);
|
|
26
|
-
componentDidMount(): void;
|
|
27
|
-
mountDt(): void;
|
|
28
|
-
componentDidUpdate(prevProps: HiPlotPluginData): void;
|
|
29
|
-
setSelectedToSearchResult(): void;
|
|
30
|
-
setSelected(selected: Array<Datapoint>): void;
|
|
31
|
-
render(): JSX.Element;
|
|
32
|
-
destroyDt(): void;
|
|
33
|
-
componentWillUnmount(): void;
|
|
34
|
-
}
|
|
35
|
-
export {};
|