Get label positions
First I want to thanks for this plugin cause it helped me a lot for a project.
The problem : HTML labels
I read some issues where people want HTML tooltip and I have the same problem but I think it's out of the scope of this plugin. A callback or a way to get label positions could help solving this issue.
First Idea
Expose the "labels" offset position, something more accessible than :
chart.$datalabels._labels[1]._el.getCenterPoint()
Second Idea
Maybe a third parameter to the formatter that would give the anchor position (x, y) so it could be used as a starting point to build custom HTML label (with absolute positioning it could work)
datalabels: {
anchor: 'end',
align: 'top',
offset: 2,
backgroundColor: '#FFF',
borderRadius: 4,
formatter: function (data, chart, anchorposition) {
}
}
But it won't solve the resize problem :(
@Grafikart I agree, generating/manipulating DOM elements is out of the scope of this plugin.
About the "first idea", chart.$datalabels._labels[1]._el.getCenterPoint() is part of the internal/private API (see the "important" note on this page) so you shouldn't rely on it. The "second idea" can't work because label positions are not yet computed when calling the formatter (or any of the other options).
It would need a dedicated API to first query the label geometry, perform layout and finally call a method to position / draw each label. I marked this ticket as a feature request but I will probably not be able to work on it anytime soon.