【问题标题】:Primefaces 5.1 : Bar and pie charts display no legendsPrimefaces 5.1:条形图和饼图不显示图例
【发布时间】:2016-09-16 07:35:39
【问题描述】:

我的条形图和饼图中没有显示图例。 我为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

【问题讨论】:

标签: jsf jsf-2 primefaces charts


【解决方案1】:

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

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

有点垃圾,Primefaces 5.1 似乎没有默认设置这个属性。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-24
    • 2012-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-14
    相关资源
    最近更新 更多