PDA

View Full Version : how to get xy-coordinates from axis



smkkiran
24 Jan 2012, 2:45 AM
is der any way to XY co-ordinates from a plotted chart why because i want to draw a box on scatter chart
can any one help me how to do

mitchellsimoens
24 Jan 2012, 11:38 AM
Like when you click or you need to get the XY coordinates of the chart itself?

smkkiran
24 Jan 2012, 9:29 PM
programically i want to get the x-coordinate or y coordinate for a mapping(value) to draw a line at that point

Goliaeth
12 Nov 2013, 9:27 AM
I'm also looking to do the same thing here. Based on clicking somewhere on the chart (not a series), I need to derive the relative xy coordinate. Any help would be appreciated.

Goliaeth
13 Nov 2013, 12:29 PM
After some tinkering, I wanted to answer my own question. I do not promise this is the best way to accomplish this.


var chart = Ext.create('Ext.chart.Chart', {
xtype: 'chart',
...
listeners: {
mouseup: function(e, eOpts) {

var yAxis = chart.axes.get(0);
var ySpread = yAxis.to - yAxis.from;
var yTickValue = ySpread / (yAxis.length + 2);

var yOffset = e.getY() - yAxis.axis.el.getY();
var yValue = yAxis.to - (yOffset * yTickValue);

var xAxis = chart.axes.get(1);
var xSpread = xAxis.to - xAxis.from;
var xTickValue = xSpread / (xAxis.length + 2);

var xOffset = e.getX() - xAxis.axis.el.getX() ;
var xValue = xAxis.from + (xOffset * xTickValue);

if(yOffset >= 0 && yOffset < (yAxis.length + 3) && xOffset >= 0 && xOffset < (xAxis.length + 3)) {
// Do required with xValue & yValue
}
}
},
...