PrimeFaces:6.0.0
我想显示折线图。在该图表中,
X轴应显示Sce_1,Sce_2 ....等, Y轴应以HH:MM:SS格式显示时间
目前,我可以在两个x轴中显示值,但不会显示图表。
图表: enter image description here
以下是我的代码:
在Xhtml文件中:
<p:chart id="gp2" type="line" model="#{student.areaModel}" extender="ext2" style="height:400px;width:800px" />
Java脚本: 注意:我在项目中导入了jqplot-1.4.20.jar
<script type="text/javascript" src="/org/wicketstuff/jqplot/behavior/plugins/jqplot.dateAxisRenderer.min.js"></script>
<script type="text/javascript">
//<![CDATA[
function ext2() {
//this = chart widget instance
//this.cfg = options
this.cfg.axes = {
xaxis : {
rendererOptions : {
tickRenderer : $.jqplot.CanvasAxisTickRenderer
},
tickOptions : {
fontSize : '10pt',
fontFamily : 'Tahoma',
angle : 30
}
},
yaxis : {
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
}
}
};
this.cfg.highlighter = {
show : true,
tooltipOffset : 2
}
};
//]]>
</script>
在Backingbean文件中,
public void graph_04()
{
if(areaModel != null)
{
areaModel.clear();
}
areaModel = new LineChartModel();
DateAxis Yaxis = new DateAxis("Time");
Yaxis.setMin("00:00:00");
Yaxis.setMax("00:59:59");
Yaxis.setTickFormat("%H:%#M:%S");
areaModel.getAxes().put(AxisType.Y, Yaxis);
Axis xAxis = new CategoryAxis("Sce Name");
areaModel.getAxes().put(AxisType.X, xAxis);
xAxis.setTickAngle(-30);
areaModel.setStacked(true);
areaModel.setShowPointLabels(true);
LineChartSeries ch = new LineChartSeries();
ch.setLabel("List");
ch.set("Sce_1", new Time(00,10,10).getTime());
ch.set("Sce_2", new Time(00,20,10).getTime());
ch.set("Sce_3", new Time(00,30,12).getTime());
ch.set("Sce_4", new Time(00,40,18).getTime());
ch.set("Sce_5", new Time(00,50,56).getTime());
ch.set("Sce_6", new Time(00,22,30).getTime());
ch.set("Sce_7", new Time(00,18,40).getTime());
areaModel.addSeries(ch);
}
为什么图表值没有显示在图表中?