Skip to Content
DashboardsHow-to guidesRecipe: top N as a horizontal bar

Recipe: top N as a horizontal bar

For: implementers. Setup: ModularIoT.

Result: a ranking of the 5 owners with the most requests, from highest to lowest, with the value at the end of each bar.

Top 5 owners as horizontal bars with labels

Before you start

StepWhere
Save each SQL query with a nameSettings › Connections › BigQuery › + New › Save
Add a saved query to the dashboardWith Edit Mode on: settings menu (gear) › Saved queries › Add query. Connection: your BigQuery connection. Operation: the SQL query’s name
Add a widgetWith Edit Mode on: Add Widget

The full walkthrough is in Build your first dashboard.

Query

SELECT responsable, COUNT(*) AS cantidad FROM `my-project.operations.solicitudes` GROUP BY responsable ORDER BY cantidad DESC LIMIT 5

Save it as top_responsables. The chart does not sort: the order comes from ORDER BY. The first row is at the top.

Steps

  1. Turn on Edit Mode. Add the saved query Result name top, Operation top_responsables, Parameters (JSON) {}.

  2. Add Widget › search Chart › Chart v2. Data Provider: Planner, Variable top.

  3. Visualization:

    SettingValue
    TitleTop 5 owners
    Chart FamilyCartesian
    X-Axis Columnresponsable
    RepresentationsThe widget comes with two (bar and line). Delete the line. On the bar: column cantidad, label Requests, Labels on
    Horizontal BarsOn
    Show LegendOff
  4. Save.

Variants

You wantChange
The top 10LIMIT 10 and a taller widget
The bottom (fewest requests)ORDER BY cantidad ASC
Color by valueColors & Rules: for example > 10 red. See Chart v2
Long namesThey are cut at 120 pixels. Shorten them in the query

The label of the longest bar can be cut at the right edge, as in the screenshot (#2246 ).

Last updated on