Ciao,
I think it is not possible without modifying the library.
Anyway I did it quite easily by modifying the library (the biggest annoyance is to import the library and recompile it):
1. I downloaded the source code
2. I imported the project into Eclipse
3. I modified a couple of classes
4. I re-compiled the jar
5. I replaced the jar in C:\Users\filippo.panelli\Documents\Processing\libraries\gicentreUtils\library
6. I restarted Processing
What I changed:
in AbstractChart.java I replaced:
- protected DecimalFormat[] axisFormatter;
with
- protected Format[] axisFormatter;
In the constructor I replaced:
- axisFormatter = new DecimalFormat[MAX_DIMENSIONS];
with
- axisFormatter = new Format[MAX_DIMENSIONS];
then I added a new method by copying and pasting setFormat, I called it setDateFormat. It is the same code as setFormat with only 1 difference in bold below:
- protected void setDateFormat(int dimension, String format)
- {
- axisFormatter[dimension] = new SimpleDateFormat(format);
- ...
Last point, in XYChart. java I added to new methods similar to setXFormat and setYFormat, but called setXDateFormat and setYDateFormat, I show here the code for x-axis, you can figure out the one for y-axis:
- /** Sets the numerical format for numbers shown on the x-axis.
- * @param format Format for numbers on the x-axis.
- */
- public void setXFormat(String format)
- {
- setFormat(0, format);
- }
- /** Sets the date format for dates/times shown on the x-axis.
- * @param format Format for numbers on the x-axis.
- */
- public void setXDateFormat(String format)
- {
- setDateFormat(0, format);
- }
That's all.
Ciao
Filippo