Annotating pie chart

Looking for a way to add the pie size inside it, e.g.
image

I’ve used this snippet, but have no idea how to refer to the total_size from query results (tried playing with {{}} and @ etc. but it doesn’t work. Has anyone tried to make something similar?
image

You’re using the custom javascript visualization, right?