0
votes

I have produce a code for a dynamic jfreechart and I want this chart to have Major grid lines and Secondary grid lines.

Is that possible to happen with jfreechart??

Thanks in advance!!!

EDIT:

Unfortunatelly I don't use XYplot but I use TimeSeries Chart like the following:

JFreeChart chart = ChartFactory.createTimeSeriesChart(
                       "Measurement",
                       "Date",
                       "Measurement",
                       dataset,
                       true,
                       true,
                       false);
2

2 Answers

3
votes

If you are using an XYPlot you can turn on the minor gridlines using:

  • XYPLot#setDomainMinorGridlinesVisible()

  • XYPLot#setRangeMinorGridlinesVisible()

as well as controlling the colour and line style, full details in the documentation

You are using an XYPLot, if you look at the source code for ChartFactory#createTimeSeriesChart() you will see that the 6th line is:

XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
-1
votes

This is the code I use:

 TimeSeries ts= new TimeSeries("Metrisi", Day.class);
     ts.add(new Day(day1, month1, year1), 100);
     ts.add(new Day(day2, month2, year2), 150);
     ts.add(new Day(day3, month3, year3), 250);
     ts.add(new Day(day4, month4, year4), 275);

     TimeSeriesCollection dataset = new TimeSeriesCollection();
 dataset.addSeries(ts);
 JFreeChart chart = ChartFactory.createTimeSeriesChart(
 "Measurement",
 "Date",
 "Measurement",
 dataset,
 true,
 true,
 false);

As a result when I create a TimeSeriesChart I don't have the ability to create major grid lines and secondary grid lines?