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
Tick spacing on X axis
Re: Tick spacing on X axis
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.
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.
Re: Tick spacing on X axis
David:
I am working with Emile on this project. We are using createLineChart. Do you have a demo written for createXYChart? Thanks.
Jason
I am working with Emile on this project. We are using createLineChart. Do you have a demo written for createXYChart? Thanks.
Jason
Re: Tick spacing on X axis
Yes, I was using createLineChart(...). I will try the createXYChart(...).
Thanks,
Emile
Thanks,
Emile
Re: Tick spacing on X axis
I found the JFreeChartDemo that has an XYChart. I'll look at that.
Jason
Jason