Skip to content

[Feature]: Layout bar charts: group and aggregate, order, bar limit, and look #2487

Done

Description

@jgregoriorincon

Before you start

What problem does this solve?

A layout's chart frame draws one bar per feature of a numeric field, the 20 largest, in one fixed colour, titled with the field name. That only works for small layers and simple questions. A map page often needs a chart that summarises the layer instead: the population per continent, the number of sites per region, the mean value per class.

Today, several things go wrong without saying so:

  • Bars past the 20th are dropped silently.
  • Features with no number in the field are left out silently.
  • Negative values are drawn as 1 px bars.
  • An unknown label field is ignored on layout.addElement.
  • label can't be changed with layout.update, and the Format pane has no rows for a chart's layer, field or label.

Proposed solution

Four pull requests, each with its own project capability, so that older readers refuse a project they would draw differently.

  1. Data (layout-chart-data)
    • group: one bar per value of a field, with statistic count, sum, mean, min or max. Blank values make one "(blank)" bar. A count can chart a text field.
    • order: largest first (the default), smallest first, by label A to Z, or layer order.
    • bars: 1 to 100, 20 by default.
    • Past the limit, the user chooses: leave the rest out, with a warning, or gather them in a last "Other" bar (other), which holds the same statistic over their features.
    • Negative values run from a zero line.
    • Warnings say how many features have no number.
    • label becomes editable in layout.update, and an unknown one is refused.
    • Format pane rows: Layer, Field, Group by, Statistic or Label, Order, Bars, Past the limit.
    • Charts saved before draw to the same pixels.
  2. Look (layout-chart-look): vertical or horizontal bars, values on the bars (thousands separated, a choice of decimals), a custom title or none, the bar colour, and labels set against the bars.
  3. Classes (layout-chart-classes): bars coloured by the layer's symbology classes, and bars stacked by a second field, with a key.
  4. Facing charts (layout-chart-facing): bars that run the other way (right to left, or down), a fixed maximum so that two charts share one scale, labels hidden, and a bar outline. Two charts side by side then compare two fields per category back to back, for example the share of businesses against the share of people in each district, with the category names between them.

The chart stays one drawing function, so the layout view, PNG, PDF and SVG exports all draw it the same way.

All four stay within the .rgis format 2, adding to it as the other layout options have since. A new option is written only when it differs from its default. Its capability goes into requires only when a project uses it. So a project with plain charts keeps its bytes and still opens in older releases, while one that uses the new options is refused there, naming the capability, instead of being drawn differently and saved without them.

Estimated scope

  • Medium: a broader feature that is feasible in a reasonable timeframe

Alternatives considered

  • Building the chart outside RustGIS and placing it as a picture: it doesn't follow the data, and it loses the layout's fonts and ink.
  • A report's chart block: reports already group and aggregate, but their charts don't go on a layout page.
  • One large PR: the model, the commands, the pane and four capabilities are easier to review in four steps.
  • A single back-to-back chart element with two fields: it would duplicate the bar drawing for one layout. Two charts that can face each other also cover a chart that runs the other way on its own.

Activity

  1. added
    enhancement
    on Nov 20, 2026
  2. jgregoriorincon commented on Nov 20, 2026

    @jgregoriorincon
    ContributorAuthor

    I'm working on this. Part 1 (data: group, statistic, order, bar limit, Other bar) is ready and its pull request follows shortly.

  3. jgregoriorincon commented on Nov 20, 2026

    @jgregoriorincon
    ContributorAuthor

    Part 1 was merged in #2489. I'm now working on part 2 (look: vertical bars, values on the bars with a choice of decimals, a custom title or none, the bar colour, and labels set against the bars), and its pull request follows shortly. I've also added a part 4 to the plan above: charts that can face each other, so that two of them side by side compare two fields per category back to back.

  4. jgregoriorincon commented on Nov 20, 2026

    @jgregoriorincon
    ContributorAuthor

    Part 2 was merged in #2537. I'm now working on part 3 (classes), in two pull requests so that each stays reviewable:

    • 3a: bars coloured by the layer's symbology classes (layout-chart-classes). A bar per feature takes its feature's class colour; a grouped bar takes the colour its features share, and keeps the chart's bar colour, with a warning, when they fall in several classes.
    • 3b: bars stacked by a second field, with a key (layout-chart-stack, its own capability, so a reader that knows 3a refuses a stacked chart instead of drawing it flat).

    The pull request for 3a follows shortly.

  5. jgregoriorincon commented on Nov 23, 2026

    @jgregoriorincon
    ContributorAuthor

    I'm now working on part 4 (facing charts), in two pull requests so that each stays reviewable:

    • 4a: bars that run the other way (mirror: right to left, or columns hanging down), a fixed maximum (max) so that two charts share one scale, and labels hidden (hideLabels). Capability layout-chart-facing.
    • 4b: a bar outline (barOutline), with a capability of its own (layout-chart-outline), so that a reader of 4a refuses a chart with an outline rather than drawing it without one.
  6. jgregoriorincon commented on Nov 27, 2026

    @jgregoriorincon
    ContributorAuthor

    All of this plan is merged:

    Each part added its own project capability (layout-chart-data, -look, -classes, -stack, -facing, -outline).

    Two chart notices go beyond this plan and will get their own issue: saying a chart's notices again on export (#2824, "Not in this PR"), and a notice for a chart too small to draw (noted as a follow-up in #2537).

    Closing as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions