fix: 测试线上Jfreechart图表汉字乱码

11111
winter 10 months ago
parent 32f2414cd8
commit c2c1f9cd0b

@ -446,7 +446,6 @@ public class EvaluationServiceImpl implements EvaluationService {
);
List<AppraiseRecordVo> content = appraiseRecordItemPage.getContent();
return content;
}
@ -660,6 +659,12 @@ public class EvaluationServiceImpl implements EvaluationService {
praiseDistributionDataset.setValue(FiveEducations.ART.getName(), reportVo.getPraiseDistribution().get(FiveEducations.ART.getCode()));
praiseDistributionDataset.setValue(FiveEducations.LABOUR.getName(), reportVo.getPraiseDistribution().get(FiveEducations.LABOUR.getCode()));
JFreeChart praisePieChart = ChartUtil.pieChart("五育表扬指标分布", praiseDistributionDataset);
// 设置字体
Font font = new Font("SimSun", Font.PLAIN, 12);
praisePieChart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
praisePieChart.getTitle().setFont(font);
praisePieChart.getLegend().setItemFont(font);
praisePieChart.getLegend().setItemPaint(Color.BLACK);
PiePlot plot1 = (PiePlot) praisePieChart.getPlot();
plot1.setNoDataMessage("无数据");
plot1.setNoDataMessageFont(new Font("宋体", Font.PLAIN, 18));
@ -675,6 +680,10 @@ public class EvaluationServiceImpl implements EvaluationService {
criticalDistributionDataset.setValue(FiveEducations.ART.getName(), reportVo.getCriticalDistribution().get(FiveEducations.ART.getCode()));
criticalDistributionDataset.setValue(FiveEducations.LABOUR.getName(), reportVo.getCriticalDistribution().get(FiveEducations.LABOUR.getCode()));
JFreeChart criticalPieChart = ChartUtil.pieChart("五育待改进指标分布", criticalDistributionDataset);
criticalPieChart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
criticalPieChart.getTitle().setFont(font);
criticalPieChart.getLegend().setItemFont(font);
criticalPieChart.getLegend().setItemPaint(Color.BLACK);
PiePlot plot2 = (PiePlot) criticalPieChart.getPlot();
plot2.setNoDataMessage("无数据");
plot2.setNoDataMessageFont(new Font("宋体", Font.PLAIN, 18));
@ -738,23 +747,5 @@ public class EvaluationServiceImpl implements EvaluationService {
return children;
}
/**
* distribution 0, 1
*/
private void checkIfDistributionNull(Map<String, Integer> distribution) {
boolean flag = false;
for (Map.Entry<String, Integer> entry : distribution.entrySet()) {
if (entry.getValue() != 0) {
flag = true;
break;
}
}
if(flag) {
return;
}
// distribution 全部为 0,则初始化为 1
distribution.forEach((k, v) -> distribution.put(k, 1));
}
}

Loading…
Cancel
Save