"Push Left-Up" on chart; getting crosshair values

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
flink
Posts: 3
Joined: Mon Feb 13, 2006 12:01 pm
Location: Portugal
Contact:

"Push Left-Up" on chart; getting crosshair values

Post by flink » Mon Feb 13, 2006 12:22 pm

Hi!

Having just purchased the Developer guide (wich is very nicely written and I recommend to everyone that use JFreeChart), I finished the first charting phase of my application in two days. Thanks David! :)

All that is missing now is a couple of small things that bothers me: I have this beautiful, multicolored, multi-axis, multi-dataset chart working nicely. All axes are custom ranged. But when you zoom "backwards" on a chart (drag the mouse left and up for a bit), it defaults to reseting all my axes to autorange... how can I redraw the chart again as per the inicial settings/ranges when the user does that "backwards zoom"?

The second thing is actually solved. I just want to know if my solution is good or if it will break with the next release! :)
Thing is when you get the domain value from a crosshair on a timeSeries chart, it returns a positive number (the index on the series) if that (in my case) second has a value. Otherwise, it returns a number that is negative.
I want the crosshair to behave un-locked to the data, but to always return a value (the value immediatly before the crosshair's position in the series). I kind of saw a logic behind the numbering, and what I do is:

Code: Select all

					int itemIndex = timeSeries[k].getIndex( new Second(new Date(millis) ) );
					
					if (itemIndex < 0) // if this second does not have a value,
						itemIndex = (-itemIndex) - 2; // go to the second before it that does.

					try
					{
						if (itemIndex >= 0) 
						{
							TimeSeriesDataItem item = timeSeries[k].getDataItem( itemIndex );
							double y = item.getValue().doubleValue();          
							// do something with the value
So, I just get the last index that has a value... am I "cheating" here? Is there a better way to do it I have missed completely?

Thanks!
--
Oscar

flink
Posts: 3
Joined: Mon Feb 13, 2006 12:01 pm
Location: Portugal
Contact:

Post by flink » Fri Feb 17, 2006 4:12 pm

Can someone please help me with my first problem, please? I can't seem to find a simple way to do it...

Thanks!
--
Oscar

Locked