AreaChart - Y Axis Category Display

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Raghu

AreaChart - Y Axis Category Display

Post by Raghu » Tue Nov 26, 2002 4:19 pm

Hello all,

I am using JFreeChart to draw graphs in my servlet. The servlet plots a stacked line chart with Time in the X axis and traffic (kb/s) in the Y Axis. I pick up data from the database for a day, time varying every 5 mins. Which means that the X Axis will have a plot for every 5 mins for the whole 24 hours. Which means 24*30 points which makes the X axis very clumsy and not readable.

My requirement is that the X axis must show labels for every 30 mins (which means 48 labels for a day) but the graph must still plot points for every 5 mins. If anybody has come across a similar situation, pls help me.

Thanx in advance

Regards,
Raghu

Dave Gilbert

Re: AreaChart - Y Axis Category Display

Post by Dave Gilbert » Wed Nov 27, 2002 1:27 pm

The tick units on the axis, and the values in your dataset are independent. So you can either leave the axis to 'auto-select' an appropriate tick unit (it tries to display as many labels as possible without any overlaps) or manually set whatever unit you want:

XYPlot plot = myChart.getXYPlot();
DateAxis axis = (DateAxis) plot.getDomainAxis();
DateTickUnit unit = new DateTickUnit(DateTickUnit.MINUTE, 30);
axis.setTickUnit(unit);

Regards,

Locked