How show less values in the X-axis in line chart (JFreechart)?
Asked Answered
F

0

0

How can I do in order to show less values ​​on the X axis, to get the data organized?

However I want the values ​​are all shown. One idea I had was to use the zoom so you can see all the records, but do not know if it was a good idea, or rather do not even know it.

As you can see in the picture my idea is that data more legible, in order to realize the best of everything.

Does anyone can help me please?

//Code with result from query and chart create

String query="select (CONCAT(`date`, ' ', hour)),  temperature from records where idTermomether like 'T1' and date between '2014-06-01' and '2014-06-03'";
            JDBCCategoryDataset dataset = new JDBCCategoryDataset (CriaConexao.getConexao(),query);
            JFreeChart chart = ChartFactory.createLineChart(" - Temperature", "Date", "Temperature", dataset, PlotOrientation.VERTICAL, false, true, true);
            BarRenderer renderer = null;
            CategoryPlot plot= chart.getCategoryPlot();
            CategoryAxis xAxis=(CategoryAxis)plot.getDomainAxis();
            xAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
            renderer=new BarRenderer();
            ChartFrame frame = new ChartFrame("Temperature", chart);
            frame.setVisible(true);
            frame.setSize(400,650);

enter image description here

Furmenty answered 20/6, 2014 at 14:45 Comment(2)
don't use categoryplot, but something like that where there's date and time? #21299596Tanker
Marian is correct, you should not use a CategoryPlot when your x-axis is displaying values or dates - use an XYPlot instead, with a DateAxis. If you want to use a method from the ChartFactory to create your chart, then createTimeSeriesChart() is probably the best choice. This also means you will need to change the dataset object that you use.Terrel

© 2022 - 2024 — McMap. All rights reserved.