Group,
In my app I have a slider which I want to display the same tick labels as the domain axis of my chart uses.
However, I have not been able to find out how to access the ticklabels used by the axis.
Anybody has got any leads?
thx,
Hans
slider labels and chart tick labels
Well, I figured it out for myself.
I created a fake tick list using a fake screen data area and calling refreshTicks() on the axis such as:
That did the trick. If there is a better way, pls. let me know.
I don't know what others think, but my impression is that it appears to be unnecessarily hard to do certain simple things with JFreeChart (even tho I love using it).
kindly,
H.
I created a fake tick list using a fake screen data area and calling refreshTicks() on the axis such as:
Code: Select all
Rectangle2D fakeArea = new Rectangle2D.Double(10, 10, 1000, 1000);
java.util.List ticks = plot.getDomainAxis().refreshTicks((Graphics2D) chartPanel.getGraphics(),
null, fakeArea, RectangleEdge.BOTTOM);
String idx0 = ((NumberTick) ticks.get(0)).getText().replace(",","");
String idx1 = ((NumberTick) ticks.get(1)).getText().replace(",","");
int delta = Integer.parseInt(idx1) - Integer.parseInt(idx0);
slider.setMajorTickSpacing(delta);
I don't know what others think, but my impression is that it appears to be unnecessarily hard to do certain simple things with JFreeChart (even tho I love using it).
kindly,
H.
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
If you want to get the entire tick list, your approach is probably as simple as it can be.
If all you want to get is the difference between two ticks (this is what you are calculating in your example), see this thread:
http://www.jfree.org/phpBB2/viewtopic.php?p=68718
Regards, paradoxoff
If all you want to get is the difference between two ticks (this is what you are calculating in your example), see this thread:
http://www.jfree.org/phpBB2/viewtopic.php?p=68718
Regards, paradoxoff