Bug report #21617

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

Added by Alister Hood over 5 years ago. Updated over 5 years ago.

Status:Open
Priority:Normal
Assignee:-
Category:Vectors
Affected QGIS version:3.6.0 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:29433

Description

0. 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.
1. 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.
2. 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.
3. 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
4. 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.
5. 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.

Associated revisions

Revision da6a3786
Added by Alister Hood over 5 years ago

Add missing bracket to formula generated by data defined override

Refs #21617

Revision e880db57
Added by backporting[bot] over 5 years ago

Add missing bracket to formula generated by data defined override

Refs #21617

History

#1 Updated by Alister Hood over 5 years ago

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

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

Also available in: Atom PDF