🏠 back to Observable

selected swatches

Hello,

I am working on a large dataset of Hindi Film Songs (Bollywood and pre-Bollywood, link below). When I am creating graphs of the dominant lyricists and composers, I would like to show swatches of just the top people. How do I do that? On a related note, how do I create limited lists including only top counts (10 or 25) of songs for a singer/composer/lyricist?

Thanks in adavence,
Rini

https://observablehq.com/@rbhttchr/hindifilmsongs_basic

hi @rbhttchr on the bar chart what defines the top people? the Count attribute? if that’s the case you can use filter on your mark Plot.barY

filter: d => d.Count > 90,

1 Like

Hi @radames, where and how do I insert the filter? I tried defining ‘lyrswatch’, but obviously I am not doing it the right way.

here is where I’d add the filter

Plot.barY(lyricists, {
  x: "Decade",
  y: "Count",
  rx: 1,
  filter: d => d.Count > 90,
  title: (d) => `${d.Lyricist} : ${d.Count} songs in the ${d.Decade}`,
  fill: (d) => d.Lyricist
}),

Thanks so much! My query is actually a bit more complicated. I want to show all lyricists in the bargraph, but provide swatches for only the filtered ones (for count>90 or whatever). Can that be done?

sorry I see it now! just checked and you just switched the order of map and filter. Here is how your lyrswatch will work now.

lyrswatch = lyricists.filter((v) => v.Count > 90).map((d) => d.Lyricist)