Building an interactive dashboard in QGIS: dynamic analysis with Data Plotly, widgets and expressions

Objective

Create a dynamic monitoring interface in QGIS with :

  • Interactive graphs (via Data Plotly)
  • Simple user filters (range, date, type of waste)
  • Dynamic key indicators and statistics
  • A map that adapts to filtered data

All without leaving the QGIS interface!



Use case: monitoring beach litter

Let’s take our releves_dechets layer with :

Field Description beach Name of beach type_waste Waste category quantity Quantity observed date_obs Date of observation

Field Description
beach Name of beach
type_waste Waste category
quantity Quantity observed
date_obs Date of observation

Objective: enable a user to filter data (by range, date…) and immediately see :

  • An updated map
  • A dynamic graph
  • Updated indicators


Step 1: Filter data interactively

  • Open the layer’s attribute table (right-click > “Open attribute table”).
  • Click on the funnel icon to activate the filter.
  • Then click on the filter form icon.

The fields will appear with the widgets defined (single values, date range…). Select the desired values and click on “Apply filter”.

This filter does not directly modify the map, but you can :

  • use only the entities selected in Data Plotly,
  • or create a virtual layer with a SELECT * FROM releves_waste WHERE ….


Step 2: create an interactive chart with Data Plotly

  1. Open the Data Plotly panel (menu View > Panels > Data Plotly).
  2. Choose the chart type (e.g. Bar chart).
  3. Configure :

    • X Axis: type_dechet
    • Y Axis: quantity
    • Layer: your filtered layer
    • Check Use only selected features if you are filtering via the table.

As soon as you modify the filter or select other features, the graph is updated.


Step 3: Display dynamic indicators with labels

To avoid complex scripts or temporary views, QGIS lets you display dynamic statistics directly on the map, in the form of labels attached to features.

Objective

Display, for selected features only :

  • Beach name
  • Total waste observed on this range

Method

  • Activate labels on your layer.
  • In the label expression, use :

if(
  is_selected(),
  "plage"  || '\n'  ||  
  'Total déchets : ' || 
  aggregate(
    'suivi_plages_dechets',
    'sum',
    "quantite",
    filter:= "plage" = attribute(@parent, 'plage')
  ),
  ''
)

This expression checks whether the range is selected (is_selected()), then displays :

  • Its name
  • The sum of waste for this range, calculated dynamically via aggregate().

Result

When you select one or more ranges, the label is displayed only on those selected, with their respective waste totals.


Variant (optional)

You can also filter via the attribute table or a search form, and the labels will react automatically to the selection.


Step 4: Organize the workspace

Create a dashboard interface:

  • Left: attribute table or filters
  • Center: map
  • Bottom: Data Plotly graph
  • Right: counters/statistics (via text frames)

Save your layout via Project > Save layout.


In a nutshell

Element Tools used Filtering Attribute table / Form Reactive graphics Data Plotly Dynamic statistics Expressions / Custom widgets User interface Workspace organization

Element Tools used
Filtering Attribute table / Form
Reactive graphics Data Plotly
Dynamic statistics Expressions / Custom widgets
User interface Workspace organization


Bonus: advanced tips

  • Create a virtual layer with a dynamic filter to centralize displayed data
  • Use CASE and regexp_match() functions for advanced groupings
  • Test plug-ins: Quick Filter, Attribute Table Filter, Input Widgets
  • Consider a PostgreSQL/PostGIS project with materialized views filterable by date or site


To be continued…

In a future article, we’ll look at how to transform this QGIS dashboard into a web interface with :

  • Export to QGIS Server or Lizmap
  • Filterable online dashboard (range, date…)
  • Integration into a participatory or citizen website


Si cet article vous a intéressé et que vous pensez qu'il pourrait bénéficier à d'autres personnes, n'hésitez pas à le partager sur vos réseaux sociaux en utilisant les boutons ci-dessous. Votre partage est apprécié !

Leave a Reply

Your email address will not be published. Required fields are marked *