2016-09-16 55 views
1

没有图例出现在我的条形图和饼图中。 我尝试了setLegendPlacementsetLegendPosition方法的几个参数,但没有结果。Primefaces 5.1:条形图和饼图不显示图例

我哪里出错了?

这是我为条形图配置:

BarChartModel model = new BarChartModel(); 
model.setZoom(true); 
model.setLegendPlacement(LegendPlacement.INSIDE); 
model.setLegendPosition("ne"); 
model.setAnimate(true); 
model.setMouseoverHighlight(true); 
model.setShowPointLabels(true); 

ChartSeries myChartSeries = new ChartSeries(); 
bank.setLabel("myChatSeries"); 
for (String key : datas.keys()) { 
    bank.set(key, datas.get(key)); 
} 
model.addSeries(myChartSeries); 

Axis yAxis = model.getAxis(AxisType.Y); 
yAxis.setLabel(status.name()); 
yAxis.setMin(0); 
yAxis.setMax(maxCount+1); 
yAxis.setTickInterval("2"); 

Axis xAxis = model.getAxis(AxisType.X); 
xAxis.setTickAngle(-20); 

这是我的饼图配置:

PieChartModel model = new PieChartModel(); 

model.setLegendPosition("ne"); 
model.setLegendPlacement(LegendPlacement.INSIDE); 
model.setTitle("Informations général"); 
model.setMouseoverHighlight(true); 
model.setShowDataLabels(true); 

model.set("type1", 3); 
model.set("type2", 6); 
model.set("type3", 8); 

我的堆栈:JAVA 8,JSF 2.1.28,primefaces 5.1, primefaces-themes 1.0.10

+0

要获得更多帮助,请考虑创建[mcve] – Gimby

回答

0

通过在绘制之前将属性legend.show设置为true解决:

$.jqplot.preDrawHooks.push(function() { 
    this.legend.show = true; 
}); 

不知何故,有点垃圾破解,Primefaces 5.1默认情况下似乎没有设置此属性。