Primefaces & jqplot - display dates on the axis

I am trying to use the extender attribute on a line chart in PrimeFaces 3.4. I need to use an expander to format the x axis with date / time values. Doing this without an expander is not an option, as there are too many data points, and the labels are simply overwritten if I use the default PF lineChart attributes. When I tweak the code as shown below, I get the x axis with no displayed values; all i see is the x axis. See Pic for more details. How to configure this so that the x axis displays the time in hh: mm format?

Chart displayed

XHTML Code

<script type="text/javascript" src="#{request.contextPath}/js/plugins/jqplot.dateAxisRenderer.min.js"></script> <script type="text/javascript" src="#{request.contextPath}/js/plugins/jqplot.canvasAxisTickRenderer.min.js"></script> <script type="text/javascript"> function loginRateChartExt() { this.cfg.axes = { yaxis: { numberTicks: 10, label: 'Logins per minute ->', labelRenderer: $.jqplot.CanvasAxisLabelRenderer, labelOptions: { fontFamily: 'Verdana', fontSize: '8pt' }, }, xaxis: { renderer: $.jqplot.DateAxisRenderer, rendererOptions: { tickRenderer:$.jqplot.CanvasAxisTickRenderer }, tickOptions: { formatString:'%H:%M' }, label: 'Time of day ->', labelRenderer: $.jqplot.CanvasAxisLabelRenderer, labelOptions: { fontFamily: 'Verdana', fontSize: '8pt' } } }; } </script> <p:lineChart id="loginRateChart" value="#{loginRateBean.chartModel}" extender="loginRateChartExt" /> 

Bean Code

 for(int i = 0; i < workerBean.getSize(); i++) { // worker bean has the data for (String key : workerBean.getValueKeys()) { // each key refers to a series // chartSeriesMap is a map that contains all the series // workerBean.getKeyAt(i) returns Date // workerBean.getValueAt(i, key) returns a Number chartSeriesMap.get(key).set(workerBean.getKeyAt(i), workerBean.getValueAt(i, key).floatValue()); } } for (String string : workerBean.getValueKeys()) { chartModel.addSeries(chartSeriesMap.get(string)); } 
+3
source share
2 answers

To achieve this, you must set the date to LONG using .getTime () ;

 serie.set(registro.getDataAfericao().getTime(), registro.getValor()); 

For more information: http://forum.primefaces.org/viewtopic.php?f=3&t=23891&start=10

+1
source

Adding the min attribute to the expander seems to fix the display problem. I saw this on another question about stackoverflow (link below). Does anyone know if this is a workaround?

jqPlot DateAxis tickInterval not working

0
source

All Articles