{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "dataOrigin",
    "charts"
  ],
  "properties": {
    "id": {
      "enum": [
        "performance-drawdown",
        "observed-forecast-actual",
        "price-volume",
        "flow-price",
        "sox-quadrant",
        "etf-holdings",
        "dram-rebase",
        "journal-ledger",
        "news-evidence"
      ]
    },
    "dataOrigin": {
      "const": "synthetic"
    },
    "charts": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Chart"
      }
    },
    "detail": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/Chart"
      }
    },
    "ledger": {
      "$ref": "#/$defs/Table"
    },
    "article": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "title",
        "date",
        "body",
        "source",
        "quote"
      ],
      "properties": {
        "title": {
          "type": "string"
        },
        "date": {
          "type": "string",
          "format": "date"
        },
        "body": {
          "type": "string"
        },
        "source": {
          "type": "string"
        },
        "quote": {
          "type": "string"
        }
      }
    }
  },
  "$defs": {
    "Chart": {
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "line",
            "area",
            "small-multiples",
            "bar",
            "diverging",
            "slope",
            "dumbbell",
            "scatter",
            "heatmap",
            "boxplot",
            "histogram",
            "waterfall",
            "range",
            "calendar",
            "fan",
            "bullet",
            "treemap",
            "candlestick",
            "donut"
          ],
          "title": "Kind"
        },
        "title": {
          "type": "string",
          "title": "Title"
        },
        "unit": {
          "type": "string",
          "title": "Unit"
        },
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Description"
        },
        "x_label": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "X Label"
        },
        "y_label": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Y Label"
        },
        "x_reference": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "X Reference"
        },
        "y_reference": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Y Reference"
        },
        "x_domain": {
          "anyOf": [
            {
              "items": {
                "type": "number"
              },
              "type": "array",
              "maxItems": 2,
              "minItems": 2
            },
            {
              "type": "null"
            }
          ],
          "title": "X Domain"
        },
        "y_domain": {
          "anyOf": [
            {
              "items": {
                "type": "number"
              },
              "type": "array",
              "maxItems": 2,
              "minItems": 2
            },
            {
              "type": "null"
            }
          ],
          "title": "Y Domain"
        },
        "x": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "maxItems": 20000,
          "title": "X"
        },
        "y": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "maxItems": 500,
          "title": "Y"
        },
        "series": {
          "items": {
            "$ref": "#/$defs/Series"
          },
          "type": "array",
          "maxItems": 48,
          "title": "Series"
        },
        "points": {
          "items": {
            "$ref": "#/$defs/Point"
          },
          "type": "array",
          "maxItems": 20000,
          "title": "Points"
        },
        "rows": {
          "items": {
            "$ref": "#/$defs/Measure"
          },
          "type": "array",
          "maxItems": 1000,
          "title": "Rows"
        },
        "matrix": {
          "items": {
            "items": {
              "type": "number"
            },
            "type": "array",
            "maxItems": 3,
            "minItems": 3
          },
          "type": "array",
          "maxItems": 20000,
          "title": "Matrix"
        },
        "forecast_start": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Forecast Start"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "kind",
        "title",
        "unit"
      ],
      "title": "Chart"
    },
    "Series": {
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$",
          "title": "Id"
        },
        "name": {
          "type": "string",
          "title": "Name"
        },
        "values": {
          "items": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "type": "array",
          "maxItems": 20000,
          "title": "Values"
        },
        "color": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            },
            {
              "type": "null"
            }
          ],
          "title": "Color"
        },
        "role": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "observed",
                "forecast",
                "actual",
                "benchmark"
              ]
            },
            {
              "type": "null"
            }
          ],
          "title": "Role"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "id",
        "name",
        "values"
      ],
      "title": "Series"
    },
    "Point": {
      "properties": {
        "name": {
          "type": "string",
          "title": "Name"
        },
        "x": {
          "type": "number",
          "title": "X"
        },
        "y": {
          "type": "number",
          "title": "Y"
        },
        "group": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Group"
        },
        "id": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$"
            },
            {
              "type": "null"
            }
          ],
          "title": "Id"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "name",
        "x",
        "y"
      ],
      "title": "Point"
    },
    "Measure": {
      "properties": {
        "name": {
          "type": "string",
          "title": "Name"
        },
        "value": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Value"
        },
        "id": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$"
            },
            {
              "type": "null"
            }
          ],
          "title": "Id"
        },
        "start": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Start"
        },
        "end": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "End"
        },
        "low": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Low"
        },
        "high": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "High"
        },
        "target": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Target"
        },
        "type": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "delta",
                "total"
              ]
            },
            {
              "type": "null"
            }
          ],
          "title": "Type"
        },
        "values": {
          "anyOf": [
            {
              "items": {
                "type": "number"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Values"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "name",
        "value"
      ],
      "title": "Measure"
    },
    "Table": {
      "properties": {
        "title": {
          "type": "string",
          "title": "Title"
        },
        "columns": {
          "items": {
            "$ref": "#/$defs/Column"
          },
          "type": "array",
          "maxItems": 32,
          "minItems": 1,
          "title": "Columns"
        },
        "rows": {
          "items": {
            "$ref": "#/$defs/TableRow"
          },
          "type": "array",
          "maxItems": 25000,
          "title": "Rows"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "title",
        "columns",
        "rows"
      ],
      "title": "Table"
    },
    "Column": {
      "properties": {
        "key": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$",
          "title": "Key"
        },
        "label": {
          "type": "string",
          "title": "Label"
        },
        "unit": {
          "type": "string",
          "title": "Unit",
          "default": ""
        },
        "numeric": {
          "type": "boolean",
          "title": "Numeric",
          "default": false
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "key",
        "label"
      ],
      "title": "Column"
    },
    "TableRow": {
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$",
          "title": "Id"
        },
        "cells": {
          "patternProperties": {
            "^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "number"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "type": "object",
          "maxProperties": 32,
          "title": "Cells"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "id",
        "cells"
      ],
      "title": "TableRow"
    }
  }
}
