Custom symbol axis

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Leprechaunius
Posts: 1
Joined: Sun Mar 23, 2014 10:13 pm
antibot: No, of course not.

Custom symbol axis

Post by Leprechaunius » Sun Mar 23, 2014 10:25 pm

Hi, I am plotting frequency in Hz, using the TimeSeriesChart. So far so good. But I need to add a second Y (value) axis that would represent musical tones. I need the ticks to be represented by String values (C#9,A4 and so on), so I figured out I should use SymbolAxis. The problem is I need to map the string tick values to exact number values, such as:
A4->440, A#4->466.164, B4->493.883, C5 ->523.251..... So it won't be linear nor logarithmic. How can I do that? Thanks.

(v1.0.17)

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

Re: Custom symbol axis

Post by david.gilbert » Mon Mar 24, 2014 7:11 am

I think SymbolAxis won't work for you, because it is coded to convert integer values to symbols. What you should do is subclass NumberAxis and override just this method:

Code: Select all

public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge)
David Gilbert
JFreeChart Project Leader

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

Locked