barchart

barchart, tile type

The barchart tile displays one or more numeric series grouped by category. Each value expression passed after the with keyword should use an aggregator. An explicit group by statement is expected.

table T = extend.range(10)
T.X = random.poisson(5 into T)
T.G = "G\{T.N}"

show barchart "My Groups" { 1..8, 1..14;unit: "$"} with
  sum(T.X)
  group by T.G

The tile can also display multiple series:

table T = with
  [| as Category, as Units, as Returns |]
  [| "A", 10, 1 |]
  [| "A", 15, 2 |]
  [| "B", 8, 0 |]
  [| "B", 12, 1 |]

show barchart "Units and returns" { 1..8, 1..12 } with
  sum(T.Units) as "Units" { color: "orange" }
  sum(T.Returns) as "Returns" { color: "red" }
  group by T.Category

Examples

In region-based dashboards, barchartVariant controls bar thickness and barchartValuePosition places values over the bars or to their right. The following tiles display identical quantities with two presentations.

table Items = with
  [| as Sku, as Units |]
  [| "A-100", 20 |]
  [| "B-200", 60 |]
  [| "C-300", 40 |]

variants = show region { 1..8, 1..8 }

show barchart "Thick bars, values over" { 1..6, 1..6 in variants;
  barchartVariant: thick; barchartValuePosition: "over"
} with
  sum(Items.Units) { color: blue; unit: " units" }
  group by Items.Sku
  order by Items.Sku

show barchart "Thin bars, values right" { 7..12, 1..6 in variants;
  barchartVariant: thin; barchartValuePosition: right
} with
  sum(Items.Units) { color: blue; unit: " units" }
  group by Items.Sku
  order by Items.Sku

Series with the same seriesGroup share a scale. Distinct groups use independent scales; the default group is "auto". Setting unit changes the display label without changing the group.

table Items = with
  [| as Sku, as Stock, as Demand, as Value |]
  [| "A-100", 20, 40, 8000 |]
  [| "B-200", 60, 30, 12000 |]
  [| "C-300", 40, 50, 6000 |]

comparison = show region { 1..8, 1..18 }

show barchart "Independent quantity and money scales" { .., 1..15 in comparison;
  barchartVariant: thin; barchartValuePosition: right; numbers: simple
} with
  sum(Items.Stock) as "Stock" { seriesGroup: "quantity"; unit: " units"; color: blue }
  sum(Items.Value) as "Value" { seriesGroup: "money"; unit: "$"; color: green }
  group by Items.Sku
  order by Items.Sku

A-100 has one third of the largest stock quantity, but two thirds of the largest monetary value. Bar lengths can be compared within a group. They cannot be compared across groups as if their units and scales were identical.

Remarks

Each value expression becomes one series in the barchart.

With block placement such as { 1..2, 1..4 }, the group by expression must have type text. Use text(...) when grouping by a non-text category.

Legacy dashboards with placement such as a1d4 accept exactly one value expression. Use block placement such as { 1..2, 1..4 } to display multiple series. See show for the placement rules.

StyleCode

In region-based dashboards, the barchart exposes tile, series, and value scopes. A series has its own style, and a value can receive per-category styling through vector injection. The legacy axis and legend scopes below do not describe the region-based barchart.

The legacy dashboard attachment points are listed below.

For generic StyleCode rules, see stylecode.

User Contributed Notes
0 notes + add a note