I have charts with a XYLineAndShapeRenderer, a XYPlot spannable and domain DateAxis with a fixedAutoRange which display the last hour.
When my higher value is not more in the last hour, the range axis reduces his size but I would like it doesn't do it in order to see all the values when I move on the domain DateAxis with the ctrl+click more easily (without waiting a refresh of the chart (all 1 minute in my case)).
Exemple:
If I have a value at 2 in the last hour and all others values to 0, the range axis go from 0 to 2 but when the 2 value is not more in the last hour the range axis only display the 0 value but I would like to keep my range range from 0 to 2.
Another possibility would be to auto-adjust range axis in real time when I move the chart on the domain axis with the ctrl-click.
My chart initializing:
Code: Select all
TimePeriodValues values = new TimePeriodValues("values");
TimePeriodValuesCollection dataset = new TimePeriodValuesCollection(values);
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
renderer.setBaseToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());
DateAxis domainAxis = new DateAxis("Time");
domainAxis.setFixedAutoRange(3600000);
domainAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm dd/MM"));
ValueAxis rangeAxis = new NumberAxis("Number");
XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, renderer);
plot.setDomainPannable(true);
JFreeChart chart = new JFreeChart("Chart", plot);
this.setLayout(new BorderLayout());
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setMouseZoomable(true, true);
this.add(chartPanel);