Show majorAxis at the end of NumberAxis

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
plunavat
Posts: 29
Joined: Sun Jan 01, 2012 10:59 am
antibot: No, of course not.

Show majorAxis at the end of NumberAxis

Post by plunavat » Wed Aug 14, 2019 3:11 pm

Hello,

We have plotted XYPlot with Domain and Range Axis as Number Axis with AutoRangeIncludesZero(true).
The issue is that we want to extend the axis to contain majoraxis at the end

Image

In the attached image the in first graph the Range axis should automatically go till 50, the second graph is ok and third graph should go till 75
same with domain axis, it should go till 32.5

How can we do this with AutoRange as the dataset would be dynamic

Thanks & Regards,
Pranav C Lunavat

daress
Posts: 23
Joined: Tue Mar 13, 2007 4:52 pm
Contact:

Re: Show majorAxis at the end of NumberAxis

Post by daress » Fri Aug 16, 2019 3:15 pm

Tag!

Since you are having a constrained, dynamic XYPlot, I would recommend turning off auto range includes zero (set it to false), and instead manually set the range on the NumberAxis.

Since you want to always include zero, create the plot, obtain the range of the axis you want to modify, set the lower bound to 0, and the upper bound to whatever you compute it to be (for the first plot, you may want to always round up to the nearest increment of 10, ie the 43 on the first plot would become 50.

David

plunavat
Posts: 29
Joined: Sun Jan 01, 2012 10:59 am
antibot: No, of course not.

Re: Show majorAxis at the end of NumberAxis

Post by plunavat » Mon Aug 19, 2019 6:45 am

Hello David,

Thanks for the reply.
The graphs are created dynamically and hence I would like to go by AutoRange.
My only requirement is that the max end of the axis should always display the value as its a standard norms. Currently (attached image in original post) it doesn't show. Whether this can be achieved automatically or I'll have to do it manually as suggested by you

dgarratt
Posts: 8
Joined: Mon Aug 19, 2019 7:29 pm
antibot: No, of course not.

Re: Show majorAxis at the end of NumberAxis

Post by dgarratt » Mon Aug 19, 2019 9:18 pm

Sorry to ask a question rather than post an answer. How did you get the value plot points to appear as dots on the red line ?

The API is very complex and I'm making very slow progress

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: Show majorAxis at the end of NumberAxis

Post by John Matthews » Tue Aug 20, 2019 3:55 am

Also look at DatasetUtils methods that iterate over the items in an XYDataset to find the bounds.

Locked