Primefaces 5.1:条形图和饼图不显示图例

时间:2016-09-16 07:35:39

标签: jsf jsf-2 primefaces charts

我的条形图和饼图中没有图例。 我为setLegendPlacementsetLegendPosition方法尝试了几个参数,但没有结果。

我哪里出错?

这是我对条形图的配置:

 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

1 个答案:

答案 0 :(得分:0)

在绘制之前通过在钩子上将属性componentWillReceiveProps(nextProps, nextState) { if (this.state.data != nextState.data) { this.setState({showNotif: true}); } } 设置为legend.show来解决:

true

有点无用的黑客攻击,Primefaces 5.1似乎没有默认设置这个属性。