Problem Description
Xmin and max values :
scalaMinX= - 7207
scalaMaxX= 27506
dimX=10
I draw the axis using the following sequence
......
NumberAxis domainAxis_x = (NumberAxis) plot.getDomainAxis();
domainAxis_x.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
domainAxis_x.setRange(new Range(scalaMinX, scalaMaxX));
domainAxis_x.setFixedAutoRange(scalaMaxX - scalaMinX);
domainAxis_x.setAutoRangeIncludesZero(false);
domainAxis_x.setTickUnit(new NumberTickUnit((scalaMaxX - scalaMinX) / dimX));
The result is to have an axis with the first tick positioned not at the beginning of the axis with the value of -6942.6 but some pixel right.
It seems the jfreechart compute the delta tick starting from 0 (negative and positive) and not from the lower value.
What I want is to obtain a X axis with the first tick positioned at the beginning of the axis labeled with -7207 and the subsequents tick positioned at the delta value of ((scalaMaxX-scalaMinx)/dimX) .
How can I obtain that ?
Thanks in advance
[/img]
Starting X Axis with tick and negative value
To be more clear
Xmax=27506
Xmin=-7207
Delta Tick=(27506+7207)/10=3471.3
I expected to obtain a graphics with the X scale drawed like the following:
0
!---------------!-------------!--------------!-------------!
-7207.......-3753.7.....-264.4........3206.9......6678.2
but I obtain the following with the an extra minor tick just few pixel
right the axis start.
0
!--!------------!-------------!--------------!-------------!
-6942.6....-3471.3.........0...........3471.3........6942.6
Why ?
It seems jfreechart compute the ticks starting from 0 (positive and negative). The value of 6942.6 is correct but the real min value of the
X axis is not printed. How can I obtain the scale as above with the axis
starting with ticks from the beginning of the axis (without the extra tick added just after the beginning) and with the effective min value of -7207 printed ?
Thanks
Xmax=27506
Xmin=-7207
Delta Tick=(27506+7207)/10=3471.3
I expected to obtain a graphics with the X scale drawed like the following:
0
!---------------!-------------!--------------!-------------!
-7207.......-3753.7.....-264.4........3206.9......6678.2
but I obtain the following with the an extra minor tick just few pixel
right the axis start.
0
!--!------------!-------------!--------------!-------------!
-6942.6....-3471.3.........0...........3471.3........6942.6
Why ?
It seems jfreechart compute the ticks starting from 0 (positive and negative). The value of 6942.6 is correct but the real min value of the
X axis is not printed. How can I obtain the scale as above with the axis
starting with ticks from the beginning of the axis (without the extra tick added just after the beginning) and with the effective min value of -7207 printed ?
Thanks
I have got exactly the same problem. Did you by any chance find a solution for what you were looking for? I have been trying all sorts of variations and it always keeps putting the ticks around 0 and also displaying 0 which I really don't want.
David any chance you could give us a hint
Thanks
Sergio
David any chance you could give us a hint
Thanks
Sergio
You could try creating your own number axis and overriding calculateLowestVisibleTickValue(). You will have to declare scalaMinX as final
Code: Select all
NumberAxis domainAxis_x = new NumberAxis("X Values"){
protected double calculateLowestVisibleTickValue() {
return scalaMinX;
}
};
domainAxis_x.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
domainAxis_x.setRange(new Range(scalaMinX, scalaMaxX));
domainAxis_x.setFixedAutoRange(scalaMaxX - scalaMinX);
domainAxis_x.setAutoRangeIncludesZero(false);
domainAxis_x.setTickUnit(new NumberTickUnit((scalaMaxX - scalaMinX) / dimX));
plot.setDomainAxis(domainAxis_x);
The answer does not come from thinking outside the box, rather the answer comes from realizing the truth; There is no Box. my js site