Is it possible to
- add some kind of renderer to the XAxis? My values are timestamps (milliseconds), so would be nice to render them as time string
- to define where the legend must be shown (e.g. right of the graph)?
Is it possible to
For positioning the legend, you can disable the default legend and add you own.
soChart.disableDefaultLegend();
Legend myLegend = new Legend();
Position p = myLegend.getPosition(true);
p.set...
p.set...
soChart.add(myLegend);
Regarding the rendering of the axis labels, I will get back to you.
Wow, quick and perfect reply again! Thanks, Syam.
I have incorporated the requested feature (Version 1.1.2). You can use something as follows:
xAxis.getLabel(true).setFormatter("{yyy}/{MM}/{dd}");
Please have a look at the documentation.
[Here]
(https://storedobject.com/api/com/storedobject/chart/Axis.Label.html#setFormatter(java.lang.String))
That’s quick!!! :-)
My xAxis contains milliseconds, which doesn’t seem to be handled correctly. Do I need to use other value type?
xAxis = new XAxis(DataType.NUMBER);
xAxis.getLabel(true).setFormatter("{HH}:{mm}:{ss}");
...
xValues.add(System.currentTimeMillis());
You should use DataType.TIME
or DataType.DATE
(in the case of just date with out the time part) for that.
Also, there are helper classes available for creating serial data:
SerialTime
, SerialDate
, SerialData
etc.
If your data is in millis, you can do something like LocalDateTime.ofEpochSecond(millis, 0, ZoneOffset.UTC)
to convert that to DataType.TIME
data.