1

I need to create complex labels for sites that contain multiple values in each. These values are colored depending on their value (ex. in range = green, out of range = red). I need to do this from an expression. Has QGIS implemented this feature yet?

Here's and image of what I'm trying to reproduce:

what I'm trying to reproduce

3
  • Label font colour can only be set per label. So you'd need to use rule-based labeling to create a single label per row and displace them accordingly. – Erik Nov 17 '20 at 17:47
  • @Erik Is there a way to have these grouped labels bounded by a bordered rectangle as in the example? – sdutcher Nov 17 '20 at 18:29
  • Probably by a ton of frickling, yes. – Erik Nov 18 '20 at 8:52
0

The version of QGis I'm running, 3.16 supports html formatting of label text.

enter image description here

The code to support conditional formatting is a little unwieldy, but it works. Just mind your html closures. Here's an example label value expression.

if(attribute(get_feature(@layer_name, 'sampleno', minimum(sampleno)+2),'PH') > 5.9 AND attribute(get_feature(@layer_name, 'sampleno', minimum(sampleno)+2),'PH') < 8.6, '<p style="color:green">','<p style="color:red">')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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