Open Presentation

Search docs

Loading documentation…
    OpenPresentation/opf
    Browse docs
    On this page
    View source

    Table Color Scale

    A color scale over the number cells of one or more columns. One scale is shared by all named columns, so equal numbers get equal colors. Only cells whose value is a finite number are shaded; a cell with its own style.fill keeps it. Two colors make a sequential scale: the lowest value is the first color, the highest the second. Three colors make a diverging scale: 'center' is drawn in the middle color, lower values towards the first and higher values towards the last. A diverging scale with no pinned 'min' or 'max' is symmetric around 'center', so equal distances from the center get equal strength. Colors are mixed in OKLab. A table that is paged is shaded over its whole range, so a value has the same color on every page.

    Metadata

    Definition
    #/$defs/TableColorScale
    Form
    object
    Source
    spec/schemas/opf.schema.json

    Field index

    FieldTypeReq.Description
    columnsarray<string>yesThe columns to shade, by header text (an inline table) or by dataset column name after 'fields' (a dataset-backed table). A name no column has is a 'table-color-scale-unknown-column' error.
    colorsarray<ref:SchemeColorName>—The colors of the scale, low to high, as scheme color names. Two colors make a sequential scale (the lowest value in the first, the highest in the second); three make a diverging scale (the middle color is drawn at 'center', the first below it and the last above it). Absent: ['surface', 'primary'].
    colors[] · Allowed values
    "accent1""accent2""accent3""accent4""accent5""accent6""dark1""dark2""light1""light2""primary""secondary""accent""background""surface""surfaceAlt""text""textSecondary"
    centernumber—The value drawn in the middle color. Only with three 'colors' (a 'center' with two colors, or with no 'colors', is a schema error). Absent: 0 when the values span both signs, else the middle of the range. With no 'min' and no 'max' the scale is symmetric around it.
    minnumber—The value drawn in the first color; lower values draw in it too. Absent: the lowest number in the named columns (a diverging scale with neither 'min' nor 'max' is symmetric around 'center': it runs from center minus d to center plus d, d the largest distance of any value from the center). A given 'min' or 'max' pins that end exactly, and each side of a diverging scale is then on its own span.
    maxnumber—The value drawn in the last color; higher values draw in it too. Absent: the highest number in the named columns (see 'min' for a diverging scale).

    columns

    typearray<string>requiredyesdefault—

    The columns to shade, by header text (an inline table) or by dataset column name after 'fields' (a dataset-backed table). A name no column has is a 'table-color-scale-unknown-column' error.

    colors

    typearray<ref:SchemeColorName>requirednodefault—

    The colors of the scale, low to high, as scheme color names. Two colors make a sequential scale (the lowest value in the first, the highest in the second); three make a diverging scale (the middle color is drawn at 'center', the first below it and the last above it). Absent: ['surface', 'primary'].

    colors[] · Allowed values
    "accent1""accent2""accent3""accent4""accent5""accent6""dark1""dark2""light1""light2""primary""secondary""accent""background""surface""surfaceAlt""text""textSecondary"

    center

    typenumberrequirednodefault—

    The value drawn in the middle color. Only with three 'colors' (a 'center' with two colors, or with no 'colors', is a schema error). Absent: 0 when the values span both signs, else the middle of the range. With no 'min' and no 'max' the scale is symmetric around it.

    min

    typenumberrequirednodefault—

    The value drawn in the first color; lower values draw in it too. Absent: the lowest number in the named columns (a diverging scale with neither 'min' nor 'max' is symmetric around 'center': it runs from center minus d to center plus d, d the largest distance of any value from the center). A given 'min' or 'max' pins that end exactly, and each side of a diverging scale is then on its own span.

    max

    typenumberrequirednodefault—

    The value drawn in the last color; higher values draw in it too. Absent: the highest number in the named columns (see 'min' for a diverging scale).

    Complete definition constraints
    Schema constraints
    {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "columns"
      ],
      "description": "A color scale over the number cells of one or more columns. One scale is shared by all named columns, so equal numbers get equal colors. Only cells whose value is a finite number are shaded; a cell with its own style.fill keeps it. Two colors make a sequential scale: the lowest value is the first color, the highest the second. Three colors make a diverging scale: 'center' is drawn in the middle color, lower values towards the first and higher values towards the last. A diverging scale with no pinned 'min' or 'max' is symmetric around 'center', so equal distances from the center get equal strength. Colors are mixed in OKLab. A table that is paged is shaded over its whole range, so a value has the same color on every page.",
      "properties": {
        "columns": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1,
          "uniqueItems": true,
          "description": "The columns to shade, by header text (an inline table) or by dataset column name after 'fields' (a dataset-backed table). A name no column has is a 'table-color-scale-unknown-column' error."
        },
        "colors": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/SchemeColorName"
          },
          "minItems": 2,
          "maxItems": 3,
          "description": "The colors of the scale, low to high, as scheme color names. Two colors make a sequential scale (the lowest value in the first, the highest in the second); three make a diverging scale (the middle color is drawn at 'center', the first below it and the last above it). Absent: ['surface', 'primary']."
        },
        "center": {
          "type": "number",
          "description": "The value drawn in the middle color. Only with three 'colors' (a 'center' with two colors, or with no 'colors', is a schema error). Absent: 0 when the values span both signs, else the middle of the range. With no 'min' and no 'max' the scale is symmetric around it."
        },
        "min": {
          "type": "number",
          "description": "The value drawn in the first color; lower values draw in it too. Absent: the lowest number in the named columns (a diverging scale with neither 'min' nor 'max' is symmetric around 'center': it runs from center minus d to center plus d, d the largest distance of any value from the center). A given 'min' or 'max' pins that end exactly, and each side of a diverging scale is then on its own span."
        },
        "max": {
          "type": "number",
          "description": "The value drawn in the last color; higher values draw in it too. Absent: the highest number in the named columns (see 'min' for a diverging scale)."
        }
      },
      "if": {
        "required": [
          "center"
        ]
      },
      "then": {
        "required": [
          "colors"
        ],
        "properties": {
          "colors": {
            "minItems": 3
          }
        }
      },
      "examples": [
        {
          "columns": [
            "Q1",
            "Q2",
            "Q3",
            "Q4"
          ]
        },
        {
          "columns": [
            "YoY %"
          ],
          "colors": [
            "accent2",
            "surface",
            "accent1"
          ],
          "center": 0
        }
      ]
    }