{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.invalid/course/v09/chart-spec-schema-v09.json",
  "title": "P09 chart specification",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "chart_id",
    "question",
    "source_version",
    "chart_type",
    "x",
    "y",
    "group_by",
    "filters",
    "unit",
    "period",
    "time_scope",
    "data_grain",
    "missing_value_policy",
    "zero_baseline_policy",
    "annotations",
    "do_not_claim",
    "human_review",
    "fallback"
  ],
  "properties": {
    "chart_id": {
      "type": "string",
      "pattern": "^C[0-9]{2}$"
    },
    "question": {
      "type": "string",
      "minLength": 1
    },
    "source_version": {
      "type": "string",
      "minLength": 1
    },
    "chart_type": {
      "enum": [
        "horizontal_bar",
        "vertical_bar",
        "line",
        "scatter",
        "table",
        "none"
      ]
    },
    "x": {
      "type": "string"
    },
    "y": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "group_by": {
      "type": "string"
    },
    "filters": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "unit": {
      "type": "string",
      "minLength": 1
    },
    "period": {
      "type": "string",
      "minLength": 1
    },
    "time_scope": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "start",
        "end",
        "grain",
        "comparison"
      ],
      "properties": {
        "start": {
          "type": "string",
          "minLength": 1
        },
        "end": {
          "type": "string",
          "minLength": 1
        },
        "grain": {
          "type": "string",
          "minLength": 1
        },
        "comparison": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "data_grain": {
      "type": "string",
      "minLength": 1
    },
    "missing_value_policy": {
      "type": "string",
      "minLength": 1
    },
    "zero_baseline_policy": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "mode",
        "reason",
        "visible_scale_cue"
      ],
      "properties": {
        "mode": {
          "enum": [
            "required",
            "exception",
            "not_applicable"
          ]
        },
        "reason": {
          "type": "string",
          "minLength": 1
        },
        "visible_scale_cue": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "annotations": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "do_not_claim": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "human_review": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "fallback": {
      "type": "string",
      "minLength": 1
    }
  }
}
