How can I get the maximal visible value?
-
- Posts: 4
- Joined: Wed Nov 19, 2003 6:39 pm
How can I get the maximal visible value?
I want to automatically resize my y-axis depending on the values displayed (setAutoRange(true) will not work).
Expanding the rage work fine. I want reduce the axis length, if the last value is 70% of the maximal visible value. But I cannot find a way to get the max. visible value for calculating a minor value for y-axis.
Any idea?
Expanding the rage work fine. I want reduce the axis length, if the last value is 70% of the maximal visible value. But I cannot find a way to get the max. visible value for calculating a minor value for y-axis.
Any idea?
Reduce Y-Axis length
Hi,
Try using the following code to reduce the axis length
Hope this is of help to you.
regards,
Kartik
Try using the following code to reduce the axis length
Code: Select all
CategoryPlot plot = chart.getCategoryPlot();
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
Range rangeData = rangeAxis.getRange();
rangeData = new Range(rangeData.getLowerBound(),rangeData.getUpperBound());
rangeAxis.setRange(rangeData);
regards,
Kartik
-
- Posts: 4
- Joined: Wed Nov 19, 2003 6:39 pm
Re: Reduce Y-Axis length
Kartik,
unfortunately not. I tried upperBound() before. But it seems to return the upperBound of all values. Not only the visible values. I think it will than work, if I can delete the values not visible in my dataset. But
a) I don't know how to do it. I use a TimeSeriesCollection and there is no delete method and no repace method I also searched to reduce my datapoints.
b) Later I will support a different mode with scrollbar, so there I need the older values.
Did you or anyone else another possibility? I used to track it by my own, but it is always correct, because I don't know the real timeframe actually displayed.
unfortunately not. I tried upperBound() before. But it seems to return the upperBound of all values. Not only the visible values. I think it will than work, if I can delete the values not visible in my dataset. But
a) I don't know how to do it. I use a TimeSeriesCollection and there is no delete method and no repace method I also searched to reduce my datapoints.
b) Later I will support a different mode with scrollbar, so there I need the older values.
Did you or anyone else another possibility? I used to track it by my own, but it is always correct, because I don't know the real timeframe actually displayed.
Theoretic it could work with:
but the call doesn't work. For the horizontal axist it work. I use it there for unzooming.
So I do it now outside with my onw tracking. It works, but it could be better if it would be integrated in jFreeChart, or if I can get the maximum value of the drawn values.
Code: Select all
chartPanel.autoRangeVertical()
So I do it now outside with my onw tracking. It works, but it could be better if it would be integrated in jFreeChart, or if I can get the maximum value of the drawn values.
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
At the moment there is no support in JFreeChart for obtaining the range of values for the visible points only. That is something that I want to introduce (at least for time series charts) to make it easier to work with large time series (for example, you might want to plot the most recent 3 months of a 10 year time series). It is on the to-do list, but I have no idea when I will get to it...
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Great! I have also seen your patch re: tooltips which sounds like a good idea, I just haven't had time to look closely at it yet.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


Replaceing last value of a time series
That's greatkingguppy wrote:I've implemented this, it's one of the many patches
I'll be submitting soon.

Also very useful and not too much too implement - I think - will be a possibility to replace a value - espeacially the last - with a new value. Or much better only with a new time.
Background:
I have a dynamic chart. To update the time I have to add a new value to the same value and the new time. In this way I get a lot of not needed values. Espeacially, if user choose a short update time. It will be much better, if I had the possibility to change the timestap of the last value. In this case, the time will go on and I don't need to blow up my collection.
roadrunner
-
- Posts: 4
- Joined: Wed Nov 19, 2003 6:39 pm
Workaround
I did the following workaround (if someone will help this):
calculates vertical range:
Gets the actual timerange for the x-axis
calculates vertical range:
Code: Select all
public void checkVerticalBounds() {
try {
long time = getDataset().getTime();
if(time-fBoundcheckStarttime > getVisibleTimeRange()) {
int seriesCount = getDataset().getSeriesCount();
for (int series = 0; series < seriesCount; series++) {
// Falls noch nicht initialisiert
if(fMaxValues[0][series]==0) {
fMaxValues[0][series]=fMaxValues[1][series];
}
if(fMaxValues[0][series]*0.7 > fMaxValues[1][series] && fMaxValues[1][series] > 0) { // neuer Wert kleiner 70% des alten Höchstwertes
fValueAxis[series].setRange(0, fMaxValues[1][series]*1.1); // Anzeigenhöhe verkleinern
}
// reinit maxValueSammler
fMaxValues[0][series] = fMaxValues[1][series]; // neuer maxValue
fMaxValues[1][series] = 0; // Sammler rücksetzen
}
fBoundcheckStarttime=getDataset().getTime();
}
} catch (Exception e) {
System.err.println("Excep");e.printStackTrace();
}
}
Gets the actual timerange for the x-axis
Code: Select all
private long getVisibleTimeRange() {
if (fVisibleTimeRange == 0) {
fVisibleTimeRange = 60000; // 60 secunden
}
return fVisibleTimeRange;
}