Forum Discussion
Deneb - change labelFontWeight for one value in an axis label
- 3 years ago
Hi tomwill,
Fields are not exposed in the datum object for an axis label. You have access to either a label or value property in the backing datum and it's this that you need to inspect in your condition.
Something like the following should work:
"labelFontWeight": { "condition": { "test": "datum['value'] == 'Global'", "value": "bold" }, "value": "normal" }I've replicated this in a chart I have open, specifying that the Wellington label be bold, as per the above approach and this seems as expected, e.g.:
Regards,
Daniel
Thanks this worked. Very new to Deneb so still a lot of copy, paste, pray. I had used the
"datum['Region']
structure to change data labels based on value but must be a difference in how datum works in a 'mark' block vs and 'encoding' block.
Glad it worked! Normally you would be correct in your assumption - you would refer to the field in a datum whenever it typically makes sense to do so (i.e. in a mark or most encoding channels), and was a good place to start. I was caught out by this initally, too 🙂
Axes are a special case because they potentially represent the normalisation of multiple series for a category, or could be continuous (and therefore use a different granularity for the number of displayed ticks than there are in your series). As such, the axis labels have their own (simpler) datum structure that is derived from the field you've encoded.