Line Chart - Adjusting padding for first/last tick marks

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
knlewis
Posts: 3
Joined: Fri Jun 28, 2013 5:00 pm
antibot: No, of course not.

Line Chart - Adjusting padding for first/last tick marks

Post by knlewis » Wed Feb 03, 2016 8:27 pm

Perhaps this has been answered already and I can't find what I need because I am searching incorrectly.

I am trying to create a graph like this one.

Image

I can't figure out what I need to adjust to make the LineChart domain plotting start on the x-axis as shown. How do I eliminate the padding in place before (and after) the first point is plotted? My graph looks like the one below:

Image

I suspect I might need create my own custom Axis (as I only want to adjust the spacing before the first tick mark and after the last) and that is fine. I'm just not sure what exactly in particular to change in there to achieve my end goal.

Thank you for any ideas!

Naxter
Posts: 45
Joined: Thu Jun 26, 2014 8:24 am
antibot: No, of course not.
Location: Germany, Aachen

Re: Line Chart - Adjusting padding for first/last tick marks

Post by Naxter » Thu Feb 04, 2016 8:34 am

Hey!

forget this, I thought you were using normal XYPlot.

Greetings
Last edited by Naxter on Thu Feb 04, 2016 2:34 pm, edited 1 time in total.

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

Re: Line Chart - Adjusting padding for first/last tick marks

Post by david.gilbert » Thu Feb 04, 2016 12:21 pm

You can set the lower and upper margins on the axis to 0.0, but you will still be left with half a category width at each end.

In a future release, I will probably add 'firstCategoryHalfWidth' and 'lastCategoryHalfWidth' flags to give some control over this (it's already done that way in Orson Charts), but for now there is no way to completely eliminate that gap unfortunately.
David Gilbert
JFreeChart Project Leader

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

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

Re: Line Chart - Adjusting padding for first/last tick marks

Post by david.gilbert » Thu Feb 04, 2016 12:25 pm

An alternative would be to switch to an XYPlot, then you can eliminate the margins but you would have to customise the formatting of the date axis.
David Gilbert
JFreeChart Project Leader

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

knlewis
Posts: 3
Joined: Fri Jun 28, 2013 5:00 pm
antibot: No, of course not.

Re: Line Chart - Adjusting padding for first/last tick marks

Post by knlewis » Thu Feb 04, 2016 4:39 pm

Thanks for the response.

I'll try the adjustment you suggested and see if they are OK with it before switching to an XYPlot. We actually have a graph already using an XYPlot has a look similar to what I want. That's why I thought it was possible with LineChart.

Now I can stop beating my head against the wall at least!

Thanks again!

Locked