OBJECTIVE
I'm trying to add data labels to my chart, however I have multiple bars layered on top of each other, and I need the data labels to hover over different bars depending on if values in a certain field are positive or negative.
ATTEMPT
This could be achieved by changing the "field" property of the "y" encoding using a condition. I've spent some time exploring Vega-Lite documentation and experimenting with some stuff, but I can't get it to work no matter what I try. Vega seems to ignore by condition. I'm also curious if I'm able to apply conditions to "mark" rather than "encoding". When values are negative, I'd like to change "dy" to 10 from -10.
Any suggestions?
'''
"mark": {
"type":"text",
"dy":-10
},
"encoding": {
"text": {
"field": "field_one"
},
"y": {
"condition":{
"test":"datum['test_data'] < 0",
"field": "field_one"
},
"field": "field_two"
}....
}
'''