2

I have been trying to dynamically display labels based in the Decoration Title Label in QGIS, as can be seen on this answer by the user Kasper.

What I am trying to achieve now is to change the colour of those labels, somehow overriding the default colour option the Title Label provides here under the Font option: enter image description here

Ideally, on a string as the following one, which always displays first the name of the line and then dynamically the stops as the animation moves forward: Jubilee line: aggregate(layer:='your_layer_name',aggregate:='concatenate_unique', expression:="stop_name", filter:=@map_start_time <= "time" and "time" <= @map_end_time, concatenator:=',') the Jubilee Line bit should have a different colour than the rest of the text.

I believe wrapping the title (this Jubilee Line bit in the example) in a CASE WHEN ... THEN ... and calling a color_rgb function might work, but I couldn't achieve anything successful yet.

4
  • You can use HTML formatting for that (I don't know enough about to give a full anwser): north-road.com/2022/09/09/…
    – Kasper
    Jan 17, 2023 at 7:43
  • Yes, that's what I thought. HTML formatting is allowed almost elsewhere but not on the Title Label. Perhaps something interesting to be implemented on future QGIS updates.
    – Trikelians
    Jan 17, 2023 at 10:44
  • I had done a quick try an had managed to have one part of static text in bold, the other part of a different colour, Title decoration , Qgis 3.28
    – Kasper
    Jan 17, 2023 at 12:47
  • 1
    Oh, I see. You have to enable the 'Allow HTML formatting' option inside the Font configuration dialogue. Indeed, then it works.
    – Matt
    Jan 17, 2023 at 12:56

1 Answer 1

7

You can use HTML rendering in the Title Decoration:

First enable it in the Font properties by ticking the appropriate box:enter image description here

Format the Title as needed: enter image description here

It works: enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.