Vega-Lite API: What's the best way to add an annotation?

What I have in this notebook seems brittle, as the annotation text is not actually linked to the rule, so changes to the chart can leave the text floating.

Also, for the markRule , is the .data([0]) approach the right thing to do? It seems that if I don’t do that I either get nothing (if no data is declared), or I get a darker mark, presumably because the mark is being repeated many times (if I use the actual data being used by the line).

Any ideas, anyone? Maybe @visnup?

Create an object with both ruler and its annotation?

Hi @abitrolly! I wonder if I don’t understand what you mean, but I’m not sure I can see how that would help.

In my example, the position of the rule comes from encoding vl.y().datum(185) but the position of the text comes from vl.markText({…dx: 20,dy: -134…}) which leaves them essentially unrelated.

I think that ideally there would be something like vl.markRule({label:"Max Temp: 185˚F",dx:-2,dy:3}) where the positional properties were relative to the actual rule.