Do not show the tick mark when no data

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
lukkumar
Posts: 17
Joined: Thu Jun 07, 2007 8:10 pm

Do not show the tick mark when no data

Post by lukkumar » Thu Jul 19, 2007 10:37 pm

Hi,
I have used the XYPlot to plot a StackedXYBarRenderer and I observed that the tick marks were visible even when there is no data. I would like to have the tick marks visible on X-axis only when there is data. How to achieve this.
I know this sounds simple but, I need to know to which flag of a method should I set this option.

Thanks,
Laks.

potterd64
Posts: 13
Joined: Fri Aug 18, 2006 7:54 pm

Post by potterd64 » Fri Jul 20, 2007 12:39 am

you can hide ticks like this.

p.getDomainAxis(0).setTickLabelsVisible(false);
p.getDomainAxis(0).setTickMarksVisible(false);

where p is your plot.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Fri Jul 20, 2007 9:54 am

You can hide the tick marks as the previous poster suggested, but there isn't a way to make this happen automatically just when there is no data.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

lukkumar
Posts: 17
Joined: Thu Jun 07, 2007 8:10 pm

Post by lukkumar » Fri Jul 20, 2007 4:21 pm

Hi,
Thanks for the reply. Is it possible to show the labels on the X axis only when there is data at that point, because it does not look good to show a label there and no data is available for that point...

Thanks.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Fri Jul 20, 2007 5:31 pm

You could subclass the axis and override refreshTicks().
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked