I've created a Flex LineChart that shows high and low tide predictions over time. I'm using the LineSeries with form="curve", which produces a nice sinusoidal wave graph, representing water level over time. The X-axis represents time, and the Y-axis represents water level. The only data points I have to work with are high and low tide values, but I would like to figure out how to determine the y-values of arbitrary x-values along the line.
For example, let's say I have the following data points:
var highLowTidePredictions:ArrayCollection = new ArrayCollection( [
{ Date: new Date(2010, 1, 26, 7, 15), waterLevel: 20.3 },
{ Date: new Date(2010, 1, 26, 13, 15), waterLevel: -1.2 },
{ Date: new Date(2010, 1, 26, 19, 15), waterLevel: 19.0 },
{ Date: new Date(2010, 1, 27, 1, 15), waterLevel: -1.0 },
{ Date: new Date(2010, 1, 27, 7, 15), waterLevel: 18.7 },
{ Date: new Date(2010, 1, 27, 13, 15), waterLevel: 0.7 }
]);
Here's my Line Chart:
<mx:LineChart id="highLowLinePredictionsLineChart"
width="100%" height="100%"
dataProvider="{highLowTidePredictions}"
showDataTips="true">
<mx:horizontalAxis>
<mx:DateTimeAxis id="dta" />
</mx:horizontalAxis>
<mx:series>
<mx:LineSeries id="lineSeries1"
xField="Date" yField="waterLevel"
form="curve" interpolateValues="true" sortOnXField="true"/>
</mx:series>
</mx:LineChart>
And I want to know the waterLevel
on Feb 26, 2010 at 09:00.
It would be cool if I could do
var date:Date = new Date(2010, 1, 26, 9, 0);
var waterLevel:Number = lineSeries1.getYValue(date);
But alas, that getYValue(xValue)
function doesn't exist.