Published
Edited
Sep 15, 2020
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function image_url_to_blob(img_url) {
return png2blob(img_url).then(blob2buffer);
}
Insert cell
function blob_to_sqlite(buf) {
return new SQLiteDatabaseClient(new Uint8Array(buf));
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof db = {
var dom = html`<div>💿`;
dom.value = null;
var curr = await localforage.getItem(local_forage_key);
if (curr == null || !curr.constructor == ArrayBuffer) {
var download = await image_url_to_blob(url);
localforage.setItem(local_forage_key, download);

dom.value = blob_to_sqlite(download);
dom.dispatchEvent(new CustomEvent("input"));
} else {
dom.value = blob_to_sqlite(curr);
dom.dispatchEvent(new CustomEvent("input"));
}
return dom;
}
Insert cell
db
Insert cell
Insert cell
Insert cell
db.describe()
Insert cell
Insert cell
// preventing intermediate queries from being generated while using the slider...
debounce_range = debounce(viewof range, 200)
Insert cell
Insert cell
sample = db.query(
`SELECT
*
FROM
(SELECT
DISTINCT(EnglishProductName) AS product, Color,sum(SalesAmount) AS total
FROM
FactInternetSales
INNER JOIN
DimProduct ON FactInternetSales.ProductKey = DimProduct.ProductKey
GROUP BY
EnglishProductName)
WHERE
total BETWEEN ${debounce_range[0]} AND ${debounce_range[1]}
`
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more