Custom Tick Units

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Mich
Posts: 9
Joined: Mon Nov 09, 2009 2:33 pm
antibot: No, of course not.

Custom Tick Units

Post by Mich » Mon Nov 09, 2009 2:39 pm

Hi all,

it's possible to use custom tick units?

I have seen it is possibile to set a unit interval, and also to set user-defined tick units (the problem is that only the smallest one is used).

My Problem is the following: I have some values on the x-axis, for example:
  • 1,2,3,4,5,6,7,8,9,10
and I want to display on the x-axis only the units for:
  • 4,7,9
some suggestion? Thx in advance

Mich
Posts: 9
Joined: Mon Nov 09, 2009 2:33 pm
antibot: No, of course not.

Re: Custom Tick Units

Post by Mich » Wed Nov 11, 2009 9:02 am

I have to override the method ValueAxis.drawTickMarkAndLabels?

matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: Custom Tick Units

Post by matinh » Wed Nov 11, 2009 12:18 pm

Better use the setStandardTickUnits() method.

- martin

Mich
Posts: 9
Joined: Mon Nov 09, 2009 2:33 pm
antibot: No, of course not.

Re: Custom Tick Units

Post by Mich » Wed Nov 11, 2009 12:22 pm

thx for the answer.

I have already tried, but if I do

Code: Select all

TickUnits units = new TickUnits();
units.add(new NumberTickUnit(4, myNumberFormat));
units.add(new NumberTickUnit(7, myNumberFormat));
units.add(new NumberTickUnit(9, myNumberFormat));
		
da.setStandardTickUnits(units);
I see the point: 4,8,...

and not a custom set of points

sawong
Posts: 1
Joined: Wed Nov 11, 2009 8:24 pm
antibot: No, of course not.

Re: Custom Tick Units

Post by sawong » Wed Nov 11, 2009 8:27 pm

Subclass the axis and override the refreshTicks() method - you can return any combination of ticks that you want.

See http://www.jfree.org/phpBB2/viewtopic.p ... ick#p79591

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

Re: Custom Tick Units

Post by david.gilbert » Wed Nov 11, 2009 10:43 pm

You have found the correct approach (overriding refreshTicks()). Thanks for posting the follow-up.
David Gilbert
JFreeChart Project Leader

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

nasr25
Posts: 8
Joined: Mon Jun 15, 2015 6:01 am
antibot: No, of course not.

Re: Custom Tick Units

Post by nasr25 » Wed Dec 21, 2016 6:44 am

can anyone give me more hint or some code how can i do it ?

please

Locked