I want to generate a graph with horizantal axis has tick label in hh:mm mm/dd/yy format. I try to use BasicTimeSeries and createTimeSeriesChart. The graph just maked the horizatal axis with hh:mm like 19:02 19:10 ....
Am I doing something wrong?
Part of the code as below,
BasicTimeSeries series1 = new BasicTimeSeries("Test1", "Millisecond", "Value", FixedMillisecond.class);
Date now = new Date();
try {
series1.add(new FixedMillisecond(now.getTime()), new Double(50.1));
....
TimeSeriesCollection data = new TimeSeriesCollection();
data.addSeries(series1);
JFreeChart chart = ChartFactory.createTimeSeriesChart("IP Performace Report", "Time", "Kbps", data, true);
Your help is greatly appreciated.
Peter
TimeSeriesChart with tick hh:mm mm:dd:yy
Re: TimeSeriesChart with tick hh:mm mm:dd:yy
Hi,
Check this,
-----------------------------------------------------
XYPlot plot = (XYPlot)chart.getPlot();
HorizontalDateAxis ax = (HorizontalDateAxis)plt.getDomainAxis();
ax.setAutoTickUnitSelection(false);
ax.setTickUnit(new DateUnit(Calendar.SECOND, 1));
ax.getTickLabelFormatter().applyPattern(" MM/dd/yy HH:mm");
-----------------------------------------------------
regards,
reji
Check this,
-----------------------------------------------------
XYPlot plot = (XYPlot)chart.getPlot();
HorizontalDateAxis ax = (HorizontalDateAxis)plt.getDomainAxis();
ax.setAutoTickUnitSelection(false);
ax.setTickUnit(new DateUnit(Calendar.SECOND, 1));
ax.getTickLabelFormatter().applyPattern(" MM/dd/yy HH:mm");
-----------------------------------------------------
regards,
reji
Re: TimeSeriesChart with tick hh:mm mm:dd:yy
Reji,
It works! Thank you so much!
The problem now is that th tick label is too long. For the last tick very close to the right boundary of chart, the label is cut off. Something like this
| (left boundary) ................ (right boundary) |
02/26/02 19:
Is it possible to control this thing or make the label printed out in two line, such as
02/26/02
19:30
Thanks a lot for you help,
Peter
It works! Thank you so much!
The problem now is that th tick label is too long. For the last tick very close to the right boundary of chart, the label is cut off. Something like this
| (left boundary) ................ (right boundary) |
02/26/02 19:
Is it possible to control this thing or make the label printed out in two line, such as
02/26/02
19:30
Thanks a lot for you help,
Peter
Re: TimeSeriesChart with tick hh:mm mm:dd:yy
Peter,
You can plot the labels in vertical format..
try this
----------------------------------------------------
XYPlot plot = chart.getXYPlot();
HorizontalDateAxis axis = (HorizontalDateAxis)plot.getDomainAxis();
axis.setVerticalTickLabels(true);
----------------------------------------------------
Regards,
Reji
You can plot the labels in vertical format..
try this
----------------------------------------------------
XYPlot plot = chart.getXYPlot();
HorizontalDateAxis axis = (HorizontalDateAxis)plot.getDomainAxis();
axis.setVerticalTickLabels(true);
----------------------------------------------------
Regards,
Reji
Re: TimeSeriesChart with tick hh:mm mm:dd:yy
Peter,
I haven't tried to print horizontal axis labels in multi-lines. Lets hope somebody else will answer this problem..
regards,
Reji
I haven't tried to print horizontal axis labels in multi-lines. Lets hope somebody else will answer this problem..
regards,
Reji