Inserting non-numerical characters into tick labels
Inserting non-numerical characters into tick labels
I have an XYLineChart that displays time in HHh MM' SS" .... however I cannot figure out how to have this displayed since the XYLineChart only takes numbers as tick labels.
-
- Posts: 844
- Joined: Fri Oct 13, 2006 9:29 pm
- Location: Sunnyvale, CA
Use a DateAxis for the domain axis. If you want to specify how the axis labels are formatted, create a custom DataFormat and assign it with setDateFormatOverride(java.text.DateFormat). The JavaDoc entries and the internet should be able to fill in the rest of the details.
Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA
Code: Select all
Caused by: java.lang.ClassCastException: org.jfree.chart.axis.NumberAxis
[17:18:40.423] {http--8080-2} at java:167)
Code: Select all
DateAxis domainAxis = (DateAxis) plot.getDomainAxis();
-
- Posts: 844
- Joined: Fri Oct 13, 2006 9:29 pm
- Location: Sunnyvale, CA
As much as I appreciate the offer of $40, I will have to decline. I do have a few minutes, so I gave this a quick look. Try the following:tox0tes wrote:Richard, can I pay you $40 to write me sample code that simply displays a number representing milliseconds (472832837) and displays it as HHh MM' SS" on an axis?
Code: Select all
import java.text.SimpleDateFormat
DateAxis domainAxis = new DateAxis("time");
domainAxis.setDateFormatOverride(new SimpleDateFormat("HH'h' mm'' ss'"'"));
plot.setDomainAxis(domainAxis);
You have to understand that the forum is run by volunteers and only a few members of the forum are active participants with respect to answering posts. My participation in the forum varies wildly with the amount of work I have to complete for my employer (AMD). The most I can spare is to point someone in the correct direction and hope that they have the general skills and/or knowledge to go from there. JFreeChart is a project intended for developers with a good understanding of Java (or programming in general). A certain amount of self-reliance is expected, but I admit it can be irritating at times.tox0tes wrote:I have asked similar questions multiple times and get the same response: "look on the internet, search the forum, etc..." but there is no resource on the internet that talks about this. I have battling this problem for 2 months and I give up.
Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA
-
- Posts: 844
- Joined: Fri Oct 13, 2006 9:29 pm
- Location: Sunnyvale, CA
As an FYI, David Gilbert does offer support contracts for JFreeChart. I do not know what his fees are, but I am sure you can disuss the details with him via email. Unlike myself, he actually works for Object Refinery Limited and does consulting for a business.
Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA
-
- Posts: 844
- Joined: Fri Oct 13, 2006 9:29 pm
- Location: Sunnyvale, CA
You are welcome. If you still feel like paying $40 for the answer, write a check in that amount to the charity of your choice. I think that would be a fair exchange.tox0tes wrote:Thanks Richard, that code did it! That just made my day.
Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Richard, thank you very much for the generosity you've displayed here. I really really appreciate the contribution you've made in the JFreeChart forum (not to mention the codebase!) over the last few years. I can hardly offer you a "fair exchange" in return, but at least I can make a gesture - so just now I donated GBP50 (about US$90) to WaterAid on your behalf:RichardWest wrote:You are welcome. If you still feel like paying $40 for the answer, write a check in that amount to the charity of your choice. I think that would be a fair exchange.
http://www.wateraid.org/
Thanks!
Dave Gilbert
JFreeChart Project Leader
-
- Posts: 844
- Joined: Fri Oct 13, 2006 9:29 pm
- Location: Sunnyvale, CA