Tick spacing on X axis

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

Tick spacing on X axis

Post by Emile Nelson » Wed May 15, 2002 11:30 pm

How do you space the ticks on an X Axis in a line chart. We have a line chart that has 100 points and the tick number 1 - 100 is printed at the bottom of the X Axis. How do I skip some of the ticks for example instead of getting 1, 2, 3, 4...100 along the X Axis, I would prefer getting 1, 10, 20, ... 100 thereby allowing the values to be visible instead of bunched together.

Emile Nelson

David Gilbert

Re: Tick spacing on X axis

Post by David Gilbert » Thu May 16, 2002 6:09 am

Hi Emile,

Are you using createLineChart(...) in the ChartFactory class? This is intended for charts where the x-axis represents categories, so there is no general facility for dropping ticks from the axis.

For numerical x-data, you should use createXYChart(...), this will use an x-axis where the tick labels auto-adjust. The chart is based on data from the XYDataset interface rather than the CategoryDataset interface, so you'll have to change the way you set up your data. There are a couple of implementations of the XYDataset interface - XYSeriesCollection and TimeSeriesCollection are the best - or you can write your own if your data is already in some other datastructure.

Regards,

DG.

Jasom Bram

Re: Tick spacing on X axis

Post by Jasom Bram » Thu May 16, 2002 9:08 pm

David:

I am working with Emile on this project. We are using createLineChart. Do you have a demo written for createXYChart? Thanks.

Jason

Emile Nelson

Re: Tick spacing on X axis

Post by Emile Nelson » Thu May 16, 2002 9:27 pm

Yes, I was using createLineChart(...). I will try the createXYChart(...).

Thanks,

Emile

Jason Bram

Re: Tick spacing on X axis

Post by Jason Bram » Thu May 16, 2002 9:59 pm

I found the JFreeChartDemo that has an XYChart. I'll look at that.

Jason

Locked