Customize x axis

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
ardlema
Posts: 1
Joined: Thu Jan 22, 2015 1:36 pm
antibot: No, of course not.

Customize x axis

Post by ardlema » Thu Jan 22, 2015 1:43 pm

Hi all,

I have created a XYLineChart graphic which shows values for all the hours of the days of one week (168 values). My x-axis shows values from 0 to 168 and I would like to show the hours of the day: 0, 1, 2...23, 0, 1, 2...23...0...23

Is there any easy way to achieve that? I have been looking for a while within the phorum but no luck so far. I have also tried to set the number format override defining my own DecimalFormat but it does not work (I am using Scala by the way):

xAxis.setNumberFormatOverride(new DecimalFormat() {
override def format(number: Double, toAppendTo: StringBuffer, pos: FieldPosition): StringBuffer = {
toAppendTo.append((number / 24).toInt)
}
})

Any help would be greatly appreciated.

Thank you in advance.

Locked