Re: [flexcoders] Getting the Y value for a line at a given point

2010-01-01 Thread Aaron Hardy
Have you tried something this: 100+(15/39)*(140-100)

100 being Jan 1 balance
140 being Feb 8 balance
15 being the number of days from the first data provider date point
39 being the total number of days between the first and second data 
provider date points

That should give you the y balance for the widget.

Aaron

Ryan wrote:

 I've got a line chart showing a dollar value over time. Think of it as 
 the balance of a savings account. It goes up and down every month or 
 so. What I'm trying to do is overlay little widgets on top of that 
 line on the chart to represent events that may or may not have 
 affected the line's value. This is actually similar to the Yahoo 
 Finance stock chart with the event overlays.

 Anyway, it's easy enough to add a CartesianDataCanvas as an annotation 
 element to my line chart and then add children to it. It has a nice 
 little addDataChild method that allows you to specify an x axis value 
 and a y axis value and it figures out what the corresponding x and y 
 coordinates are and places the child there. Great so far.

 Say my line series data provider looks like this:
 {date:new Date(2009, 1, 1), balance:100}
 {date:new Date(2009, 2, 8), balance:140}
 {date:new Date(2009, 3, 5), balance:95}

 If I have an event for 1/1/2009, I can look up that the balance was 
 100 on that day and place the event widget at [1/1/2009, 100]. 
 However, if I have an event on 1/15/2009, from looking at the data 
 provider above, I know that the balance was still 100, but because the 
 line is diagonally vectoring towards the next value of 140, my data 
 point is misplaced if I put it at [1/15/2009, 100].

 Is there a way to get the line's y value given an x value?
 or
 Can I change my line chart to not draw diagonal lines and instead draw 
 square lines so I won't have this problem?

 Ryan

 





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Alternative FAQ location: 
https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! 
Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* Your email settings:
Individual Email | Traditional

* To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)

* To change settings via email:
flexcoders-dig...@yahoogroups.com 
flexcoders-fullfeatu...@yahoogroups.com

* To unsubscribe from this group, send an email to:
flexcoders-unsubscr...@yahoogroups.com

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/



[flexcoders] Getting the Y value for a line at a given point

2009-12-30 Thread Ryan
I've got a line chart showing a dollar value over time. Think of it as the 
balance of a savings account. It goes up and down every month or so. What I'm 
trying to do is overlay little widgets on top of that line on the chart to 
represent events that may or may not have affected the line's value. This is 
actually similar to the Yahoo Finance stock chart with the event overlays. 

Anyway, it's easy enough to add a CartesianDataCanvas as an annotation element 
to my line chart and then add children to it. It has a nice little addDataChild 
method that allows you to specify an x axis value and a y axis value and it 
figures out what the corresponding x and y coordinates are and places the child 
there. Great so far. 

Say my line series data provider looks like this:
{date:new Date(2009, 1, 1), balance:100}
{date:new Date(2009, 2, 8), balance:140}
{date:new Date(2009, 3, 5), balance:95}

If I have an event for 1/1/2009, I can look up that the balance was 100 on that 
day and place the event widget at [1/1/2009, 100]. However, if I have an event 
on 1/15/2009, from looking at the data provider above, I know that the balance 
was still 100, but because the line is diagonally vectoring towards the next 
value of 140, my data point is misplaced if I put it at [1/15/2009, 100]. 

Is there a way to get the line's y value given an x value?
or
Can I change my line chart to not draw diagonal lines and instead draw square 
lines so I won't have this problem?

Ryan