我试图在我的primeFaces折线图中绘制show max和min趋势的水平线,但是无法理解我有没有我的xhtml代码:
<div align="center">
<p:outputPanel id="fuelAnalysisPanel">
<p:chart type="line" model="#{generatorDataLogReportBean.animatedModel2}" style="width:95%;" widgetVar="fuelChart"/>
<br/>
</p:outputPanel>
</div>
我的java类代码是:
private void createAnimatedModelsForFuel(ArrayList<Param> dataLog) {
animatedModel2 = initLinearModelForFuel(dataLog);
animatedModel2.setTitle("Fuel Graph (%)");
animatedModel2.setAnimate(true);
animatedModel2.setLegendPosition("se");
animatedModel2.setSeriesColors("D42F36");
Axis yAxis = animatedModel2.getAxis(AxisType.Y);
yAxis.setMin(0);
yAxis.setMax(100);
yAxis.setLabel("Percentage %");
}
private LineChartModel initLinearModelForFuel(ArrayList<Param> dataLog) {
LineChartModel model = new LineChartModel();
LineChartSeries series1 = new LineChartSeries();
series1.setLabel("Fuel%");
int i = 1;
String dt = "";
//int size = dataLog.size()-1 ;
/* for (; size >= 0; size--) {
if (dataLog.get(size) instanceof VT12Param) {
series1.set(i++, ((VT12Param) dataLog.get(size)).getActualFuelPercent());
}
}
*/
for (Param p : dataLog) {
if (p instanceof VT12Param) {
dt = sdf2.format(((VT12Param) p).getDateTime().getTime());
series1.set(dt, ((VT12Param) p).getActualFuelPercent());
} else if (p instanceof T20Param) {
dt = sdf2.format(((T20Param) p).getDateTime().getTime());
series1.set(dt, ((T20Param) p).getActualFuelPercent());
}
}
//model.setDatatipFormat("%s, %s");
model.addSeries(series1);
DateAxis axis = new DateAxis("Dates");
axis.setTickAngle(-30);
model.getAxes().put(AxisType.X, axis);
//axis.setMax(sdf.format(toDate.getTime()));
axis.setTickFormat("%b %#d, %H:%M"); //%b %#d, %#I %p // %b %#d, %#I:%M %p
if(dataLog.size() < 500){
axis.setTickInterval(dataLog.size()+"00000");
}
else{
axis.setTickInterval(dataLog.size()+"0000");
}
model.setLegendCols(15);
model.getAxes().put(AxisType.X, axis);
// model.setZoom(true);
return model;
}