Skip to content

Commit

Permalink
package bump
Browse files Browse the repository at this point in the history
  • Loading branch information
bmschmidt committed Jan 10, 2024
2 parents fbd7623 + 948d06a commit a68a048
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "deepscatter",
"type": "module",
"version": "2.15.1-RC-1",
"version": "2.15.2",
"description": "Fast, animated zoomable scatterplots scaling to billions of points",
"files": [
"dist"
Expand Down
5 changes: 5 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

# 2.15.1

* Adds a method to `Dataset` called visit_full that returns a promise which iterates over all the tiles in the dataset including those that have not yet loaded. (Their load is triggered.)

# 2.15.0

This would be a bugfix release except that it's possible this might accidentally break code taking advantage of undocumented behavior involving the domain for categorical scales. If you've ever set a scale to have domain [-2047, 2047], the console will now throw a warning and autochange the extent to provide more sensible support for dictionary fields.
Expand Down
46 changes: 46 additions & 0 deletions src/Dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,52 @@ export abstract class Dataset<T extends Tile> {
}
}

/**
* Invoke a function on all tiles in the dataset that have been downloaded.
* The general architecture here is taken from the
* d3 quadtree functions. That's why, for example, it doesn't
* recurse.
* @param callback The function to invoke on each tile.
* @param after Whether to execute the visit in bottom-up order. Default false.
* @param filter
*/

async visit_full(
callback: (tile: T) => Promise<void>,
after = false,
starting_tile : T | null = null,
filter: (t: T) => boolean = (x) => true,
updateFunction: (tile: T, completed, total) => Promise<void>
) {

// Visit all children with a callback function.
// In general recursing quadtrees isn't that fast, but
// we rarely have more than ten tiles deep and the
// code is much cleaner this way than an async queue.

let seen = 0;
const start = starting_tile || this.root_tile;
await start.download();
const total = JSON.parse(start.record_batch.schema.metadata.get("total_points"))

async function resolve(tile: T) {
await tile.download();
if (after) {
await Promise.all(tile.children.map(resolve))
await callback(tile);
seen += tile.record_batch.numRows
void updateFunction(tile, seen, total)
} else {
await callback(tile);
seen += tile.record_batch.numRows
void updateFunction(tile, seen, total)
await Promise.all(tile.children.map(resolve))
}
}
await resolve(start);
}

async schema() {
await this.ready;
if (this._schema) {
Expand Down
2 changes: 1 addition & 1 deletion src/deepscatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ class Scatterplot<T extends Tile> {
}
}
const selection = new DataSelection<T>(this, params);
await selection.ready;
this.selection_history.push({
selection,
name: selection.name,
flushed: false,
});
await selection.ready;
return selection;
}

Expand Down
4 changes: 2 additions & 2 deletions src/tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export abstract class Tile {
return this._children;
}

download() {
download() : Promise<void> {
throw new Error('Not implemented');
}

Expand Down Expand Up @@ -253,7 +253,7 @@ export abstract class Tile {
}

async schema() {
this.download();
await this.download();
await this.promise;
return this._schema;
}
Expand Down
4 changes: 2 additions & 2 deletions vietnam2.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h1>Vietnam</h1>

const prefs = {
source_url: 'https://bmschmidt.github.io/vietnam_war/',
max_points: 100000,
max_points: 1000,
alpha: 10.12, // Target saturation for the full page.
zoom_balance: 0.12, // Rate at which points increase size. https://observablehq.com/@bmschmidt/zoom-strategies-for-huge-scatterplots-with-three-js
point_size: 2, // Default point size before application of size scaling
Expand Down Expand Up @@ -184,7 +184,7 @@ <h1>Vietnam</h1>
scatterplot
.plotAPI({
alpha: 3.5,
max_points: 10000,
max_points: 1000,
point_size: 5,
duration: 0.1,
encoding: {
Expand Down

0 comments on commit a68a048

Please sign in to comment.