Sprucely title background

Формат данных

Every dashboard rendered by Sprucely.io - whether created through the standalone JavaScript runtime, the standalone React components, or stored in your account - shares the same underlying JSON shape: a config object for dashboard-wide styling and a data object describing the widget tree. This reference documents that JSON in full, together with the dataset format it reads from and which chart type to pick for a given combination of columns. For embedding instructions, see the simple dashboard integration notes.

Dashboard JSON

Every dashboard is a single JSON object with two top-level keys: config, which carries dashboard-wide styling, and data, a tree of typed widget nodes starting from a single dash root. Each node has a type field and, for container types, a children array of nested nodes.

  • dash - the dashboard root. Always exactly one, at the top of the tree.
  • dash_stacker_hor / dash_stacker_ver - lays out its children in a row or a column.
  • dash_chart - a chart, in one of six chart types (see below).
  • dash_table - a data table.
  • dash_text - a text block.
  • dash_image - an uploaded image.
  • dash_spacer - fixed empty space between widgets.

Every widget accepts the same presentation fields, regardless of type:

  • size - the widget’s size along its container’s main axis: ‘Auto’, ‘<n>px’ or ‘<n>%’.
  • padding - inner spacing, for example ‘10px’.
  • backgroundColor - a CSS color, for example ‘#FFFFFF’ or ‘transparent’.
  • borderRadius / borderWidth - corner radius and border thickness, for example ‘10px’.
  • borderColor - a CSS color for the border.
  • shadow - true or false; adds a drop shadow.

Chart Widgets

Every chart shares the same fields; which of x, y, d (or c) and r are used, and what type of column each accepts, depends on the chart type - each of the six chart types is covered in its own subsection below, with a live example rendered from one small shared sample dataset.

  • datasetId - the dataset this chart reads from - must match a dataset’s name.
  • chartType - area, bar, cell, dot, hexbin or line.
  • title - an optional chart title.
  • dataFunction - the aggregate applied to d (or c): count (default), sum, average, min, max, median or stddev. Leave d/c unset when using count.
  • x - the column for the X dimension.
  • y - the column for the Y dimension (cell, dot and hexbin only).
  • d (or c, an alias for the same field) - the column aggregated into the chart’s value/color dimension.
  • r - the column for the radius dimension (dot only).
  • seasonX / seasonY - groups a time column into a recurring period: year, quarter, month, week, dayofyear, day, dayofweek, hour, minute or second.

Dimension columns are classified as categorical, time or continuous based on their declared type - see the dataset JSON section below. When dataFunction is count, the d/c dimension is left unset - a count needs no value column. Any other aggregate (sum, average, min, max, median or stddev) requires it.

Bar

x accepts a categorical, continuous or time column. d (or c) must be continuous, and is only used when dataFunction is not count. seasonX is allowed when x is a time column, to group it into a recurring period such as day of week. y and r are not used.

Line

x accepts a continuous or time column - not categorical. d (or c) must be continuous, only used when dataFunction is not count. Seasonality is not supported. y and r are not used.

Area

x accepts a continuous or time column - not categorical. d (or c) must be continuous, only used when dataFunction is not count. Seasonality is not supported. y and r are not used.

Cell

x and y both require a categorical column, or a time column with seasonality enabled (seasonX for x, seasonY for y). d (or c) must be continuous, only used when dataFunction is not count. seasonY additionally requires x to already resolve to a categorical dimension - either a genuinely categorical column, or a time column with seasonX set. r is not used.

Dot

x and y accept a continuous or time column. r and d (or c) must both be continuous - never categorical or time. Seasonality is not supported. Dot charts read best with datasets of up to a few hundred rows.

Hexbin

x and y both accept a continuous or time column - not categorical. d (or c) must be continuous, only used when dataFunction is not count. Seasonality is not supported. r is not used.

Other Widgets

Table (dash_table)

  • datasetId - the dataset to display.
  • fontFamily - default Arial; one of Arial, Calibri, Cambria, Century Gothic, Courier New, Garamond, Helvetica, Consolas/Monaco (Monospace), Lucida Bright, Lucida Sans, Segoe UI, Tahoma, Verdana.
  • fontSize - default 12px; 6-256px or 1-10vw.
  • color - default inherit.
  • bold / italic - true or false, default false.
  • ratio - width/height ratio, a number from 0.125 to 16.

Text (dash_text)

  • text - the text to display.
  • fontFamily / fontSize (default 3vw) / color / bold / italic - same as the table widget.
  • justifyContent / alignItems - ‘0’ start, ‘1’ center or ‘2’ end.

Image (dash_image)

  • assetId - an uploaded image asset.
  • objectFit - default none; none, contain, cover or fill.

Spacer (dash_spacer)

  • size - required; default 100px; 0-100% or 30-1000px.

Stackers (dash_stacker_hor, dash_stacker_ver)

  • children - the nested widgets, laid out in a row (dash_stacker_hor) or a column (dash_stacker_ver).
  • gap - default ‘10px’; spacing between children.
  • minHeight - a minimum height for the stacker.

Dataset JSON

A dataset is a single JSON object with a name, typed columns and rows:

{
  "name": "Orders",
  "headers": ["region", "category", "amount", "quantity"],
  "types": ["VARCHAR", "VARCHAR", "FLOAT", "INTEGER"],
  "entries": [
    ["North", "Electronics", 120.50, 2],
    ["South", "Clothing",     89.95, 1],
    ["North", "Furniture",   432.00, 5],
    ["South", "Electronics",  74.50, 1]
  ]
}
  • name - the dataset name; charts and tables reference it through their datasetId field.
  • headers - the column names, in the same order as each row in entries.
  • types - one column type per header - see the categories below.
  • entries - the rows, each an array of values in header order.

Optionally, row_start, row_end, col_start and col_end select a zero-indexed, inclusive sub-range of entries to import - useful when appending only new rows from a larger table. All four default to the full range:

{
  "name": "Orders",
  "headers": ["region", "amount"],
  "types": ["VARCHAR", "FLOAT"],
  "entries": [ ["North", 120.50], ["South", 89.95], ["North", 432.00], ["South", 74.50] ],
  "row_start": 0,
  "row_end": 1,
  "col_start": 0,
  "col_end": 1
}

Every column type is classified as categorical, time or continuous, which determines which chart dimensions it can be used for - see the chart widget sections above:

  • Categorical - BIT, BITSTRING, BOOLEAN, BOOL, LOGICAL, BLOB, BYTEA, BINARY, VARBINARY, UUID, VARCHAR, CHAR, BPCHAR, TEXT, STRING
  • Time - DATE, TIME, TIMESTAMP, DATETIME, TIMESTAMP WITH TIME ZONE, TIMESTAMPTZ
  • Continuous - every other type, for example INTEGER, FLOAT, DOUBLE, BIGINT, DECIMAL

Column references in a chart (x, y, d/c, r) must match a header name exactly, case-sensitive.

Styling and Theme Overrides

Dashboard-level colors are set once in config.style.widget and apply to every widget that doesn’t override them:

  • color - the default text color.
  • backgroundColor - the default dashboard background.
  • primaryColor - the foreground/active series color, used for headers and the cross-filtered trace.
  • primaryColorSubtle - the low end of the color gradient used by cell, dot and hexbin charts.
  • secondaryColor - the background/unfiltered series color.

Any widget can override its own presentation directly on its JSON node - backgroundColor, color, padding, borderRadius, borderWidth, borderColor and shadow. The example below overrides one chart’s own colors and corners while the rest of the dashboard keeps the shared theme:

{
  "type": "dash_chart",
  "datasetId": "Orders",
  "chartType": "hexbin",
  "x": "amount",
  "y": "quantity",
  "backgroundColor": "#F5F0FF",
  "borderRadius": "12px",
  "borderWidth": "1px",
  "borderColor": "#6E2BDC",
  "shadow": true
}

Complete Example

A small dashboard combining a header, two charts side by side and a table, all reading from one dataset:

{
  "config": {
    "type": "dashboard",
    "style": {
      "widget": {
        "color": "#000000",
        "backgroundColor": "#FFFFFF",
        "primaryColor": "#6E2BDC",
        "primaryColorSubtle": "#E2D5F8",
        "secondaryColor": "#CCCCCC"
      }
    }
  },
  "data": {
    "type": "dash",
    "children": [
      { "type": "dash_text", "text": "Orders Overview", "fontSize": "2vw", "justifyContent": "0" },
      {
        "type": "dash_stacker_hor",
        "children": [
          { "type": "dash_chart", "datasetId": "Orders", "chartType": "bar",  "x": "region", "dataFunction": "count" },
          { "type": "dash_chart", "datasetId": "Orders", "chartType": "cell", "x": "region", "y": "category", "dataFunction": "count" }
        ]
      },
      { "type": "dash_table", "datasetId": "Orders" }
    ]
  }
}