Skip to content

Chart and stacked bar widgets #3432

Todo

Description

@rubenvdlinde

Is your feature request related to a problem? Please describe.

  • The counts per status or per month are the next question after the single numbers.
Why this is needed

Describe the solution you'd like

  • Widgets that plot grouped and timeseries aggregates: a chart (bar, line or pie) and a stacked bar over two grouping columns.
  • Depends on the aggregation endpoint. Links: project plan, sprint 2.
Diagram
sequenceDiagram
    actor U as Viewer
    participant C as Chart widget
    participant API as GET api/2 tables/{id}/aggregate (new)
    participant DB as cell tables
    U->>C: open the page
    C->>API: grouped mode, group by status
    API->>DB: count per group
    DB-->>API: groups and counts
    API-->>C: series
    C-->>U: bar, line or pie in theme colours, with a table of the values
    U->>C: open a stacked bar
    C->>API: grouped mode, two grouping columns, or timeseries mode per month
    API-->>C: series per group
Loading
Acceptance Criteria
  • Each type is listed by GET /api/2/widget-types with its settings schema.
  • Data comes from the grouped and timeseries modes of the aggregation endpoint.
  • Colours come from the theme, and the chart has a text alternative (a table of the values).
  • Export and import carry the widgets.
  • Unit tests for the schemas, a Playwright spec per widget.
  • The values count only rows the viewer may read; on a view source the view's filter applies.
  • Settings are stored as JSON text in the settings text column of tables_contexts_widget (at most 60000 bytes, GridWidgetTypes::SETTINGS_MAX_BYTES), not in a database JSON column, as advised on Grid pages in applications (frontend) #3099. Nothing is filtered or sorted on them.
  • Widgets are saved through the page route PATCH api/2/contexts/{contextId}/pages/{pageId}, which declares #[RequirePermission] for managing the application, and the service checks the same right before it writes. A test saves a page with the new widget as a reader of the application and expects 403, as learned in the review of feat(contexts): give applications a menu with its own API #3135.
  • Usable at 360 px wide: nothing cut off and no horizontal scroll of the page. Every action works with the keyboard alone.
Components
  • CnChartWidget (adapt, week 44): the chart widget type (bar, line, pie); its series come from aggregate.grouped and aggregate.timeseries of the data adapter instead of OpenRegister.
  • CnStackedBarWidget (adapt, week 44): the stacked bar widget type over two grouping columns, on aggregate.grouped.
Out of scope
  • Drilling down from a bar into the rows.
  • Exporting a chart as an image.
  • The aggregation endpoint: Robert's Q9 draft.
  • Slicing, in landing order: one PR for the bar chart, then line and pie, then the stacked bar.

Describe alternatives you've considered

Questions for maintainers

  1. Which chart component? Options: (a) a chart library added to Tables, (b) a chart component contributed to nc-vue, the way NcStatsBlock (feat: add NcStatsBlock component nextcloud-libraries/nextcloud-vue#9142) was. We would go with (b): other apps get the same charts, and the theme and dark mode are handled once.
  2. Which time buckets for timeseries? Options: (a) day, week, month and year, (b) any interval. We would go with (a): it covers the cases we know and keeps the endpoint simple.

Additional context

Linking to other objects
Relevant files:
Related issues

Drafted with AI assistance from the project plan; @remko48 reviews it. Part of #3419.

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

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions