I am using PrimeFaces 3.4.1 to plot time chart (Date on x-axis, int value on y-axis).
At the moment I have something like that:
xhtml:
In Java, fill your LineChartSeries
objects with times in milliseconds using Date#getTime()
.
On the facelets side, download from jqPlot site and import the following jqPlot plugins:
<h:outputScript name="Javascript/jqplot.canvasAxisTickRenderer.js" />
<h:outputScript name="Javascript/jqplot.canvasAxisTickRenderer.min.js" />
<h:outputScript name="Javascript/jqplot.dateAxisRenderer.js" />
<h:outputScript name="Javascript/jqplot.dateAxisRenderer.min.js" />
And use this js extender for p:lineChart
component:
function chartExtender() {
this.cfg.axes = {
xaxis : {
renderer : $.jqplot.DateAxisRenderer,
rendererOptions : {
tickRenderer:$.jqplot.CanvasAxisTickRenderer
},
tickOptions : {
fontSize:'10pt',
fontFamily:'Tahoma',
angle:-40
}
},
yaxis : {
rendererOptions : {
tickRenderer:$.jqplot.CanvasAxisTickRenderer
},
tickOptions: {
fontSize:'10pt',
fontFamily:'Tahoma',
angle:30
}
}
};
this.cfg.axes.xaxis.ticks = this.cfg.categories;
}
Useful links:
http://forum.primefaces.org/viewtopic.php?f=3&t=25289#p79916
http://forum.primefaces.org/viewtopic.php?f=3&t=23891&p=78637#p78637