September 3rd, 2007 by Kyle
Tags: charting, Flex, flex-charting, graphs, line-sensitivity, linerenderer, mouseout, mouseover, stroke
Posted in: Flex
I had a customer asking how he could make the lines in a LineSeries have a sensitivity to mouse proximity similar to the datapoints.
Here is what I came up with:
The essence of the solution was to extend the LineRenderer and draw an additional line with alpha=0, but of specified width, to the graphics object that the visible line is drawn on. That way mouse events will be dispatched by this line.
I figured the most logical place to specify the lineSensitivity attribute would be on the “Stroke” object, so I added that property to an extension of the Stroke class that I then access in my custom LineRenderer.
Here is the Stroke extension:
{
import mx.graphics.Stroke;
public class MyStroke extends Stroke
{
public function MyStroke(color:uint=0.0, weight:Number=0.0, alpha:Number=1.0, pixelHinting:Boolean=false, scaleMode:String="normal", caps:String=null, joints:String=null, miterLimit:Number=0.0)
{
super(color, weight, alpha, pixelHinting, scaleMode, caps, joints, miterLimit);
}
private var _lineSensitivity:Number=50;
[Inspectable(category="General")]
public function get lineSensitivity():Number
{
return _lineSensitivity;
}
/**
* @private
*/
public function set lineSensitivity(value:Number):void
{
_lineSensitivity = value;
}
}
}
No Comments »

Recent Comments