qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.46k stars 2.99k forks source link

Vector styling: Data Defined Override "Assistant" and expression editor do not work together #29433

Open qgib opened 5 years ago

qgib commented 5 years ago

Author Name: Alister Hood (@AlisterH) Original Redmine Issue: 21617 Affected QGIS version: 3.6.0 Redmine category:vectors


  1. Load a polygon layer and under layer styling click on the "Simple fill". Click the "data defined override" button to the right of the drop-down for "Fill color" or "Stroke color". Use the "Assistant" at the bottom of the menu to apply a data defined override based on a numeric field in the layer attributes.
  2. Click the data defined override button again, and click edit, to manually edit the expression. You will see in the bottom left of the dialog that the "Expression is invalid", because @Parser Errors: ramp_color function is called with wrong number of arguments. Expected 2 but got 3.@ This is because there is a bracket missing from the expression. The fix is easy - I will do a pull request.
  3. Add the missing bracket (next to the second to last one in the expression), and if your source data is right* you will still see the "Expression is invalid", because @Eval Error: "custom ramp" is not a valid color ramp@. If you replace "custom ramp" with the name of a colour ramp this error goes away. If possible, it would be much better if the "Assistant" would save the name of the colour ramp that you select, unless it actually deserves to be called "custom ramp" because you have actually customised it.
  4. Following on from 2, I guess it would also be better if a "custom ramp" didn't invalidate the expression, as you could then edit the expression successfully (currently I think it forgets what was in the "custom ramp" when you edit the expression).

Tested on Linux and Windows with versions up to 3.6

  1. If you edit the expression manually, and then try to use the assistant again, it will try to use the whole generated expression as the "source", rather than the field you originally specified. Not sure how easy this would be to fix.
  2. Combining 2 and 4, if you edit the expression manually, to use a named colour ramp, and then try to use the assistant again, it doesn't remember the named colour ramp - it defaults back to the one at the top of the list.
qgib commented 5 years ago

Author Name: Alister Hood (@AlisterH)


The fix is easy - I will do a pull request.

See [[https://github.com/qgis/QGIS/pull/9561]]

qgib commented 5 years ago

Author Name: Alister Hood (@AlisterH)


Sorry, make that https://github.com/qgis/QGIS/pull/9562

Pedro-Murteira commented 2 years ago

Still valid on QGIS 3.22.4 and 3.24.0.