I use PrimeFaces 3.4.1 to plot a timeline (date on the x axis, int value on the y axis).
At the moment, I have something like this:
XHTML
<p:lineChart id="timeChart" value="#{myGraphBean.model}" legendPosition="e" title="Time Chart" minY="0" maxY="25" style="height:300px"/>
Java bean :
private final static int MAX_VALUE = 20; private final static int NUMBER_OF_POINTS = 20; private final static DateFormat dateFormat = new SimpleDateFormat("dd-MM-yy"); private void createLinearModel() { model = new CartesianChartModel(); Calendar day = Calendar.getInstance(); day.set(Calendar.HOUR_OF_DAY, 0); day.set(Calendar.MINUTE, 0); day.set(Calendar.SECOND, 0); day.set(Calendar.MILLISECOND, 0); LineChartSeries series = new LineChartSeries(); series.setLabel("My series"); for (int i = 0; i < NUMBER_OF_POINTS; i++) { series.set(dateFormat.format(day.getTime()), getRandomValue()); day.add(Calendar.DAY_OF_MONTH, 1); } model.addSeries(series); } private int getRandomValue() { return rand.nextInt(MAX_VALUE); }
So my bean just creates some random int value for each day. (My application creates actual data points, this is just a dummy example)
In my application, I have been generating data for a long time, for example, 6 months. Now when I do something, I get terrible graphics:

What I would like to do:
I would like my data to be indicated, but I only show a checkmark, say, every month.
I tried changing the checkmark on the x axis following a few other messages ( ex1 , ex2 ), but I couldn't get it to work.
Using the primfaces extender, I tried using things like tickInterval: '1 month' by setting the min attributes, but nothing tickInterval: '1 month' . In most cases, it just breaks the schedule.
Questions:
The jqPlot document says: โNote that although jqPlot will parse most of any date available to a person, it is safer to use javascript timestamps when possible. It is also better to specify a date and time rather than just one date. This is due to inconsistent browser processing local time compared to UTC with bare dates. " In my bean plot, should I fill out the series using formatted date (String) after the javascript timestamp ("yyyy-MM-dd h: mma") or directly using java.util.Date?
How to change the tick along the x axis (letโs say, 1 month), having a marker only every month, but still the chart goes through all the daytime points (i.e. I donโt want to average my points for a month)?
phoenix7360
source share