viewof schwelle = Inputs.range([25, 39], {
  value: 30,
  step: 0.5,
  label: "Schwellenwert Hitzetage (°C)"
})
alle_jahre = d3.range(1945, 2027)

// Hitzetage pro Jahr zählen
raw = transpose(hw_data)

hitzetage = alle_jahre.map(j => ({
  Jahr: j,
  Hitzetage: raw.filter(d => d.Jahr === j && d.tlmax >= schwelle).length
}))

Plot.plot({
  marks: [
    Plot.barY(hitzetage, { x: "Jahr", y: "Hitzetage", fill: "firebrick" })
  ],
  x: { tickFormat: "d", label: "Jahr", ticks: [...d3.range(1950, 2026, 10), 2026] },
  y: { label: "Hitzetage" },
  width: 700
})