This is a library for allowing interactive visualization of extremely large datasets, in browser.
It's fast for three reasons:
feather
format, in a
custom quadtree format that makes it possible to only load
data as needed on zoom. Feather takes no time to parse in the browser
once transferred, compresses pretty well, and can be directly copied to the GPU without
transformation in JS. This is the way of the future.
We also now allow custom in-browser calculations on Arrow data.It also runs in completely static settings, so you can host a million-point scatterplot over something like Github Pages.
Deepscatter is the underlying graphics engine for Atlas. It is provided under an NC-CC-BY-SA license for all noncommercial use.
See the autogenerated typescript documentation for a full list of methods and functions.
Github issues, even low quality ones, are welcome here.
There is also a dedicated Deepscatter Slack which you are welcome to join. Nomic maintains a discord server that has dedicated Deepscatter and Atlas support channels.
I came into doing this stuff from a very non-technical background and welcome people to join with naive questions.
See the arxiv example above to see some basic examples.
First, install the companion tiling library, which is written in python, and generate a million points of test data in tiles of 50000 apiece.
python3 -V # requires Python 3.9.x or 3.10.x
python3 -m pip install git+https://github.com/bmschmidt/quadfeather
quadfeather-test-data 1_000_000
quadfeather --files tmp.csv --tile_size 50_000 --destination tiles
Then setup this library to run. It will start a local dev server.
npm i
npm run dev
If you go to localhost:3344
, you should see an interactive scatterplot. To dig into what you're seeing, open index.html
.
(In 2021, this development site works in Chrome, not Safari or Firefox, because it uses ES6 module syntax inside the webworker. The distributed version of
the module should work in all browsers.)
Create a CSV, parquet, or feather file that has columns called 'x' and 'y'. (Or a feather file that has columns x
, y
). Any other columns (categorical information, etc.) can be included as additional columns.
Tile it:
cd deepscatter # if you're not already there
quadfeather --files ../some-path-to/your-data.csv --tile_size 50000 --destination tiles
x
and y
column and the tiles
folder is in the root directory of this project, you can see the data visualized by runningnpm run dev
and opening http://localhost:3345/index-simplest-way-to-start.html
in your browser.
To edit the visualization, or to troubleshoot, look at the file index-simplest-way-to-start.html
, where you should find a bare-bones implementation of deepscatter.
Explore index.html
, and render it at http://localhost:3345/index.html
, for a more advanced example.
Note: Ideally, in a future release you'll be able to create these specs in away that doesn't require coding JSON directly.
npm run build
will create an ES module at dist/deepscatter.es.js
The mechanics of
importing this are very slightly different than index.html
.
Note that this is an ESM module and so requires you to use <script type="module">
in your code.
Don't worry! We're allowed to
do this now! But do be aware that this will not work on computers running very old browsers.
Snippet:
<div id="my-div"></div>
<script type="module">
import Scatterplot from './dist/deepscatter.umd.js';
f = new Scatterplot('#my-div');
</script>
See index_prod.html
for an example
This is currently bundled with vite and rollup. There is/will be a further interaction layer on top of it, but the core plotting components are separate and should work as a standalone layer that supports plot requests via an API.
Any interaction logic that changes the API call directly does not belong in this library. The only interaction code here is for zooming and interacting with points.
The plotting components and the tiling components are logically quite separate; I may break the tiling strategy into a separate JS library called 'quadfeather'.
Apache Arrow would still be a necessary intermediate format, but it could be generated from CSV files
using, say, arquero
or a WASM port of DuckDB
.
This is still subject to change and is not fully documented. The encoding portion of the API mimics Vega-Lite with some minor distinctions to avoid deeply-nested queries and to add animation and jitter parameters.
{
encoding: {
"x": {
"field": "x",
"transform": "literal"
},
"color": {
"field": "year",
"range": "viridis",
"domain": [1970, 2020]
}
}
x0
(for animations; transitions between x0 and x)y0
(for animations; transitions between y0 and y)filter
. (Filtering is treated as an aesthetic operation by this library.)Jitter is a little overloaded with features right now, but some are quite fun.
jitter method is set on 'method' key of the 'jitter_radius' field. Possible values are:
circle
spiral
time
normal
on_zoom
is directly set, not passed in via prefs
):const scatterplot = new Scatterplot('#deepscatter');
scatterplot.on_zoom = (transform) => {...}
Generated using TypeDoc