I used it and it's better than jqplot.
![Wink ;)](./images/smilies/icon_e_wink.gif)
Yes, I confirm you that I use key.getTime() because it doesn't work with dates but using long the "renderer:$.jqplot.DateAxisRenderer" converts it into a Date format.marcose wrote:@pescamillam,
Thank you very much for posting the sample code. I had a question on what you had posted.
Could you please confirm that when you build the series object in the bean, the key to the values you add is key.getTime() and not key (i.e. a long and not a Date) ?
Can jqplot work with epoch time and format it as a date ?
I tried following what you had suggested, but I am seeing nothing on my x-axis !!!! I have used different options though (numberTicks & tickOptions:{formatString:'%H:%M'}).
Code: Select all
<td align="center">
<p:lineChart id="linear" value="#{cashBean.linearModel}" legendPosition="ne" animate="true" widgetVar="chart" zoom="true"
title="#{cashBean.linearModelTitle}" style="height:280px; width:480px" extender="ext2"/>
<script type="text/javascript" src="../src/plugins/jqplot.dateAxisRenderer.min.js"></script>
<script>
function ext2() {
//this = chart widget instance
//this.cfg = options
this.cfg.axes = {
xaxis:{
min:null,
max:null,
autoscale:true,
numberTicks:null,
pad:1.0,
tickInterval:'1 days',
renderer:$.jqplot.DateAxisRenderer,
rendererOptions: {
tickInset: 0
},
tickRenderer: $.jqplot.CanvasAxisTickRenderer,
tickOptions:{
fontSize:'10pt',
fontFamily:'Tahoma',
angle:-40
}
},
yaxis:{
rendererOptions:{
tickRenderer:$.jqplot.CanvasAxisTickRenderer
},
tickOptions:{
fontSize:'10pt',
fontFamily:'Tahoma',
formatString: "$%'d",
angle:30
}
}
};
this.cfg.highlighter = {
show: true,
tooltipOffset: 2
}
}
</script>
</td>
Code: Select all
linearModel = new CartesianChartModel();
LineChartSeries series1 = new LineChartSeries();
series1.setLabel(evolution.getTag());
Map<Object, Number> data = getShowedEvolutionData(evolution.getEvolution());
TreeSet<Date> tree = new TreeSet<Date>();
for (Object lineChartSeries : data.keySet()) {
Date key = (Date)lineChartSeries;
tree.add(key);
}
Iterator<Date> it = tree.iterator();
while (it.hasNext()) {
Date key = it.next();
Number value = data.get(key);
series1.set(key.getTime(), value);
}
linearModel.addSeries(series1);
Users browsing this forum: No registered users and 45 guests