Thanks a lot. Where did you get the original LineSeries code? All I have is the swc file...
On Fri, Nov 21, 2008 at 10:20 PM, Brendan Meutzner <[EMAIL PROTECTED]>wrote: > package range_charts.extended_series > { > import mx.charts.HitData; > import mx.charts.chartClasses.CartesianTransform; > import mx.charts.series.LineSeries; > import mx.charts.series.items.LineSeriesItem; > import mx.graphics.IStroke; > import mx.graphics.LinearGradientStroke; > import mx.graphics.Stroke; > > public class CustomLineSeries extends LineSeries > { > override public function > findDataPoints(x:Number,y:Number,sensitivity:Number):Array > { > // esg, 8/7/06: if your mouse is over a series when it gets added > and displayed for the first time, this can get called > // before updateData, and before and render data is constructed. > The right long term fix is to make sure a stubbed out > // render data is _always_ present, but that's a little disruptive > right now. > if (interactive == false || !renderData) > return []; > var pr:Number = getStyle("radius"); > var minDist2:Number = pr + sensitivity; > minDist2 *= minDist2; > var minItem:LineSeriesItem = null; > var pr2:Number = pr * pr; > > var len:int = renderData.filteredCache.length; > if (len == 0) > return []; > if(sortOnXField == true) > { > var low:Number = 0; > var high:Number = len; > var cur:Number = Math.floor((low+high)/2); > > var bFirstIsNaN:Boolean = isNaN(renderData.filteredCache[0]); > > while (true) > { > var v:LineSeriesItem = renderData.filteredCache[cur]; > if (!isNaN(v.yFilter) && !isNaN(v.xFilter)) > { > //var dist:Number = (v.x - x)*(v.x - x) + (v.y - > y)*(v.y -y); > var dist:Number = (v.x - x)*(v.x - x) ; > if (dist <= minDist2) > { > minDist2 = dist; > minItem = v; > } > } > > if (v.x < x || (isNaN(v.x) && bFirstIsNaN)) > { > low = cur; > cur = Math.floor((low + high)/2); > if (cur == low) > break; > } > else > { > high = cur; > cur = Math.floor((low + high)/2); > if (cur == high) > break; > } > } > } > else > { > var i:uint; > for (i=0;i<len;i++) > { > v = renderData.filteredCache[i]; > if (!isNaN(v.yFilter) && !isNaN(v.xFilter)) > { > //dist = (v.x - x)*(v.x - x) + (v.y - y)*(v.y -y); > dist = (v.x - x)*(v.x - x) ; > if (dist <= minDist2) > { > minDist2 = dist; > minItem = v; > } > } > } > } > > if (minItem) > { > var hd:HitData = new > HitData(createDataID(minItem.index),Math.sqrt(minDist2),minItem.x,minItem.y,minItem); > var istroke:IStroke = getStyle("lineStroke"); > if (istroke is Stroke) > hd.contextColor = Stroke(istroke).color; > else if (istroke is LinearGradientStroke) > { > var gb:LinearGradientStroke = > LinearGradientStroke(istroke); > if (gb.entries.length > 0) > hd.contextColor = gb.entries[0].color; > } > hd.dataTipFunction = formatDataTip; > return [ hd ]; > } > return []; > } > > > private function formatDataTip(hd:HitData):String > { > var dt:String = ""; > > var n:String = displayName; > if (n && n != "") > dt += "<b>" + n + "</b><BR/>"; > var xName:String = > dataTransform.getAxis(CartesianTransform.HORIZONTAL_AXIS).displayName; > if (xName != "") > dt += "<i>" + xName+ ":</i> "; > dt += > dataTransform.getAxis(CartesianTransform.HORIZONTAL_AXIS).formatForScreen( > LineSeriesItem(hd.chartItem).xValue) + "\n"; > > var yName:String = > dataTransform.getAxis(CartesianTransform.VERTICAL_AXIS).displayName; > if (yName != "") > dt += "<i>" + yName + ":</i> "; > dt += > dataTransform.getAxis(CartesianTransform.VERTICAL_AXIS).formatForScreen( > LineSeriesItem(hd.chartItem).yValue) + "\n"; > > return dt; > } > > > } > } > > > > <custom_series:CustomLineSeries id="baseSeries" name="Reading Value" > xField="readingDate" yField="reading" displayName="Reading Value" > stroke="{new Stroke(0xFF0000, 0)}" > fill="{new SolidColor(0xFF0000, 0.6)}" lineStroke="{new > Stroke(0xFF0000, 1)}" form="curve" interpolateValues="false" > lineSegmentRenderer="mx.charts.renderers.LineRenderer" > radius="2" > /> > > > > > > On Fri, Nov 21, 2008 at 1:48 PM, Sefi Ninio <[EMAIL PROTECTED]> wrote: > >> Hi Brendan, >> >> Could you maybe paste your implementation of the extending class? >> >> Thanks, >> Sefi >> >> On Fri, Nov 21, 2008 at 8:41 PM, Sefi Ninio <[EMAIL PROTECTED]> wrote: >> >>> Hi Brendan >>> >>> Thanks for the reply, I'll give it a try. >>> >>> Sefi >>> >>> >>> On Fri, Nov 21, 2008 at 6:34 PM, Brendan Meutzner <[EMAIL PROTECTED]>wrote: >>> >>>> Claude Hussenet has come up with a solution for this. Here's the >>>> past post. >>>> >>>> http://tech.groups.yahoo.com/group/flexcoders/message/90045 >>>> >>>> I've used and it works great. >>>> >>>> >>>> Brendan >>>> >>>> >>>> >>>> On Fri, Nov 21, 2008 at 4:56 AM, Sefi Ninio <[EMAIL PROTECTED]>wrote: >>>> >>>>> Hey, >>>>> >>>>> I have a chart set up and using dataTipFunction to format the datatips. >>>>> It works great. >>>>> However, what I'd really like, is to display the datatips for all the >>>>> series for the current x axis value the mouse pointer is over (and only >>>>> those). >>>>> Example: if the mouse pointer is over x value 10, and I have 3 line >>>>> series in that chart, then all 3 points correlating to x value 10 will >>>>> have >>>>> their datatips visible. >>>>> >>>>> There are a few issues with this: >>>>> 1. I don't have an easy way to translate mouse pointer location on >>>>> mouse over to the relevant x axis value. >>>>> 2. Once I (hopefully) get the x value, I'd also have to have all y >>>>> values for the series (relatively simple). >>>>> 3. If I get here, I'll have to think of a way to cause the points to >>>>> show their datatip and ofcourse clear all previous open datatips... >>>>> >>>>> any ideas on either of those points? >>>>> >>>>> Thanks, >>>>> Sefi >>>>> >>>>> >>>> >>>> >>>> -- >>>> Brendan Meutzner >>>> http://www.meutzner.com/blog/ >>>> >>> >>> >> > > > -- > Brendan Meutzner > http://www.meutzner.com/blog/ > >