当我展示图表JSF Primefaces 5.2的图例时,我遇到了问题。在第一次加载时,图例没有颜色的线条,但是当我重新编辑此页面时,所有都是okei。
这里我的代码,我已经设置了默认图例,但在第一次加载时,颜色没有显示。我试图用基于javascript的jqplot修改,但我得到了相同的结果
dryMassVsPowerGraphModel = new LineChartModel();
affectColorBusFamily();
BigDecimal dryMassTemp;
Double eolPowerTemp = 0d;
Map<Double, Double> mapTemp = new HashMap<Double, Double>();
for (final Entry<String, String> busFamily : filterBusFamily.entrySet()) {
seriesContainsPoint = false;
final List<Map<String, Object>> listDryMassEOLPowerByBusFamily = spaceTrakSpaceCraftDao
.getDryMassVsPowerGraphValues(busFamily.getValue());
if (CollectionUtils.isNotEmpty(listDryMassEOLPowerByBusFamily)
&& listDryMassEOLPowerByBusFamily.size() > 0) {
listeLabelBusFamilyTemp = new ArrayList<>();
filterBusFamilySelected.put(busFamily.getKey(), busFamily.getValue());
final LineChartSeries myserie = new LineChartSeries();
myserie.setLabel(busFamily.getValue());
myserie.setShowLine(false);
for (final Map<String, Object> item : listDryMassEOLPowerByBusFamily) {
BigDecimal dryMass = null;
final BigDecimal dryMass_scor = (BigDecimal) item.get("dry_mass_scor");
final BigDecimal dryMass_seradata = (BigDecimal) item.get("dry_mass_scor");
dryMass = dryMass_scor != null ? dryMass_scor : dryMass_seradata;
if (dryMass != null) {
eolPowerTemp = mapTemp.get(dryMass.doubleValue());
if (eolPowerTemp != null
&& eolPowerTemp.compareTo((Double) item.get("eol_power")) != 0) {
listeLabelBusFamilyTemp.add("'" + busFamily.getValue() + "'");
}
if (eolPowerTemp == null) {
listeLabelBusFamilyTemp.add("'" + busFamily.getValue() + "'");
}
mapTemp.put(dryMass.doubleValue(), (Double) item.get("eol_power"));
myserie.set(dryMass.doubleValue(), (Double) item.get("eol_power"));
seriesContainsPoint = true;
}
}
if (seriesContainsPoint) {
numberSat++;
final Random rand = new Random();
final float r = rand.nextFloat();
final float g = rand.nextFloat();
final float b = rand.nextFloat();
final Color randomColor = new Color(r, g, b);
final String hex = Integer.toHexString(randomColor.getRGB()).substring(2);
listColor.add(hex);
dryMassVsPowerGraphModel.addSeries(myserie);
listeLabelBusFamily += "[ " + StringUtils.join(listeLabelBusFamilyTemp, ',') + " ], ";
}
dryMassVsPowerGraphModel.setLegendPosition("e");
dryMassVsPowerGraphModel.setLegendPlacement(LegendPlacement.OUTSIDEGRID);
dryMassVsPowerGraphModel.setLegendCols(2);
}
}
listeLabelBusFamily = listeLabelBusFamily.substring(0, listeLabelBusFamily.lastIndexOf(","));
dryMassVsPowerGraphModel.setSeriesColors(StringUtils.join(listColor, ','));
dryMassVsPowerGraphModel.setShowDatatip(false);
final Axis xAxis3 = dryMassVsPowerGraphModel.getAxis(AxisType.X);
xAxis3.setLabel("Dry mass (kg)");
final Axis yAxis3 = dryMassVsPowerGraphModel.getAxis(AxisType.Y);
yAxis3.setLabel("EOL Power (W)");