Public
Edited
Feb 24, 2023
Insert cell
Insert cell
newgpu = {
// let instance = new Compute();
//const a = new Float32Array(Array.from({length:4},()=>Math.random()))
//const b = new Float32Array(Array.from({length:4},()=>Math.random()))//.reverse()

const input = Array.from({length:2},() =>
Math.random());

let values = {input}

return values
}
Insert cell
Plot.plot({
height: 750,
width:300,
margin:64,

color: {
domain: [ ,,,...order],
scheme: "rdylbu",
invert: true
},
y: {
label: "exports (US$, billions) →",
axis: null ,
//invert: true
// ticks: null,
domain:[180,0]

},
x: {
inset: 16,
ticks: [2019, 2020],
domain:[2019,2020],
axis:"top",
tickFormat: (d) => parseInt(d),
label: null,
invert: true
},
marks: [
Plot.areaY(
exports,
Plot.stackY({
y: "total",
x: "year",
fill: "country",
order,
fillOpacity: 0.7,
stroke: "white"
})
),
Plot.rectY(
exports,
Plot.stackY({
y: "total",
x: "year",
z: "country",
order,
x2: "year",
x1: (d) => +d["year"] + 0.25 * Math.sign(d["year"] - 2019.5),
fill: "country",
stroke: "white",
title: (d) => `${d["total"]} billion US$, ${d["share"]}`
})
),
Plot.text(
exports,
Plot.stackY(
Plot.groupZ(
{ y: "mean", text: "first" },
{
y: "total",
z: "country",
order,
x: 2019.5,
text: "country"
}
)
)
)
]
})
Insert cell
Insert cell
Insert cell
groupLeft = d3.groups(data, d=>d.Functie)
.map(d=>[d[0],orderLeft.get(d[0]),d[1]])
.sort((a,b)=>a[1]-b[1])
.map(d=>({[d[0]]:d[2].length}))
Insert cell
groupRight = d3.groups(data, d=>d.Actor)
.map(d=>[d[0],orderRight.get(d[0])[1],d[1]])
.sort((a,b)=>a[1]-b[1])
.map(d=>({[d[0]]:d[2].length}))
Insert cell
data = {
let parsed = d3.tsvParse(flat)
return parsed.map(d=>({...d,
leftRank: orderLeft.get(d.Functie),
rightRank: orderRight.get(d.Actor)[1],
}))
}
Insert cell
Insert cell
exports = FileAttachment("exports.csv").csv({ typed: true })
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