Note that there are some explanatory texts on larger screens.

plurals
  1. POPrimefaces & jqplot - Displaying dates on an axis
    primarykey
    data
    text
    <p>I am trying to use the extender atttribute on a line chart in PrimeFaces 3.4. I need to use extender to format the x-axis with date/time values. Doing this without extender is not an option as there are too many data points and the labels simply overwrite if I use the default PF lineChart attributes. When I setup the the code as shown below, I get an x-axis with no values displayed; all I can see is the x-axis. See pic for more details. How can I set this up so that the x-axis displays time in hh:mm format ?</p> <p><img src="https://i.stack.imgur.com/XRzrx.png" alt="Chart Displayed"></p> <p>XHTML Code</p> <pre><code>&lt;script type="text/javascript" src="#{request.contextPath}/js/plugins/jqplot.dateAxisRenderer.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="#{request.contextPath}/js/plugins/jqplot.canvasAxisTickRenderer.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function loginRateChartExt() { this.cfg.axes = { yaxis: { numberTicks: 10, label: 'Logins per minute -&gt;', labelRenderer: $.jqplot.CanvasAxisLabelRenderer, labelOptions: { fontFamily: 'Verdana', fontSize: '8pt' }, }, xaxis: { renderer: $.jqplot.DateAxisRenderer, rendererOptions: { tickRenderer:$.jqplot.CanvasAxisTickRenderer }, tickOptions: { formatString:'%H:%M' }, label: 'Time of day -&gt;', labelRenderer: $.jqplot.CanvasAxisLabelRenderer, labelOptions: { fontFamily: 'Verdana', fontSize: '8pt' } } }; } &lt;/script&gt; &lt;p:lineChart id="loginRateChart" value="#{loginRateBean.chartModel}" extender="loginRateChartExt" /&gt; </code></pre> <p>Bean Code</p> <pre><code>for(int i = 0; i &lt; 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)); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload