Public
Edited
Apr 13, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dt.view()
Insert cell
import { createClient } from "@silentworks/supabase";
Insert cell
import { aq, op } from '@uwdata/arquero'
Insert cell
import { BarChart } from "@d3/horizontal-bar-chart"
Insert cell
supabase = createClient(
"https://itvifawsdgiynkldcfnv.supabase.co",
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Iml0dmlmYXdzZGdpeW5rbGRjZm52Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2NjU0MDMyNzcsImV4cCI6MTk4MDk3OTI3N30.YvPD_C5yy5ELMJw-jt28uMTfwOoY7WPDeBOUy4JL0_0"
);
Insert cell
async function getData() {
let { data, error } = await supabase
.from("main")
.select("show_date, description, venue")
.eq("validated", "true")
.order("show_date");
return data;
}
Insert cell
data = getData();
Insert cell
dt = aq.from(data)
.groupby('venue')
.rollup({shows: op.count('venue')})
.orderby(aq.desc('shows'))
.fold()
Insert cell
//1) combine the arrays:
phillymetal = {
let aggregateData = {venue: dt._data.venue.data, shows: dt._data.shows.data}
let list = [];
for (var j = 0; j < aggregateData.shows.length; j++)
list.push({ count: aggregateData.shows[j], venue: aggregateData.venue[j] });

return list.sort(function (a, b) {
return a.count < b.count ? 1 : a.count == b.count ? 0 : -1;
});
}
Insert cell
winners = {
let maxShows = Math.max(...phillymetal.map(e => e.count));
let obj = phillymetal.filter(el => el.count === maxShows);
return obj
}

Insert cell
message = {
let venues = winners.map(el => el.venue);
let maxShowsValue = winners[0].count;
let venuePlurality = venues.length > 1 ? 'venues' : 'venue';
let venueNames = venues.length > 1 ? venues.join(" and ") : venues;
let message = `Congratulations to ${venueNames} for being the heaviest ${venuePlurality} in Philadelphia: ${maxShowsValue} shows since 04/12/2022.`
return message
}
Insert cell
insert = {
let el = document.querySelector(".message")
el.innerHTML += message;
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more