3liz / lizmap-web-client

Transfer a QGIS project on a server, Lizmap is providing the web interface to browse it
https://www.lizmap.com
Mozilla Public License 2.0
257 stars 143 forks source link

Dataviz: scatterplot traces are not coloured according to values in attribute table #4444

Closed InnovPlantProtect closed 2 months ago

InnovPlantProtect commented 4 months ago

What is the bug? (in English)

I have a table with meteo data from several stations. Variables are daily min, avg and max temp and relative humidity. Data start from Jan 2024. I am trying to use dataviz to plot in a single scatter plot the avg temp of each station. To do so i set colour = station_name. However, dataviz shows only 1 station.
In plotly express the code will be something lilke fig = px.line(df, x='date', y='temp_med_C', color='station_name') where df is my meteo_data table

Steps to reproduce the issue

1.in QGIS import meteo_data from postgresql and ensure that in the qgis server project property the layer has WFS checked 2.in QGIS open lizmap plugin and in dataviz choose scatter plot, then date as x axis and temp_med as y axis. Define colour = station_name dataviz_scatterplot

  1. publish the project and check the results, which unfortunately are not what expected as a single line is plotted instead of the 4 (stations)
  2. dataviz_published

Versions, safeguards, check summary etc

Versions :

List of safeguards :
* Mode : safe * Allow parent folder : no * Prevent other drive : yes * Prevent PG service : yes * Prevent PG Auth DB : yes * Force PG user&pass : yes * Prevent ECW : yes

Check Lizmap plugin

Operating system

Ubuntu 22

Browsers

Firefox, Chrome

Browsers version

recent

Relevant log output

No response

nboisteault commented 4 months ago

Hi @InnovPlantProtect Can you show us colors you put in your table?

nboisteault commented 4 months ago

Hi @InnovPlantProtect , Can you show us what result you wish?

InnovPlantProtect commented 4 months ago

@nboisteault please find below what i get from running a python code i wrote. the graph is obtained with plotly. Note that the graph shows only only two stations in May as i am waiting for the data of the other stations. So, it is OK if you see only two lines in that month meteo_stations_prr

InnovPlantProtect commented 4 months ago

@nboisteault the colours i had in the graphs take the station_name variable. In python i manage, in lizmap i did not.

InnovPlantProtect commented 3 months ago

@nboisteault and @mdouchin i have found a work around which allows me to do what i needed. I am sharing it FYI and for everyone else having a similar situation. I opted to relate my table to a vector file and use this one as source of data. Then i selected the same type scatter plot (see above figure) with date in the x variable and meteo parameters as y variables (e.g. min, agv and max temperature). I keep on using the variable station names as colour legend. Then, i enable the filter function and use the filter to have the graph for each station. In this way, by selecting the station i have its related graph. One question: the filter works only if the table has geometry. If i have a simple table (with no geom) the filter does not work. Is this an unexpected behaviour? If so, it would be great to enable the filter also for ordinary tables and not imply that all data in the webGIS are necessarily with geom. Thanks!

github-actions[bot] commented 2 months ago

This issue is missing some feedbacks. 👻 Please have a look to the discussion, thanks. 🦎