@@ -5601,15 +5601,36 @@ class Zoom {
5601
5601
constructor(selector2, prefs, plot) {
5602
5602
this.prefs = prefs;
5603
5603
this.svg_element_selection = select(selector2);
5604
- this.width = +this.svg_element_selection.attr(" width") ;
5605
- this.height = +this.svg_element_selection.attr(" height") ;
5604
+ this._width = plot. width;
5605
+ this._height = plot. height;
5606
5606
this.renderers = /* @__PURE__ */ new Map();
5607
5607
this.scatterplot = plot;
5608
5608
this.renderers = /* @__PURE__ */ new Map();
5609
5609
}
5610
+ get width() {
5611
+ return this._width;
5612
+ }
5613
+ get height() {
5614
+ return this._height;
5615
+ }
5616
+ resize(width, height) {
5617
+ const { x_, y_ } = this.scales();
5618
+ const old_center = [
5619
+ x_.invert(this._width / 2),
5620
+ y_.invert(this._height / 2)
5621
+ ];
5622
+ this.zoomer.extent([
5623
+ [0, 0],
5624
+ [width, height]
5625
+ ]);
5626
+ this._width = width;
5627
+ this._height = height;
5628
+ this.scales(true);
5629
+ this.zoom_to(this.transform.k, old_center[0], old_center[1]);
5630
+ }
5610
5631
attach_tiles(tiles) {
5611
- this.tileSet = tiles;
5612
- this.tileSet ._zoom = this;
5632
+ this.dataset = tiles;
5633
+ this.dataset ._zoom = this;
5613
5634
return this;
5614
5635
}
5615
5636
attach_renderer(key, renderer) {
@@ -5618,7 +5639,7 @@ class Zoom {
5618
5639
renderer.zoom.initialize_zoom();
5619
5640
return this;
5620
5641
}
5621
- zoom_to(k, x = null , y = null , duration = 4e3) {
5642
+ zoom_to(k, x, y, duration = 4e3) {
5622
5643
const scales2 = this.scales();
5623
5644
const { svg_element_selection: canvas, zoomer, width, height } = this;
5624
5645
const t = identity$3.translate(width / 2, height / 2).scale(k).translate(-scales2.x(x), -scales2.y(y));
@@ -5644,7 +5665,6 @@ class Zoom {
5644
5665
const scales2 = this.scales();
5645
5666
let [x02, x12] = corners.x.map(scales2.x);
5646
5667
let [y02, y12] = corners.y.map(scales2.y);
5647
- console.log(this.scatterplot.prefs.zoom_align, "AAH");
5648
5668
if (this.scatterplot.prefs.zoom_align === "right") {
5649
5669
const aspect_ratio = this.width / this.height;
5650
5670
const data_aspect_ratio = (x12 - x02) / (y12 - y02);
@@ -5661,10 +5681,7 @@ class Zoom {
5661
5681
initialize_zoom() {
5662
5682
const { width, height, svg_element_selection: canvas } = this;
5663
5683
this.transform = identity$3;
5664
- const zoomer = zoom().scaleExtent([1 / 3, 1e5]).extent([
5665
- [0, 0],
5666
- [width, height]
5667
- ]).on("zoom", (event) => {
5684
+ const zoomer = zoom().scaleExtent([1 / 3, 1e5]).on("zoom", (event) => {
5668
5685
var _a2, _b2, _c2;
5669
5686
try {
5670
5687
document.getElementById("tooltipcircle").remove();
@@ -5678,6 +5695,7 @@ class Zoom {
5678
5695
canvas.call(zoomer);
5679
5696
this.add_mouseover();
5680
5697
this.zoomer = zoomer;
5698
+ this.resize(width, height);
5681
5699
}
5682
5700
set_highlit_points(data) {
5683
5701
const { x_, y_ } = this.scales();
@@ -5757,22 +5775,22 @@ class Zoom {
5757
5775
}
5758
5776
data(dataset) {
5759
5777
if (dataset === void 0) {
5760
- return this.tileSet ;
5778
+ return this.dataset ;
5761
5779
}
5762
- this.tileSet = dataset;
5780
+ this.dataset = dataset;
5763
5781
return this;
5764
5782
}
5765
- scales(equal_units = true ) {
5766
- if (this._scales) {
5783
+ scales(force = false ) {
5784
+ if (force !== true && this._scales) {
5767
5785
this._scales.x_ = this.transform.rescaleX(this._scales.x);
5768
5786
this._scales.y_ = this.transform.rescaleY(this._scales.y);
5769
5787
return this._scales;
5770
5788
}
5771
5789
const { width, height } = this;
5772
- if (this.tileSet === void 0) {
5790
+ if (this.dataset === void 0) {
5773
5791
throw new Error("Error--scales created before tileSet present.");
5774
5792
}
5775
- const { extent: extent2 } = this.tileSet ;
5793
+ const { extent: extent2 } = this.dataset ;
5776
5794
const scales2 = {};
5777
5795
if (extent2 === void 0) {
5778
5796
throw new Error("Error--scales created before extent present.");
@@ -15764,11 +15782,29 @@ class Renderer {
15764
15782
this.holder.node().firstElementChild
15765
15783
).node();
15766
15784
this.dataset = tileSet;
15767
- this.width = +select( this.canvas).attr(" width") ;
15768
- this.height = +select( this.canvas).attr(" height") ;
15785
+ this._width = this.scatterplot. width;
15786
+ this._height = this.scatterplot. height;
15769
15787
this.deferred_functions = [];
15770
15788
this._use_scale_to_download_tiles = true;
15771
15789
}
15790
+ get width() {
15791
+ return this._width;
15792
+ }
15793
+ set width(value) {
15794
+ this._width = value;
15795
+ this.resize(this._width, this._height);
15796
+ }
15797
+ get height() {
15798
+ return this._height;
15799
+ }
15800
+ set height(value) {
15801
+ this._height = value;
15802
+ this.resize(this._width, this._height);
15803
+ }
15804
+ resize(width, height) {
15805
+ this._width = width;
15806
+ this._height = height;
15807
+ }
15772
15808
get discard_share() {
15773
15809
return 0;
15774
15810
}
@@ -24464,6 +24500,7 @@ class ReglRenderer extends Renderer {
24464
24500
} else {
24465
24501
tileSet.download_most_needed_tiles(prefs.max_points, this.max_ix, 5);
24466
24502
}
24503
+ regl2.poll();
24467
24504
regl2.clear({
24468
24505
color: [0.9, 0.9, 0.93, 0],
24469
24506
depth: 1
@@ -24706,6 +24743,19 @@ class ReglRenderer extends Renderer {
24706
24743
depth: false
24707
24744
});
24708
24745
}
24746
+ resize(width, height) {
24747
+ super.resize(width, height);
24748
+ this.resize_textures();
24749
+ }
24750
+ resize_textures() {
24751
+ var _a2, _b2, _c2, _d2, _e2, _f2;
24752
+ (_a2 = this.fbos.colorpicker) == null ? void 0 : _a2.resize(this.width, this.height);
24753
+ (_b2 = this.fbos.contour) == null ? void 0 : _b2.resize(this.width, this.height);
24754
+ (_c2 = this.fbos.ping) == null ? void 0 : _c2.resize(this.width, this.height);
24755
+ (_d2 = this.fbos.pong) == null ? void 0 : _d2.resize(this.width, this.height);
24756
+ (_e2 = this.fbos.lines) == null ? void 0 : _e2.resize(this.width, this.height);
24757
+ (_f2 = this.fbos.points) == null ? void 0 : _f2.resize(this.width, this.height);
24758
+ }
24709
24759
get_image_texture(url) {
24710
24760
const { regl: regl2 } = this;
24711
24761
this.textures = this.textures || {};
@@ -25282,7 +25332,6 @@ class TileBufferManager {
25282
25332
);
25283
25333
}
25284
25334
}
25285
- console.log({ column });
25286
25335
if (column.type.typeId !== 3) {
25287
25336
const buffer = new Float32Array(tile.record_batch.numRows);
25288
25337
const source_buffer = column.data[0];
@@ -35640,17 +35689,13 @@ class QuadtileSet extends Dataset {
35640
35689
if (schema.metadata.has("sidecars")) {
35641
35690
const cars = schema.metadata.get("sidecars");
35642
35691
const parsed = JSON.parse(cars);
35643
- for (const [k, v] of Object.entries(
35644
- parsed
35645
- )) {
35692
+ for (const [k, v] of Object.entries(parsed)) {
35646
35693
this.transformations[k] = async function(tile) {
35647
35694
const batch = await tile.get_arrow(v);
35648
35695
const column = batch.getChild(k);
35649
35696
if (column === null) {
35650
35697
throw new Error(
35651
- `No column named ${k} in sidecar tile ${batch.schema.fields.map(
35652
- (f) => f.name
35653
- ).join(", ")}`
35698
+ `No column named ${k} in sidecar tile ${batch.schema.fields.map((f) => f.name).join(", ")}`
35654
35699
);
35655
35700
}
35656
35701
return column;
@@ -36992,11 +37037,22 @@ class Scatterplot {
36992
37037
this.mark_ready = function() {
36993
37038
};
36994
37039
this.bound = false;
37040
+ if (width === void 0) {
37041
+ width = window.innerWidth;
37042
+ height = window.innerHeight;
37043
+ window.onresize = () => {
37044
+ this.resize(window.innerWidth, window.innerHeight);
37045
+ };
37046
+ }
36995
37047
if (selector2 !== void 0) {
36996
37048
this.bind(selector2, width, height);
36997
37049
}
36998
- this.width = width;
36999
- this.height = height;
37050
+ if (width !== void 0) {
37051
+ this._width = width;
37052
+ }
37053
+ if (height !== void 0) {
37054
+ this._height = height;
37055
+ }
37000
37056
this.ready = new Promise((resolve, reject) => {
37001
37057
this.mark_ready = resolve;
37002
37058
});
@@ -37009,17 +37065,52 @@ class Scatterplot {
37009
37065
* @param selector A selector for the root element of the deepscatter; must already exist.
37010
37066
* @param width Width of the plot, in pixels.
37011
37067
* @param height Height of the plot, in pixels.
37012
- */
37068
+ */
37069
+ resize(width, height) {
37070
+ this._width = width;
37071
+ this._height = height;
37072
+ if (this.elements === void 0) {
37073
+ throw "Must bind plot to DOM element before setting dimensions";
37074
+ }
37075
+ for (const el of this.elements) {
37076
+ el.attr("width", this.width).attr("height", this.height);
37077
+ el.selectAll(".deepscatter-render-canvas").attr("width", this.width).attr("height", this.height);
37078
+ }
37079
+ if (this._renderer !== void 0) {
37080
+ this._zoom.resize(this.width, this.height);
37081
+ this._renderer.resize(this.width, this.height);
37082
+ }
37083
+ }
37084
+ get width() {
37085
+ return this._width;
37086
+ }
37087
+ set width(w) {
37088
+ this._width = w;
37089
+ this.resize(w, this.height);
37090
+ }
37091
+ get height() {
37092
+ return this._height;
37093
+ }
37094
+ set height(h) {
37095
+ this._height = h;
37096
+ this.resize(this.width, h);
37097
+ }
37013
37098
bind(selector2, width, height) {
37014
37099
this.div = select(selector2).selectAll("div.deepscatter_container").data([1]).join("div").attr("class", "deepscatter_container").style("position", "absolute");
37015
37100
if (this.div.empty()) {
37016
37101
console.error(selector2);
37017
37102
throw "Must pass a valid div selector";
37018
37103
}
37019
37104
this.elements = [];
37105
+ if (height !== void 0) {
37106
+ this._height = height;
37107
+ }
37108
+ if (width !== void 0) {
37109
+ this._width = width;
37110
+ }
37020
37111
for (const d of base_elements) {
37021
37112
const container = this.div.append("div").attr("id", `container-for-${d.id}`).style("position", "absolute").style("top", 0).style("left", 0).style("pointer-events", d.id === "deepscatter-svg" ? "auto" : "none");
37022
- const el = container.append(d.nodetype).attr("id", d.id).attr("width ", width || window.innerWidth ).attr("height", height || window.innerHeight );
37113
+ const el = container.append(d.nodetype).attr("id", d.id).attr("class ", "deepscatter-render-canvas").attr(" width", this.width ).attr("height", this.height );
37023
37114
if (d.nodetype === "svg") {
37024
37115
el.append("g").attr("id", "mousepoints");
37025
37116
el.append("g").attr("id", "labelrects");
@@ -37141,7 +37232,7 @@ class Scatterplot {
37141
37232
const bkgd = select("#container-for-canvas-2d-background").select("canvas");
37142
37233
const ctx = bkgd.node().getContext("2d");
37143
37234
ctx.fillStyle = prefs.background_color || "rgba(133, 133, 111, .8)";
37144
- ctx.fillRect(0, 0, window.innerWidth * 2, window.innerHeight * 2 );
37235
+ ctx.fillRect(0, 0, this.width, this.height );
37145
37236
this._renderer.initialize();
37146
37237
void this._root.promise.then(() => this.mark_ready());
37147
37238
return this.ready;
@@ -37209,7 +37300,7 @@ class Scatterplot {
37209
37300
}
37210
37301
async make_big_png(xtimes = 3, points = 1e7, timeper = 100) {
37211
37302
await this._root.download_to_depth(points);
37212
- const { width, height } = this._renderer ;
37303
+ const { width, height } = this;
37213
37304
this.plotAPI({ duration: 0 });
37214
37305
const canvas = document.createElement("canvas");
37215
37306
canvas.setAttribute("width", (xtimes * width).toString());
@@ -37242,10 +37333,10 @@ class Scatterplot {
37242
37333
);
37243
37334
const halfHeight = height / 2 | 0;
37244
37335
const bytesPerRow = width * 4;
37245
- var temp = new Uint8Array(width * 4);
37246
- for (var y = 0; y < halfHeight; ++y) {
37247
- var topOffset = y * bytesPerRow;
37248
- var bottomOffset = (height - y - 1) * bytesPerRow;
37336
+ const temp = new Uint8Array(width * 4);
37337
+ for (const y = 0; y < halfHeight; ++y) {
37338
+ const topOffset = y * bytesPerRow;
37339
+ const bottomOffset = (height - y - 1) * bytesPerRow;
37249
37340
temp.set(pixels.subarray(topOffset, topOffset + bytesPerRow));
37250
37341
pixels.copyWithin(
37251
37342
topOffset,
@@ -37551,7 +37642,7 @@ class Scatterplot {
37551
37642
const context2 = canvas.node().getContext("2d");
37552
37643
for (const contour of contours) {
37553
37644
context2.fillStyle = "rgba(25, 25, 29, 1)";
37554
- context2.fillRect(0, 0, window.innerWidth * 2, window.innerHeight * 2 );
37645
+ context2.fillRect(0, 0, this.width, this.height );
37555
37646
context2.strokeStyle = "#8a0303";
37556
37647
context2.fillStyle = "rgba(30, 30, 34, 1)";
37557
37648
context2.lineWidth = max([
0 commit comments