Flex LineSeries - 沿曲线查找 y 值
我创建了一个 Flex LineChart,显示随时间变化的高潮和低潮预测。我使用带有 form="curve" 的 LineSeries,它会生成一个漂亮的正弦波图,代表一段时间内的水位。 X轴代表时间,Y轴代表水位。我必须处理的唯一数据点是高潮和低潮值,但我想弄清楚如何确定沿线任意 x 值的 y 值。
例如,假设我有以下数据点:
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 }
]);
这是我的折线图:
<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>
我想知道 2010 年 2 月 26 日 09:00 的 waterLevel
。
如果我能做到的话那就太酷了
var date:Date = new Date(2010, 1, 26, 9, 0);
var waterLevel:Number = lineSeries1.getYValue(date);
,但是可惜的是,getYValue(xValue)
函数不存在。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
LineSeries 的 interpolate 属性将填充第一个值和最后一个值之间的间隙。然而,从你的问题来看,你似乎正在寻求通过提前估计来延长曲线。在这种情况下插值将不起作用。
我建议找到一个合适的水位数据估计回归模型,并将其应用于曲线上的更多点。根据我有限的经验,我可以推荐一种依赖于加权数据点的模型,称为样条模型。然而,我不是统计学家,估计模型的建议可能是错误的。
The interpolate property of the LineSeries will fill in the gaps between the first and last values. However it seems by your question that you are seeking to extend the curve by estimating ahead. Interpolate will not work in this case.
I'd suggest finding a suitable regression model of estimation of Water Level data and apply it to derive more points on the curve. From my limited experience, I could recommend a model dependent on weighted data points called the Spline model. However I am not a statistician and might be wrong about the estimate model recommendation.
好吧,我明白了。只得回到十一年级的数学课。
对于任何好奇的人,这是我想出的函数:
如果高潮(或低潮)是
date1
的w1
个单位,并且接下来的低潮(或高潮)是w2
单位位于date2
,则以下函数给出date
处的水位w
。Ok, I figured it out. Just had to go back to 11th grade math class.
For anyone who's curious, here's the function I came up with:
If the high(or low) tide is
w1
units atdate1
and the following low(or high) tide isw2
units atdate2
, then the following function gives the water levelw
atdate
.