Moving markers
In a cartesian chart, I have four series, three line and one column series. I
want to show moving markers on all of the four series, when mouse is moved in
chart region. Moving markers like circle...
For that, I am using array of items which I have got through items property of
series object. and with the help of that array I am getting x and y
co-ordinates of each item.
I am then passing these co-ordinates to localToGlobal function on series
object to get global co-ordinates. After this, I am getting the item with
minimum diff between its co-ordinates and the point where mouse is.
But the thing is, I am not getting exact item at the place, where the mouse
is. For whole width of an item on X-axis, i am getting that item when the mouse
is at the middle of that width.
Here is the sample code.....
var arrSeries:Array=(ChartBase)(myPanel.getChildAt(1)) .series;
for(var i:int=0;i<arrSeries.length;i++)
{
var arrItem:Array=arrSeries[i].items;
var flag:int=-1;
var diff:int=100000000000;
for(var j:int=0;j<arrItem.length;j++)
{
arrItem[j].currentState="deselected";
}
for(var j:int=0;arrItem && j<arrItem.length;j++)
{
var p:Point =arrSeries[i].localToGlobal(new
Point(arrItem[j].x,arrItem[j].y));
if(diff>Math.abs(Math.ceil(p.x-event.currentTarget.mou*No thank you*)))
{
diff=Math.abs(Math.ceil(p.x-event.currentTarget.mou*No thank you*));
flag=j;
}
}
if(flag!=-1)
{
showValues(arrSeries[i].yField,arrItem[flag]);
arrItem[flag].currentState="selected";
}
}
|