blockcharts alpha

Gallery / Parts of a whole /

Streamgraph

How several parts of a whole rise and fall over time, the shape more than the numbers (streamgraph).

82.9 KB of code · core 32.5 + 13 blocks 50.4

Listening hours by genre, millions per month

Pop and hip-hop grew over the two years; rock lost the most, from 36 to 28 million hours a month.

How it is made: transform.stack with center: true puts the middle of every month on 0, so the layers flow around a center line. Only the thickness of a layer means something, so there is no y axis; the tooltip gives the numbers. Draw it with mark.area (y = end, y2 = start), curve smooth.

What the report is made of

The composer reads the JSON below and puts into the page the core and only the blocks its chart uses: 13 of the 59, 82.9 KB of code, minified, which is 38% of the 215.9 KB that the core and every block weigh together. The report file is 90.0 KB: that code, the data, the styles and the page around them.

BlockWhat it doesShare of the codeKB
core.composed
A report with compressed data: the composer has run the checks already.
A report with compressed data: the composer has run the checks already. 32.5
lib.curve
The path of a line: straight segments, a smooth curve that never overshoots, or steps. Shared by line and area.
The path of a line: straight segments, a smooth curve that never overshoots, or steps. Shared by line and area. 1.2
lib.pointer
Where the pointer is on the chart, and following a mouse or a finger once a frame. Shared by tooltip, crosshair, zoom and brush.
Where the pointer is on the chart, and following a mouse or a finger once a frame. Shared by tooltip, crosshair, zoom and brush. 1.7
lib.ticks
Round steps and ticks (1, 2 or 5 × 10ⁿ). Shared by the number scales and the histogram bins.
Round steps and ticks (1, 2 or 5 × 10ⁿ). Shared by the number scales and the histogram bins. 0.7
scale.color
A color per category, from the theme palette.
A color per category, from the theme palette. 0.8
scale.linear
Numbers to positions, with round ticks.
Numbers to positions, with round ticks. 1.6
scale.time
Dates to positions, ticks in days, months or years (UTC).
Dates to positions, ticks in days, months or years (UTC). 4.1
transform.stack
Stacks series on top of each other, to 100%, or around a center line (a streamgraph).
Stacks series on top of each other, to 100%, or around a center line (a streamgraph). 2.2
mark.area
Filled areas, stacked or not.
Filled areas, stacked or not. 2.9
guide.axis
Axes: formatted labels, a title, long categories wrapped.
Axes: formatted labels, a title, long categories wrapped. 11.7
guide.legend
Legends: categories, a color bar, bubble sizes.
Legends: categories, a color bar, bubble sizes. 6.0
interaction.legend-filter
Click a legend item to hide or show its series.
Click a legend item to hide or show its series. 3.0
interaction.tooltip
The values under the pointer.
The values under the pointer. 10.7
renderer.svg
Draws into SVG: sharp, selectable, prints well. The default.
Draws into SVG: sharp, selectable, prints well. The default. 3.9
TotalThe core 32.5 and 13 blocks 50.482.9

The JSON

This is the whole input. data holds the datasets, each chart is a spec that names one. In a checkout of the repository: node scripts/compose.js skills/blockcharts/recipes/streamgraph.json report.html. Saved as page.json, it composes the same with the skill's own runtime/compose.js.

streamgraph.json

{
  "title": "Streamgraph",
  "data": {
    "listening": [
      {
        "month": "2024-01-01",
        "genre": "Pop",
        "hours": 40.0
      },
      {
        "month": "2024-01-01",
        "genre": "Rock",
        "hours": 35.9
      },
      {
        "month": "2024-01-01",
        "genre": "Hip-hop",
        "hours": 29.3
      },
      {
        "month": "2024-01-01",
        "genre": "Electronic",
        "hours": 15.6
      },
      {
        "month": "2024-01-01",
        "genre": "Jazz",
        "hours": 6.4
      },
      {
        "month": "2024-02-01",
        "genre": "Pop",
        "hours": 44.3
      },
      {
        "month": "2024-02-01",
        "genre": "Rock",
        "hours": 36.9
      },
      {
        "month": "2024-02-01",
        "genre": "Hip-hop",
        "hours": 28.7
      },
      {
        "month": "2024-02-01",
        "genre": "Electronic",
        "hours": 14.1
      },
      {
        "month": "2024-02-01",
        "genre": "Jazz",
        "hours": 5.8
      },
      {
        "month": "2024-03-01",
        "genre": "Pop",
        "hours": 48.2
      },
      {
        "month": "2024-03-01",
        "genre": "Rock",
        "hours": 37.0
      },
      {
        "month": "2024-03-01",
        "genre": "Hip-hop",
        "hours": 27.5
      },
      {
        "month": "2024-03-01",
        "genre": "Electronic",
        "hours": 12.6
      },
      {
        "month": "2024-03-01",
        "genre": "Jazz",
        "hours": 5.4
      },
      {
        "month": "2024-04-01",
        "genre": "Pop",
        "hours": 51.3
      },
      {
        "month": "2024-04-01",
        "genre": "Rock",
        "hours": 36.1
      },
      {
        "month": "2024-04-01",
        "genre": "Hip-hop",
        "hours": 25.8
      },
      {
        "month": "2024-04-01",
        "genre": "Electronic",
        "hours": 11.2
      },
      {
        "month": "2024-04-01",
        "genre": "Jazz",
        "hours": 5.2
      },
      {
        "month": "2024-05-01",
        "genre": "Pop",
        "hours": 53.3
      },
      {
        "month": "2024-05-01",
        "genre": "Rock",
        "hours": 34.3
      },
      {
        "month": "2024-05-01",
        "genre": "Hip-hop",
        "hours": 23.9
      },
      {
        "month": "2024-05-01",
        "genre": "Electronic",
        "hours": 10.1
      },
      {
        "month": "2024-05-01",
        "genre": "Jazz",
        "hours": 5.3
      },
      {
        "month": "2024-06-01",
        "genre": "Pop",
        "hours": 54.0
      },
      {
        "month": "2024-06-01",
        "genre": "Rock",
        "hours": 31.8
      },
      {
        "month": "2024-06-01",
        "genre": "Hip-hop",
        "hours": 22.0
      },
      {
        "month": "2024-06-01",
        "genre": "Electronic",
        "hours": 9.4
      },
      {
        "month": "2024-06-01",
        "genre": "Jazz",
        "hours": 5.7
      },
      {
        "month": "2024-07-01",
        "genre": "Pop",
        "hours": 53.4
      },
      {
        "month": "2024-07-01",
        "genre": "Rock",
        "hours": 28.6
      },
      {
        "month": "2024-07-01",
        "genre": "Hip-hop",
        "hours": 20.2
      },
      {
        "month": "2024-07-01",
        "genre": "Electronic",
        "hours": 9.1
      },
      {
        "month": "2024-07-01",
        "genre": "Jazz",
        "hours": 6.3
      },
      {
        "month": "2024-08-01",
        "genre": "Pop",
        "hours": 51.4
      },
      {
        "month": "2024-08-01",
        "genre": "Rock",
        "hours": 25.2
      },
      {
        "month": "2024-08-01",
        "genre": "Hip-hop",
        "hours": 18.9
      },
      {
        "month": "2024-08-01",
        "genre": "Electronic",
        "hours": 9.3
      },
      {
        "month": "2024-08-01",
        "genre": "Jazz",
        "hours": 7.1
      },
      {
        "month": "2024-09-01",
        "genre": "Pop",
        "hours": 48.4
      },
      {
        "month": "2024-09-01",
        "genre": "Rock",
        "hours": 21.8
      },
      {
        "month": "2024-09-01",
        "genre": "Hip-hop",
        "hours": 18.3
      },
      {
        "month": "2024-09-01",
        "genre": "Electronic",
        "hours": 10.0
      },
      {
        "month": "2024-09-01",
        "genre": "Jazz",
        "hours": 7.9
      },
      {
        "month": "2024-10-01",
        "genre": "Pop",
        "hours": 44.5
      },
      {
        "month": "2024-10-01",
        "genre": "Rock",
        "hours": 18.6
      },
      {
        "month": "2024-10-01",
        "genre": "Hip-hop",
        "hours": 18.3
      },
      {
        "month": "2024-10-01",
        "genre": "Electronic",
        "hours": 11.0
      },
      {
        "month": "2024-10-01",
        "genre": "Jazz",
        "hours": 8.8
      },
      {
        "month": "2024-11-01",
        "genre": "Pop",
        "hours": 40.2
      },
      {
        "month": "2024-11-01",
        "genre": "Rock",
        "hours": 16.0
      },
      {
        "month": "2024-11-01",
        "genre": "Hip-hop",
        "hours": 19.0
      },
      {
        "month": "2024-11-01",
        "genre": "Electronic",
        "hours": 12.3
      },
      {
        "month": "2024-11-01",
        "genre": "Jazz",
        "hours": 9.6
      },
      {
        "month": "2024-12-01",
        "genre": "Pop",
        "hours": 35.9
      },
      {
        "month": "2024-12-01",
        "genre": "Rock",
        "hours": 14.1
      },
      {
        "month": "2024-12-01",
        "genre": "Hip-hop",
        "hours": 20.5
      },
      {
        "month": "2024-12-01",
        "genre": "Electronic",
        "hours": 13.8
      },
      {
        "month": "2024-12-01",
        "genre": "Jazz",
        "hours": 10.2
      },
      {
        "month": "2025-01-01",
        "genre": "Pop",
        "hours": 32.0
      },
      {
        "month": "2025-01-01",
        "genre": "Rock",
        "hours": 13.2
      },
      {
        "month": "2025-01-01",
        "genre": "Hip-hop",
        "hours": 22.6
      },
      {
        "month": "2025-01-01",
        "genre": "Electronic",
        "hours": 15.4
      },
      {
        "month": "2025-01-01",
        "genre": "Jazz",
        "hours": 10.6
      },
      {
        "month": "2025-02-01",
        "genre": "Pop",
        "hours": 28.9
      },
      {
        "month": "2025-02-01",
        "genre": "Rock",
        "hours": 13.1
      },
      {
        "month": "2025-02-01",
        "genre": "Hip-hop",
        "hours": 25.1
      },
      {
        "month": "2025-02-01",
        "genre": "Electronic",
        "hours": 16.7
      },
      {
        "month": "2025-02-01",
        "genre": "Jazz",
        "hours": 10.8
      },
      {
        "month": "2025-03-01",
        "genre": "Pop",
        "hours": 26.8
      },
      {
        "month": "2025-03-01",
        "genre": "Rock",
        "hours": 14.0
      },
      {
        "month": "2025-03-01",
        "genre": "Hip-hop",
        "hours": 27.9
      },
      {
        "month": "2025-03-01",
        "genre": "Electronic",
        "hours": 17.9
      },
      {
        "month": "2025-03-01",
        "genre": "Jazz",
        "hours": 10.7
      },
      {
        "month": "2025-04-01",
        "genre": "Pop",
        "hours": 26.0
      },
      {
        "month": "2025-04-01",
        "genre": "Rock",
        "hours": 15.7
      },
      {
        "month": "2025-04-01",
        "genre": "Hip-hop",
        "hours": 30.7
      },
      {
        "month": "2025-04-01",
        "genre": "Electronic",
        "hours": 18.6
      },
      {
        "month": "2025-04-01",
        "genre": "Jazz",
        "hours": 10.3
      },
      {
        "month": "2025-05-01",
        "genre": "Pop",
        "hours": 26.6
      },
      {
        "month": "2025-05-01",
        "genre": "Rock",
        "hours": 18.0
      },
      {
        "month": "2025-05-01",
        "genre": "Hip-hop",
        "hours": 33.3
      },
      {
        "month": "2025-05-01",
        "genre": "Electronic",
        "hours": 18.9
      },
      {
        "month": "2025-05-01",
        "genre": "Jazz",
        "hours": 9.7
      },
      {
        "month": "2025-06-01",
        "genre": "Pop",
        "hours": 28.4
      },
      {
        "month": "2025-06-01",
        "genre": "Rock",
        "hours": 20.5
      },
      {
        "month": "2025-06-01",
        "genre": "Hip-hop",
        "hours": 35.5
      },
      {
        "month": "2025-06-01",
        "genre": "Electronic",
        "hours": 18.7
      },
      {
        "month": "2025-06-01",
        "genre": "Jazz",
        "hours": 9.0
      },
      {
        "month": "2025-07-01",
        "genre": "Pop",
        "hours": 31.4
      },
      {
        "month": "2025-07-01",
        "genre": "Rock",
        "hours": 23.1
      },
      {
        "month": "2025-07-01",
        "genre": "Hip-hop",
        "hours": 37.1
      },
      {
        "month": "2025-07-01",
        "genre": "Electronic",
        "hours": 18.1
      },
      {
        "month": "2025-07-01",
        "genre": "Jazz",
        "hours": 8.1
      },
      {
        "month": "2025-08-01",
        "genre": "Pop",
        "hours": 35.3
      },
      {
        "month": "2025-08-01",
        "genre": "Rock",
        "hours": 25.5
      },
      {
        "month": "2025-08-01",
        "genre": "Hip-hop",
        "hours": 38.1
      },
      {
        "month": "2025-08-01",
        "genre": "Electronic",
        "hours": 17.1
      },
      {
        "month": "2025-08-01",
        "genre": "Jazz",
        "hours": 7.3
      },
      {
        "month": "2025-09-01",
        "genre": "Pop",
        "hours": 39.5
      },
      {
        "month": "2025-09-01",
        "genre": "Rock",
        "hours": 27.3
      },
      {
        "month": "2025-09-01",
        "genre": "Hip-hop",
        "hours": 38.2
      },
      {
        "month": "2025-09-01",
        "genre": "Electronic",
        "hours": 15.7
      },
      {
        "month": "2025-09-01",
        "genre": "Jazz",
        "hours": 6.5
      },
      {
        "month": "2025-10-01",
        "genre": "Pop",
        "hours": 43.9
      },
      {
        "month": "2025-10-01",
        "genre": "Rock",
        "hours": 28.4
      },
      {
        "month": "2025-10-01",
        "genre": "Hip-hop",
        "hours": 37.7
      },
      {
        "month": "2025-10-01",
        "genre": "Electronic",
        "hours": 14.2
      },
      {
        "month": "2025-10-01",
        "genre": "Jazz",
        "hours": 5.8
      },
      {
        "month": "2025-11-01",
        "genre": "Pop",
        "hours": 47.8
      },
      {
        "month": "2025-11-01",
        "genre": "Rock",
        "hours": 28.6
      },
      {
        "month": "2025-11-01",
        "genre": "Hip-hop",
        "hours": 36.5
      },
      {
        "month": "2025-11-01",
        "genre": "Electronic",
        "hours": 12.7
      },
      {
        "month": "2025-11-01",
        "genre": "Jazz",
        "hours": 5.4
      },
      {
        "month": "2025-12-01",
        "genre": "Pop",
        "hours": 51.0
      },
      {
        "month": "2025-12-01",
        "genre": "Rock",
        "hours": 27.8
      },
      {
        "month": "2025-12-01",
        "genre": "Hip-hop",
        "hours": 34.8
      },
      {
        "month": "2025-12-01",
        "genre": "Electronic",
        "hours": 11.3
      },
      {
        "month": "2025-12-01",
        "genre": "Jazz",
        "hours": 5.2
      }
    ]
  },
  "charts": [
    {
      "title": "Listening hours by genre, millions per month",
      "note": "Pop and hip-hop grew over the two years; rock lost the most, from 36 to 28 million hours a month.",
      "how": "transform.stack with center: true puts the middle of every month on 0, so the layers flow around a center line. Only the thickness of a layer means something, so there is no y axis; the tooltip gives the numbers. Draw it with mark.area (y = end, y2 = start), curve smooth.",
      "spec": {
        "data": "listening",
        "size": [
          720,
          340
        ],
        "transforms": [
          {
            "type": "stack",
            "field": "hours",
            "by": "month",
            "group": "genre",
            "center": true,
          "follows": "color"
          }
        ],
        "scales": {
          "x": {
            "type": "time"
          },
          "y": {
            "type": "linear"
          },
          "color": {
            "type": "color"
          }
        },
        "guides": [
          {
            "type": "axis",
            "scale": "x",
            "format": {
              "month": "short",
              "year": "2-digit"
            }
          },
          {
            "type": "legend",
            "scale": "color",
            "position": "auto"
          }
        ],
        "marks": [
          {
            "type": "area",
            "x": "month",
            "y": "hours1",
            "y2": "hours0",
            "color": "genre",
            "curve": "smooth",
            "opacity": 0.9
          }
        ],
        "interaction": [
          {
            "type": "tooltip",
            "fields": [
              "genre",
              "hours"
            ],
            "formats": {
              "month": {
                "month": "long",
                "year": "numeric"
              }
            }
          },
          {
            "type": "legend-filter"
          }
        ]
      }
    }
  ]
}

The report the composer makes from it is one standalone file (90.0 KB): open it from disk, mail it, print it.

In a page of your own

The charts above use the timeseries kit (52.1 KB gzipped), the smallest one that has the blocks this example needs: lib.curve, lib.pointer, lib.ticks, scale.color, scale.linear, scale.time, transform.stack, mark.area, guide.axis, guide.legend, interaction.legend-filter, interaction.tooltip, renderer.svg. The HTML below loads it from the jsDelivr CDN, pinned to version 0.0.5; to serve it from your own site, put its file there (the files of a release) and change the address.

HTML

<script src="https://cdn.jsdelivr.net/npm/blockcharts@0.0.5/release/kits/timeseries.js"></script>

<script type="application/json" id="bc-data">
{"listening":[{"month":"2024-01-01","genre":"Pop","hours":40},{"month":"2024-01-01","genre":"Rock","hours":35.9},{"month":"2024-01-01","genre":"Hip-hop","hours":29.3},{"month":"2024-01-01","genre":"Electronic","hours":15.6},{"month":"2024-01-01","genre":"Jazz","hours":6.4},{"month":"2024-02-01","genre":"Pop","hours":44.3},{"month":"2024-02-01","genre":"Rock","hours":36.9},{"month":"2024-02-01","genre":"Hip-hop","hours":28.7},{"month":"2024-02-01","genre":"Electronic","hours":14.1},{"month":"2024-02-01","genre":"Jazz","hours":5.8},{"month":"2024-03-01","genre":"Pop","hours":48.2},{"month":"2024-03-01","genre":"Rock","hours":37},{"month":"2024-03-01","genre":"Hip-hop","hours":27.5},{"month":"2024-03-01","genre":"Electronic","hours":12.6},{"month":"2024-03-01","genre":"Jazz","hours":5.4},{"month":"2024-04-01","genre":"Pop","hours":51.3},{"month":"2024-04-01","genre":"Rock","hours":36.1},{"month":"2024-04-01","genre":"Hip-hop","hours":25.8},{"month":"2024-04-01","genre":"Electronic","hours":11.2},{"month":"2024-04-01","genre":"Jazz","hours":5.2},{"month":"2024-05-01","genre":"Pop","hours":53.3},{"month":"2024-05-01","genre":"Rock","hours":34.3},{"month":"2024-05-01","genre":"Hip-hop","hours":23.9},{"month":"2024-05-01","genre":"Electronic","hours":10.1},{"month":"2024-05-01","genre":"Jazz","hours":5.3},{"month":"2024-06-01","genre":"Pop","hours":54},{"month":"2024-06-01","genre":"Rock","hours":31.8},{"month":"2024-06-01","genre":"Hip-hop","hours":22},{"month":"2024-06-01","genre":"Electronic","hours":9.4},{"month":"2024-06-01","genre":"Jazz","hours":5.7},{"month":"2024-07-01","genre":"Pop","hours":53.4},{"month":"2024-07-01","genre":"Rock","hours":28.6},{"month":"2024-07-01","genre":"Hip-hop","hours":20.2},{"month":"2024-07-01","genre":"Electronic","hours":9.1},{"month":"2024-07-01","genre":"Jazz","hours":6.3},{"month":"2024-08-01","genre":"Pop","hours":51.4},{"month":"2024-08-01","genre":"Rock","hours":25.2},{"month":"2024-08-01","genre":"Hip-hop","hours":18.9},{"month":"2024-08-01","genre":"Electronic","hours":9.3},{"month":"2024-08-01","genre":"Jazz","hours":7.1},{"month":"2024-09-01","genre":"Pop","hours":48.4},{"month":"2024-09-01","genre":"Rock","hours":21.8},{"month":"2024-09-01","genre":"Hip-hop","hours":18.3},{"month":"2024-09-01","genre":"Electronic","hours":10},{"month":"2024-09-01","genre":"Jazz","hours":7.9},{"month":"2024-10-01","genre":"Pop","hours":44.5},{"month":"2024-10-01","genre":"Rock","hours":18.6},{"month":"2024-10-01","genre":"Hip-hop","hours":18.3},{"month":"2024-10-01","genre":"Electronic","hours":11},{"month":"2024-10-01","genre":"Jazz","hours":8.8},{"month":"2024-11-01","genre":"Pop","hours":40.2},{"month":"2024-11-01","genre":"Rock","hours":16},{"month":"2024-11-01","genre":"Hip-hop","hours":19},{"month":"2024-11-01","genre":"Electronic","hours":12.3},{"month":"2024-11-01","genre":"Jazz","hours":9.6},{"month":"2024-12-01","genre":"Pop","hours":35.9},{"month":"2024-12-01","genre":"Rock","hours":14.1},{"month":"2024-12-01","genre":"Hip-hop","hours":20.5},{"month":"2024-12-01","genre":"Electronic","hours":13.8},{"month":"2024-12-01","genre":"Jazz","hours":10.2},{"month":"2025-01-01","genre":"Pop","hours":32},{"month":"2025-01-01","genre":"Rock","hours":13.2},{"month":"2025-01-01","genre":"Hip-hop","hours":22.6},{"month":"2025-01-01","genre":"Electronic","hours":15.4},{"month":"2025-01-01","genre":"Jazz","hours":10.6},{"month":"2025-02-01","genre":"Pop","hours":28.9},{"month":"2025-02-01","genre":"Rock","hours":13.1},{"month":"2025-02-01","genre":"Hip-hop","hours":25.1},{"month":"2025-02-01","genre":"Electronic","hours":16.7},{"month":"2025-02-01","genre":"Jazz","hours":10.8},{"month":"2025-03-01","genre":"Pop","hours":26.8},{"month":"2025-03-01","genre":"Rock","hours":14},{"month":"2025-03-01","genre":"Hip-hop","hours":27.9},{"month":"2025-03-01","genre":"Electronic","hours":17.9},{"month":"2025-03-01","genre":"Jazz","hours":10.7},{"month":"2025-04-01","genre":"Pop","hours":26},{"month":"2025-04-01","genre":"Rock","hours":15.7},{"month":"2025-04-01","genre":"Hip-hop","hours":30.7},{"month":"2025-04-01","genre":"Electronic","hours":18.6},{"month":"2025-04-01","genre":"Jazz","hours":10.3},{"month":"2025-05-01","genre":"Pop","hours":26.6},{"month":"2025-05-01","genre":"Rock","hours":18},{"month":"2025-05-01","genre":"Hip-hop","hours":33.3},{"month":"2025-05-01","genre":"Electronic","hours":18.9},{"month":"2025-05-01","genre":"Jazz","hours":9.7},{"month":"2025-06-01","genre":"Pop","hours":28.4},{"month":"2025-06-01","genre":"Rock","hours":20.5},{"month":"2025-06-01","genre":"Hip-hop","hours":35.5},{"month":"2025-06-01","genre":"Electronic","hours":18.7},{"month":"2025-06-01","genre":"Jazz","hours":9},{"month":"2025-07-01","genre":"Pop","hours":31.4},{"month":"2025-07-01","genre":"Rock","hours":23.1},{"month":"2025-07-01","genre":"Hip-hop","hours":37.1},{"month":"2025-07-01","genre":"Electronic","hours":18.1},{"month":"2025-07-01","genre":"Jazz","hours":8.1},{"month":"2025-08-01","genre":"Pop","hours":35.3},{"month":"2025-08-01","genre":"Rock","hours":25.5},{"month":"2025-08-01","genre":"Hip-hop","hours":38.1},{"month":"2025-08-01","genre":"Electronic","hours":17.1},{"month":"2025-08-01","genre":"Jazz","hours":7.3},{"month":"2025-09-01","genre":"Pop","hours":39.5},{"month":"2025-09-01","genre":"Rock","hours":27.3},{"month":"2025-09-01","genre":"Hip-hop","hours":38.2},{"month":"2025-09-01","genre":"Electronic","hours":15.7},{"month":"2025-09-01","genre":"Jazz","hours":6.5},{"month":"2025-10-01","genre":"Pop","hours":43.9},{"month":"2025-10-01","genre":"Rock","hours":28.4},{"month":"2025-10-01","genre":"Hip-hop","hours":37.7},{"month":"2025-10-01","genre":"Electronic","hours":14.2},{"month":"2025-10-01","genre":"Jazz","hours":5.8},{"month":"2025-11-01","genre":"Pop","hours":47.8},{"month":"2025-11-01","genre":"Rock","hours":28.6},{"month":"2025-11-01","genre":"Hip-hop","hours":36.5},{"month":"2025-11-01","genre":"Electronic","hours":12.7},{"month":"2025-11-01","genre":"Jazz","hours":5.4},{"month":"2025-12-01","genre":"Pop","hours":51},{"month":"2025-12-01","genre":"Rock","hours":27.8},{"month":"2025-12-01","genre":"Hip-hop","hours":34.8},{"month":"2025-12-01","genre":"Electronic","hours":11.3},{"month":"2025-12-01","genre":"Jazz","hours":5.2}]}
</script>

<script type="application/json" data-bc-chart>
{
  "data": "listening",
  "size": [
    720,
    340
  ],
  "transforms": [
    {
      "type": "stack",
      "field": "hours",
      "by": "month",
      "group": "genre",
      "center": true,
      "follows": "color"
    }
  ],
  "scales": {
    "x": {
      "type": "time"
    },
    "y": {
      "type": "linear"
    },
    "color": {
      "type": "color"
    }
  },
  "guides": [
    {
      "type": "axis",
      "scale": "x",
      "format": {
        "month": "short",
        "year": "2-digit"
      }
    },
    {
      "type": "legend",
      "scale": "color",
      "position": "auto"
    }
  ],
  "marks": [
    {
      "type": "area",
      "x": "month",
      "y": "hours1",
      "y2": "hours0",
      "color": "genre",
      "curve": "smooth",
      "opacity": 0.9
    }
  ],
  "interaction": [
    {
      "type": "tooltip",
      "fields": [
        "genre",
        "hours"
      ],
      "formats": {
        "month": {
          "month": "long",
          "year": "numeric"
        }
      }
    },
    {
      "type": "legend-filter"
    }
  ],
  "alt": "Listening hours by genre, millions per month"
}
</script>