{
  "$schema": "https://vega.github.io/schema/vega-lite/v6.json",
  "config": {
    "background": "#1c1a1d",
    "font": "Helvetica, Arial, sans-serif",
    "axis": {
      "labelColor": "#aaa",
      "titleColor": "#aaa",
      "domainColor": "#363338",
      "tickColor": "#363338",
      "gridColor": "#363338",
      "gridOpacity": 0.6,
      "labelFontSize": 14,
      "titleFontSize": 14,
      "titleFontWeight": "normal"
    },
    "legend": {
      "labelColor": "#e0e0e0",
      "titleColor": "#aaa",
      "labelFontSize": 14,
      "symbolType": "square",
      "symbolSize": 130
    },
    "title": {
      "color": "#e0e0e0",
      "fontSize": 19,
      "fontWeight": 600,
      "anchor": "start",
      "subtitleColor": "#aaa",
      "subtitleFontSize": 14,
      "subtitleLineHeight": 20,
      "offset": 12
    },
    "header": {
      "labelColor": "#e0e0e0",
      "labelFontSize": 14,
      "labelFontWeight": 600,
      "titleColor": "#aaa"
    },
    "view": {
      "stroke": null
    }
  },
  "title": {
    "text": "Every day of agent use",
    "subtitle": "Tokens per day, 11 May 2025 to 20 August 2026. Unfilled cells are days with no session at all."
  },
  "transform": [
    {
      "calculate": "datum.tokens === 0 ? 'none' : datum.millions < 15.9 ? 'under 16M' : datum.millions < 49.2 ? '16-49M' : datum.millions < 158.3 ? '49-158M' : 'over 158M'",
      "as": "bin"
    }
  ],
  "width": 858,
  "height": 88,
  "mark": {
    "type": "rect",
    "cornerRadius": 2,
    "stroke": "#1c1a1d",
    "strokeWidth": 2
  },
  "encoding": {
    "x": {
      "field": "date",
      "type": "ordinal",
      "timeUnit": "yearweek",
      "axis": {
        "title": null,
        "labelAngle": 0,
        "grid": false,
        "domain": false,
        "ticks": false,
        "labelOverlap": false,
        "labelExpr": "date(datum.value) > 7 ? '' : month(datum.value) == 0 ? timeFormat(datum.value, '%b %y') : timeFormat(datum.value, '%b')"
      }
    },
    "y": {
      "field": "date",
      "type": "ordinal",
      "timeUnit": "day",
      "axis": {
        "title": null,
        "grid": false,
        "domain": false,
        "ticks": false,
        "format": "%a",
        "labelExpr": "indexof([1,3,5], day(datum.value)) >= 0 ? timeFormat(datum.value, '%a') : ''"
      }
    },
    "color": {
      "field": "bin",
      "type": "nominal",
      "scale": {
        "domain": [
          "none",
          "under 16M",
          "16-49M",
          "49-158M",
          "over 158M"
        ],
        "range": [
          "#241f28",
          "#5b2a6b",
          "#8f2fae",
          "#be2edd",
          "#e879f9"
        ]
      },
      "legend": {
        "title": null,
        "orient": "bottom",
        "direction": "horizontal",
        "symbolType": "square",
        "symbolSize": 130,
        "columnPadding": 12
      }
    },
    "tooltip": [
      {
        "field": "date",
        "type": "temporal",
        "title": "day"
      },
      {
        "field": "millions",
        "type": "quantitative",
        "title": "million tokens",
        "format": ",.0f"
      }
    ]
  },
  "data": {
    "url": "/code/token-charts/daily-heatmap.data.json",
    "format": {
      "type": "json"
    }
  }
}
