0__ 0__ - 1 year ago 75
Java Question

Disable date-formatting for domain axis in JFreeChart when x-data is Long

I'm using an

) and the problem is the X-Axis is sample frames whose type is
, so I'm populating my
by calling
xyseries.add(long, double)
. The result is that JFreeChart automatically interprets the x-values as
instances, rendering them as something that looks like SMPTE time code:

enter image description here

Instead I want to show the X values as plain (integer number) sample frames. How can I tell the plot or the renderer to revert to default numeric formatting, leaving the
s as

Answer Source

ChartFactory.createXYStepChart() creates a DateAxis for the xAxis, as seen here. DateAxis interprets your long values as milliseconds since the epoch; it displays them as dates. You can either

  • Create a new NumberAxis and use it in a call to the plot's setDomainAxis() method.

  • Create your own factory method that instantiates NumberAxis directly; a related example is shown here.