-
25 Oct 2012 8:24 AM #1
Unanswered: Best way to get a series screen X, Y for a certain value on the series?
Unanswered: Best way to get a series screen X, Y for a certain value on the series?
I'm working on implementing my own popup hint interaction (a lot more fancy than the ItemInfo one). I can get the screen X, Y from the gesture event using the event.pageX and event.pageY. I want to pop up a hint with a callout pointing to the point on the series. Unfortunately, pageX and pageY might be a few pixels off because you can click near the series point and not exactly on it.
So what I need to do is find what the ACTUAL series X, Y (in screen coordinates) are for a given X value in a series. Is there a way to do this? I'm digging around in the sprite code and thinking I may be finding undocumented ways to do this. But I'd prefer a way that's the most stable and doesn't rely on the guts of the code.
Any suggestions?
-
26 Oct 2012 12:50 PM #2
Here's how I wound up doing it. Would still not mind hearing if there's a better "official" way so I'm leaving this with no answer marked.
This is code in the gesture event for an interaction:
Code:var item = this.getItemForEvent(e); if (item) { var chart = this.getChart(); var chartRegion = chart.getMainRegion(); var clientCoords = item.sprite.attr.matrix.transformPoint([ item.series.getXAxis().getCoordFor(item.record.get(item.series.getXField())), item.series.getYAxis().getCoordFor(item.record.get(item.field)) ]); var chartXY = chart.element.getXY(); var seriesScreenX = clientCoords[0] + chartXY[0] + chartRegion[0]; var seriesScreenY = chartRegion[3] - clientCoords[1] + chartXY[1] + chartRegion[1];
-
1 Nov 2012 6:59 AM #3
Fixed the above so it works with category axes as well.


Reply With Quote