Unlisted
Edited
Feb 22, 2024
Insert cell
Insert cell
Plot.plot({
//style: "background-color:green",
height: 800,
width: 1000,
marginBottom: 50,
marginTop: 50,
marginRight: 50,
x: {
tickFormat: formatYear,
tickRotate: 45
},
y: {
grid: true
},

marks: [
Plot.rectY(
lata,
Plot.binX(
{
y: "count",
title: "first",
title: (bin) => bin.map((d) => d.Song)
},
{ rx: 8, x: "Year", fill: "Song" }
)
),
Plot.ruleY([0, 1])
]
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Inputs.table(search, {
format: {
Year: (d) => `${d}`
}
})
Insert cell
Insert cell
viewof Lyricists = Inputs.select(
LyricistCounts.map((d) => d[0]),
{
label: "Lyricist",
multiple: true,
value: "Anand Bakshi"
// format: (x) => x.Lyricist,
// value: lata.find((t) => t.Lyricist === "Anand Bakshi")
}
)
Insert cell
viewof MusicDirector = Inputs.select(
["All"].concat(MusicDirectors.map((d) => d[0])),
{
label: "Music Director",
unique: true
// format: (x) => x.MusicDirector
}
)
Insert cell
MusicDirectors = d3
.rollups(
lata,
(v) => v.length,
(d) => d.MusicDirector
)
.sort((a, b) => b[1] - a[1])
Insert cell
LyricistCounts = d3
.rollups(
lata,
(v) => v.length,
(d) => d.Lyricist
)
.sort((a, b) => b[1] - a[1])
Insert cell
lata
Insert cell
Lyricists
Insert cell
filtered = lata.filter((d) => {
let md = MusicDirector == "All" ? true : d.MusicDirector == MusicDirector;
let l = Lyricists.length ? Lyricists.indexOf(d.Lyricist) >= 0 : true;
return md && l;
})
Insert cell
Insert cell
films = lata.map((d) => d.Film)
Insert cell
years = lata.map((d) => d.Year)
Insert cell
lyricists = lata.map((d) => d.Lyricist)
Insert cell
musicdirectors = lata.map((d) => d.MusicDirector)
Insert cell
https://observablehq.com/@observablehq/plot-stack
Insert cell
d3 = require("d3@6")
Insert cell
color = d3.scaleOrdinal(d3.schemeTableau10)
Insert cell
import {swatches} from "@d3/color-legend"
Insert cell
import { importCell } from "@mbostock/dataflow"
Insert cell
import { Range, Select, Table, Checkbox } from "@observablehq/inputs"
Insert cell
import { html, svg } from "@observablehq/htl"
Insert cell
import { palettes } from "@tomshanley/cheysson-color-palettes"
Insert cell
import { pbcopy } from "@mbostock/pbcopy"
Insert cell
formatYear = (year) => `${year}`
Insert cell
fmt = (n) => d3.format(",d")(n)
Insert cell
html`<style>svg { font-size: 14px !important }`
Insert cell
(d3.scaleBivariate = function () {
function scaleBivariate(value) {
var r = reds(value[0]);
var b = blues(value[1]);

return "rgb(" + r + "," + (r + b) / 2 + "," + b + ")";
}

var blues = d3
.scaleThreshold()
.range([255, 205, 155, 105, 55])
.domain([0, 1, 2, 3, 4, 5]);

var reds = d3
.scaleThreshold()
.range([255, 205, 155, 105, 55])
.domain([0, 1, 2, 3, 4, 5]);

return scaleBivariate;
})
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