I am trying to symbolize a point layer with rectangles shaped and colored by gradient according to attribute values. I am trying to do this via label backgrounds rendered as "Geometry generator" marker symbols to prevent rectangles from overlapping and enable easy callout creation (and to enable gradient fill -- this is, to my knowledge, impossible with Ellipse markers).
Here is an overview of what I am trying to achieve. The white rectangles (these are label background symbols) are placed as I want, but I cannot color them properly. The colored rectangles are created with geometry generator, they are the desired symbols, but I cannot place them correctly.
I encountered a feature of geometry generator I cannot explain. Let us take the following table as an example point layer:
x y 10 12 15 27 43 43 27 15 12 10
When I pass the code
$geometry to geometry generator in the Symbology section, the points are placed where they are meant to be:
However, when I add labels and pass the same code to geometry generator in Labels > Background > Marker symbol, the points are placed well away from the point locations:
These labels change their locations as I drag the map canvas, they enclose the point layers when the points are near the upper left corner of canvas. The locations of text labels remains as usual.
I have two (three) questions:
1. Why are the geometry-generated label background symbols placed like that?
2. How can one avoid such improper placement?
(3.) Maybe there is another way to symbolize points with geometry generator and prevent them from overlapping that is less painful?