I'm trying to programmatically modify the upper and lower range values and the label on the graduated symbol renderer of a map layer, then producing a PDF from a layout based on that map.
The map item updates correctly to reflect changes in the upper and lower range values, but the legend item does not reflect changes I make to the labels.
I've tried all the triggerRepaint()
, update()
, legendUpdate()
, etc. calls I could find but the only thing I found that made the legend update was setAutoUpdateModel(True)
, which has the unfortunate side-effect of making the legend include all the layers that I don't want to see a legend for. I'd even use that as a work-around if I could figure out how to programmatically hide the legend items I don't want.
What might I be missing or doing wrong?
layer.emitStyleChanged()
will do it.