Skip to content

SmallMultiple

SmallMultiple draws one base component once per panel: one panel per value of a dataset column, plus panels you list yourself. All panels use the same dataset, each with its own filter, and all share one scale. This is the IBCS “small multiples” chart template: one measure for many locations, products or regions, where the reader compares the panels.

bino builds the panels when it renders, from the data. A location that is added to the data gets its panel without a change to the manifest. The panels are laid out as a Grid with equal rows and columns, and the axes of each row and column are lined up (see Cell size and alignment).

apiVersion: bino.bi/v1alpha1
kind: SmallMultiple
metadata:
  name: net-profit-by-location
spec:
  chartTitle: Net profit by location
  dataset: net_profit
  unitScaling: net_profit_scale # a ScalingGroup, shared by all panels
  scale: "0.5" # a fixed factor or "none", never "auto"
  base:
    kind: ChartTime
    ref: net-profit-trend
  panels:
    by: rowGroup

This gives one ChartTime per distinct rowGroup value, each filtered to [rowGroup] = '<value>', with the value as the caption of its panel.

  • Use SmallMultiple when every panel is the same chart or table on a slice of one dataset, and the panels must be comparable: same scale, same size, axes on one line.
  • Use a Grid when the cells show different things.
  • For a scatter or bubble chart split by rowGroup or category, the facet field of ChartScatter and ChartBubble is the better fit: it draws all panels in one chart with shared axes. Lint says so (small-multiple-xy-facet). When you need the SmallMultiple for them, set seriesNames in the ComponentStyle so that a series has the same color in every panel.

panels.by names a column of the dataset. Its distinct values become the panels. Column names are case-sensitive: rowGroup, not rowgroup, and must not contain ]. A value with an apostrophe, such as O'Hare, is quoted for the filter.

panels:
  by: rowGroup
  order: ac1 desc # largest first
  limit: 15 # the rest is dropped, with a warning
  items:
    - label: 11 more small locations
      filter: "rowGroup NOT IN ('Cologne', 'Frankfurt')"
    - label: Average of 25 locations
      dataset: net_profit_avg
      spec: { selectedStyle: highlight-panel }
  • order sorts the by panels: dataset (default) sorts by the <by>Index column when it exists (rowGroupIndex for rowGroup), else by label. label sorts by label, numbers as numbers. Any other name, such as ac1, sorts by the sum of that column per panel. Add desc to reverse.
  • limit keeps the first panels after sorting.
  • items are panels you define yourself. They come after the by panels. An item selects its rows with filter, can use another DataSet with dataset, and can change its panel with spec. panels needs by, items, or both.
  • param also passes the panel value to a referenced base as a parameter, for a base that uses it in its text or filter: param: LOCATION gives ${LOCATION}. The value is escaped like ${panel.label} (see below). A select parameter gets the value as its _LABEL too, not the label of the option.

The filter of a panel is the filter of the SmallMultiple, the filter of the base and the panel part ([<by>] = '<value>', or the item’s filter), joined with AND. A panel without any of them has no filter, also when its dataset sets a default filter.

The panels, their order and limit come from all rows of the dataset. The filters only apply inside each panel, so a location that a filter removes still gets an empty panel, and the build log says so. To leave panels out, filter the DataSet itself.

base is the component in every panel: a ChartStructure, ChartTime, ChartScatter, ChartBubble, ChartBullet or Table. It is either inline (kind + spec) or a reference (kind + ref, with params, and spec to override fields of the referenced document).

The SmallMultiple sets these fields in every panel, over the base and over the spec of an item, so no panel can leave the shared scale:

  • dataset (or the dataset of an item),
  • unitScaling and percentageScaling (ChartStructure, ChartTime and Table),
  • scale,
  • filter.

A dataset in base.spec has no effect, and lint says so. A default filter from the _spec_ columns of the dataset is replaced by the panel filter, and the build log says so.

In the base spec, the caption and the item specs, ${panel.label}, ${panel.value} and ${panel.index} (1-based) are replaced per panel. The values are escaped for where they land: as SQL text in the filter of the base (write '${panel.label}'), as JSON text everywhere else. A label with quotes is safe in both.

IBCS small multiples are only useful when the reader can compare the panels. That needs two things:

  • unitScaling: the number of data units per em, or a ScalingGroup. It is required for ChartStructure, ChartTime and Table, and must not be auto.
  • scale: a fixed font factor such as "0.5", or "none". It is required and must not be auto. With auto, each panel picks its own factor, and the same unitScaling gives bars of different lengths.

Start with scale: "0.5" for a four-column grid on one page, and adjust it until the panels fit. The rule small-multiple-scale and the build both reject a missing or auto value.

Each panel gets a caption at its top left. The default is ${panel.label}. Set caption to change it, or to "" to turn the captions off:

caption: "${panel.index}. ${panel.label}"

An empty chartTitle in the base is usual, as the caption names the panel. The font of the captions is set with the caption* keys of the grid style.

card puts every panel in a LayoutCard. Use it when a panel needs more than a caption: a logo, a footer, or a card title in IBCS form.

card:
  titleImage: "logo_${panel.value}" # an Asset per location
  footerText: "Source: ${panel.label} controlling"
  • The card title names the panel: titleBusinessUnit is ${panel.label} unless you set it. Set it to "" for a card without a title line.
  • The card has no border. Set cardShowBorder: true for one.
  • The captions are off. A caption next to a card names each panel twice, and lint warns (small-multiple-card).
  • card takes these fields of a LayoutCard: titleImage, titleBusinessUnit, titleScenarios, titleVariances, titleMeasures, titleDateStart, titleDateEnd, titleDateFormat, titleDateLink, footerText, cardShowBorder, cardFitToContent, selectedStyle, ruleset and i18nNamespace. The card holds exactly the one panel component, so it has no children and no card layout. ${panel.label}, ${panel.value} and ${panel.index} are replaced in every field.
  • An entry of panels.items can change the card of its panel with its own card, over the shared one. It needs card on the SmallMultiple.
  • With cellHeight: auto, cardFitToContent is true unless you set it.

The page title already names the measure and the period. Repeat titleMeasures or the dates in the card only when the panels differ in them.

The axes stay on one line also when the cards have titles of different height, for example when only some panels have a logo. This needs template engine v1.0.0-next.33 or newer.

  • columns: number of panel columns. Default: the square root of the panel count, rounded up (16 panels give 4 columns).
  • cellHeight, cellWidth: equal (default) or auto.
  • cellGap, showBorders (default false), selectedStyle, i18nNamespace, chartTitle: as on a Grid.

The panels are always aligned on their baselines, in both directions.

A panel can take more than one position of the grid, and it can have a background color. Use this for the one location that needs more room, or to set a panel apart.

columns: 4
panels:
  by: rowGroup
  overrides:
    - value: Berlin # the panel of this by value
      rowSpan: 2
      background: "#fff3c4"
  items:
    - label: Average of 25 locations
      dataset: net_profit_avg
      columnSpan: 2
      background: "#f2f2f2"
  • rowSpan and columnSpan are whole numbers from 1. Default: 1.
  • background is a CSS color for the cell of the panel. It wins over cellBackground of the grid style, which colors every cell.
  • An entry of panels.items takes the three fields directly.
  • A by panel comes from the data, so it has no entry of its own. panels.overrides names it by its value: the same text as ${panel.value}. overrides needs by. The value is compared with the value of the column as it is: text is case-sensitive, and spaces count. A value may have only one entry: put all fields of a panel in it. Lint reports a second entry (small-multiple-override-duplicate), and the build uses the first one and warns. A value that no panel has does nothing. The build log says so, and bino lint --execute-queries reports it (small-multiple-override-unmatched).

Bino places the panels row by row, in their order. Each panel goes to the next free position where its span has room. A position that a panel skips stays empty, and later panels do not go back to fill it. The grid gets as many rows as the panels need.

A columnSpan larger than columns cannot be placed. The build fails, and lint reports it (small-multiple-span). Without columns, the default is the square root of the number of positions that the panels take, rounded up, and never less than the widest columnSpan.

With cellHeight: equal a panel over two rows is as tall as two rows. The scale does not change: the panel has more room, not larger bars.

A ChartTime prints an axis title next to each of its axes: the chart title at the scenario axis, and the name of the variance at a variance axis. In a row of panels this repeats the same name in every panel. IBCS small multiples print it once, right of the last panel of a row.

axisTitles: rowEnd
  • each (default): every panel has its own axis titles.
  • rowEnd: only the last panel of each row has them, at its right. Bino sets axisTitlePosition of this panel to right and of all other panels to none. An axisTitlePosition in base.spec is replaced.
  • A panel that spans rows counts for the row it starts in.
  • An entry of panels.items that sets axisTitlePosition in its spec keeps its own value.

rowEnd needs a ChartTime base. With another base kind the build fails, and lint reports it (small-multiple-axis-titles).

A SmallMultiple draws one chart per panel. For a ChartScatter or a ChartBubble this repeats the tick labels, both axis titles and the legend in every panel.

kind: SmallMultiple
spec:
  dataset: matrix
  axisTitles: shared
  columns: 6
  base: { kind: ChartBubble, ref: matrix_chart }
  panels: { by: rowGroup }

With axisTitles: shared the panels are one chart: Bino sets the facet of the base to the level of panels.by and draws it once. So there is one title per axis, tick labels at the outer panels only, one legend, one number format, and the name of a panel stands inside its plot. dataset, filter, scale, chartTitle, selectedStyle and i18nNamespace of the SmallMultiple go to the chart. scale does not need a fixed value here. columns works as in the grid, also its default. cellHeight, cellWidth, cellGap and showBorders belong to the grid and have no effect.

It needs a ChartScatter or ChartBubble base and panels.by: rowGroup or category. It does not work with card, caption, panels.items, panels.overrides, panels.order, panels.limit or panels.param, and not with a base that sets facet itself or uses a ${panel...} placeholder: the build fails, and lint reports it (small-multiple-axis-titles). The level of panels.by must be above the series level of the base, as for facet: a base that colors its points by rowGroup cannot have panels by rowGroup. The chart is then empty and the build reports layout-component-error with the message of the engine. A panel is no target of an Annotation here: the build warns about an annotation with panel and draws no mark for it. Target the SmallMultiple as a whole.

Spans, backgrounds and axisTitles: rowEnd need template engine v1.0.0-next.46 or newer. With an older engine bino build and bino lint stop with small-multiple-span-engine-version.

An Annotation can point at one panel, or at a data point in it: name the SmallMultiple and set panel to the label of the panel.

A SmallMultiple is a standalone document, or a child of a LayoutPage or LayoutCard, inline or by ref. It cannot be a cell of a Grid or a node of a Tree, and a ScreenshotArtefact cannot target it directly: wrap it in a LayoutCard.

apiVersion: bino.bi/v1alpha1
kind: LayoutPage
metadata:
  name: locations
spec:
  children:
    - kind: SmallMultiple
      ref: net-profit-by-location

SmallMultiple needs template engine v1.0.0-next.32 or newer, and v1.0.0-next.33 with card. With an older engine bino build and bino lint stop with grid-cell-layout-engine-version.

Attribute Type Required Default Description
spec.dataset string or object yes - Dataset of every panel: a DataSet name, an inline DataSet, or a list. With panels.by the first entry must be a DataSet.
spec.filter string no - AlaSQL WHERE fragment ANDed into every panel filter.
spec.unitScaling string or number conditional - Shared unit scaling. Required for ChartStructure, ChartTime and Table bases, never auto.
spec.percentageScaling string or number no - Shared percentage scaling, never auto.
spec.scale string or number yes - Shared font scale: a fixed factor or none, never auto.
spec.base.kind string yes - ChartStructure, ChartTime, ChartScatter, ChartBubble, ChartBullet or Table.
spec.base.ref string conditional - Name of a document of that kind. Without it, base.spec is the inline spec.
spec.base.params object of string no - Parameters of the referenced document. Only with ref.
spec.base.spec object conditional - Inline spec, or overrides of the referenced spec. Required without ref.
spec.caption string no "${panel.label}" Caption of each panel. "" turns captions off. Off by default with card.
spec.card object no - Put every panel in a borderless LayoutCard. See Cards.
spec.panels.by string conditional - Column whose distinct values become panels. panels needs by or items.
spec.panels.order string no dataset dataset, label, or a column name, optionally followed by desc.
spec.panels.limit integer no - Most panels from by.
spec.panels.param string no - Pass the panel value to the referenced base as this parameter. Needs base.ref.
spec.panels.items array conditional - Explicit panels after the by panels: label (required), filter, dataset, spec, card, rowSpan, columnSpan, background.
spec.panels.items[].rowSpan integer no 1 Number of grid rows the panel takes. Minimum: 1. Needs engine v1.0.0-next.46.
spec.panels.items[].columnSpan integer no 1 Number of grid columns the panel takes. Minimum: 1, not more than columns. Needs engine v1.0.0-next.46.
spec.panels.items[].background string no - Background color of the cell of the panel (CSS color). Needs engine v1.0.0-next.46.
spec.panels.overrides array no - Span and background of single by panels: value (required), rowSpan, columnSpan, background. Needs by.
spec.panels.overrides[].value string, number or boolean yes - The value of the by column that names the panel.
spec.panels.overrides[].rowSpan, columnSpan, background no - As on an entry of panels.items.
spec.axisTitles string no each each, rowEnd (axis titles only right of the last panel of a row) or shared (one chart with shared axes and legend). rowEnd needs a ChartTime base and engine v1.0.0-next.46. shared needs a ChartScatter or ChartBubble base.
spec.columns integer no square root Number of panel columns.
spec.cellHeight string no equal equal or auto.
spec.cellWidth string no equal equal or auto.
spec.cellGap string no - CSS gap between the panels.
spec.showBorders boolean no false Lines between the panels.
spec.chartTitle string no - Title of the whole grid.
spec.selectedStyle string no - ComponentStyle of the grid, inherited by the panels.
spec.i18nNamespace string no - I18n namespace inherited by the panels.