I am currently graphing on the Time Series Chart by hours on the x-axis. So it starts from 0:00 and goes to 0:00 (or 24:00). When I graph my data it graphs the x-axis as Jan 1 - 0:00. I know that it's doing this because it is setting the default month and day, but is there anyway to clear out the Month and date and only have the time. In other words, what is the date format that I would have to send the DefaultXYDataSource constructor to hide the month and date. I want it where I can do both (month, date, year) and time. Thanks in advance for the help.
Regards,
Julio G.
Date Format
RE: Date Format
I'm still stuck on this one, can someone give me some hints....
thanks in advance,
julio
thanks in advance,
julio
RE: Date Format
I don't think you can pass some parameter to DefaultXYDataSource to accomplish this. The way I'm doing it is:
// Create your chart
JFreeChart chart = JFreeChart.createTimeSeriesChart(dataSource);
// Now set the axis' format
Plot plot = chart.getPlot();
DateAxis hAxis = (DateAxis)plot.getAxis(Plot.HORIZONTAL_AXIS);
SimpleDateFormat hAxisFormat = hAxis.getTickLabelFormatter();
fAxisFormat.applyPattern("H:m");
Hope this solves you problem.
[]'s
Daniel Serodio
// Create your chart
JFreeChart chart = JFreeChart.createTimeSeriesChart(dataSource);
// Now set the axis' format
Plot plot = chart.getPlot();
DateAxis hAxis = (DateAxis)plot.getAxis(Plot.HORIZONTAL_AXIS);
SimpleDateFormat hAxisFormat = hAxis.getTickLabelFormatter();
fAxisFormat.applyPattern("H:m");
Hope this solves you problem.
[]'s
Daniel Serodio
RE: Date Format
Well,
Thanks for the help, but it just didn't do the job. For some reason I guess it simply ignores it and keeps on displaying the time along with the month and day. The month and day are always "Jan 1" as if it knew those values were 0 but it still displayed them. If you have any other ideas I would greatly appreciate them.
thanx for the help,
julio
Thanks for the help, but it just didn't do the job. For some reason I guess it simply ignores it and keeps on displaying the time along with the month and day. The month and day are always "Jan 1" as if it knew those values were 0 but it still displayed them. If you have any other ideas I would greatly appreciate them.
thanx for the help,
julio
RE: Date Format
I see. I guess it's related to this bug: http://www.jrefinery.com/forums/read.ph ... =386&t=386
As far as I know, it's only a problem if you're using automatic tick values. If your tick values have a constant unit, eg, hourly ticks, you can use:
// Now set the axis' format
Plot plot = chart.getPlot();
DateAxis hAxis = (DateAxis)plot.getAxis(Plot.HORIZONTAL_AXIS);
hAxis.setAutoTickValue(false);
hAxis.setTickUnit(new DateUnit(Calendar.HOUR, 1)
SimpleDateFormat hAxisFormat = hAxis.getTickLabelFormatter();
fAxisFormat.applyPattern("H:m");
Please lemme know it this works.
[]'s
Daniel Serodio
As far as I know, it's only a problem if you're using automatic tick values. If your tick values have a constant unit, eg, hourly ticks, you can use:
// Now set the axis' format
Plot plot = chart.getPlot();
DateAxis hAxis = (DateAxis)plot.getAxis(Plot.HORIZONTAL_AXIS);
hAxis.setAutoTickValue(false);
hAxis.setTickUnit(new DateUnit(Calendar.HOUR, 1)
SimpleDateFormat hAxisFormat = hAxis.getTickLabelFormatter();
fAxisFormat.applyPattern("H:m");
Please lemme know it this works.
[]'s
Daniel Serodio
RE: Date Format
Daniel,
Thanks a million, that did the trick...i could not make it work until I looked at the actual Date Axis class and found out that Calendar.HOUR was not available, but HOUR_OF_DAY was. It works beautifully now....
thanks again,
Julio
Thanks a million, that did the trick...i could not make it work until I looked at the actual Date Axis class and found out that Calendar.HOUR was not available, but HOUR_OF_DAY was. It works beautifully now....
thanks again,
Julio