1

I have such like a live chart realized with JFreeChart. The x-axis shows the time and there are several TimeSeriesCollections in the chart. If the a value is added to the TimeSeries the charts updates and shows the value only if it is not zoomed. Is there a possibility in the zoomed mode to show automatically new values (means to keep the zoom range and jump to the right).

Thanks Oli

opfau
  • 731
  • 9
  • 37

1 Answers1

1

I found a possible solution:

this.chart.addChangeListener((ChartChangeEvent cce) -> {
        if (scrollToNewest) {
            Number max = DatasetUtilities.findMaximumDomainValue(this.plot.getDataset(0));
            ValueAxis va = this.plot.getDomainAxis();
            Range r = va.getRange();
            double curUpperBound = r.getUpperBound();
            double diff = max.doubleValue() - curUpperBound;
            Range newR = new Range(r.getLowerBound() + diff, r.getUpperBound() + diff);
            va.setRange(newR);
        }
    });
opfau
  • 731
  • 9
  • 37