0

I'm trying to create a Timeseries chart in iReport 5.0.0 and want to remove the space between the Y axis and the lines in the graph, how would i do that?

I already have a Customizer class and have tried to thinker whit some of the values in it but to no luck. Any help much appreciated.

Added a datescale to the y axis and it seems like my first date is at 2011-06-30 but my x-axis starts att 2011-05-01 for som reason.

Robert
  • 29
  • 1
  • 12

2 Answers2

0

In your chart customizer, cast your plot to an XYPlot (or just call chart.getXYPlot()) and then call setAxisOffset on it. This method sets the gap between the axes and the plot. (javadoc here)

Removing the gap from the y-axis should be as simple as calling:

plot.setAxisOffset(new RectangleInsets(5.0, 0.0, 5.0, 5.0));

Removing all of the gaps can be done with:

plot.setAxisOffset(new RectangleInsets(0.0, 0.0, 0.0, 0.0));

or

plot.setAxisOffset(RectangleInsets.ZERO_INSETS);

Edit: By default, the plot will begin slightly before the first data point. If you want the data to begin immediately at the edge of the plot, call setMinimumDate on your date axis, setting it to the same value as the first point in your dataset.

GenericJon
  • 8,746
  • 4
  • 39
  • 50
  • Hi Jon and thanks for the answer. It looks a little better now but there is still a gap betwen the y axis and the line. Could it have something to to with the x axis? It seems like it shows dates for every 4th month so meaby it somehow pushes the shale wrong? For example Jul-2011, Oct-2011 and so on. – Robert Jul 31 '13 at 11:57
  • @user2556565, I have put in a quick edit to address your issue. – GenericJon Jul 31 '13 at 12:51
  • Thanks a million, that seemed to make the graph look alright. I added on last question above. After that I think I'm more than satisfied and will mark this question as resolved. – Robert Jul 31 '13 at 13:37
  • Think I will just open up a separate question for that question. Think this case is resolved. – Robert Aug 01 '13 at 07:30
0

The axis now works. I did this:

Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR,2011);
cal.set(Calendar.MONTH,05);
cal.set(Calendar.DAY_OF_MONTH,30);

java.util.Date d = cal.getTime();
domainAxis.setMinimumDate(d);

The above answer is resolved. I will also open up a new thread on how to get the first value in a series. But that will be a separate question.

Michael Myers
  • 188,989
  • 46
  • 291
  • 292
Robert
  • 29
  • 1
  • 12