jfreechart
jfreechart copied to clipboard
Arm docker centos Pie chart generation disorder
Thanks
1、pom.xml
<dependency>
<groupId>jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>jfree</groupId>
<artifactId>jcommon</artifactId>
<version>1.0.16</version>
</dependency>
2、environment
Arm docker centos machine environment error
Inter docker centos machine environment success
3、code
public static void getGardenImage(ExeportStatisticsMiddleImageVo exeportStatisticsMiddleImageVo){
DefaultPieDataset data = new DefaultPieDataset();
exeportStatisticsMiddleImageVo.getView().forEach(data::setValue);
JFreeChart chart = ChartFactory.createPieChart3D("各类型异常数据占比分析",data,true,false,false);
PiePlot pieplot = (PiePlot) chart.getPlot();
DecimalFormat df = new DecimalFormat("0.0%");
NumberFormat nf = NumberFormat.getNumberInstance();
StandardPieSectionLabelGenerator sp1 = new StandardPieSectionLabelGenerator("{0}\n{2}", nf, df);
pieplot.setLabelGenerator(sp1);
pieplot.setNoDataMessage("无数据显示");
pieplot.setCircular(false);
pieplot.setLabelGap(0.02D);
pieplot.setIgnoreNullValues(true);
pieplot.setIgnoreZeroValues(true);
ChartPanel frame1=new ChartPanel (chart,true);
chart.getTitle().setFont(new Font("宋体",Font.BOLD,20));
PiePlot piePlot= (PiePlot) chart.getPlot();
piePlot.setLabelFont(new Font("宋体",Font.BOLD,10));
chart.getLegend().setItemFont(new Font("黑体",Font.BOLD,10));
ByteArrayOutputStream outputStream = null;
try {
outputStream = new ByteArrayOutputStream();
ChartUtilities.writeChartAsPNG(outputStream, chart, 271, 211, true, 10);
byte[] bytes = outputStream.toByteArray();
BASE64Encoder encoder = new BASE64Encoder();
String base64String = encoder.encodeBuffer(bytes).trim();
exeportStatisticsMiddleImageVo.setBaseStr(base64String.replaceAll("\n", "").replaceAll("\r", ""));
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
outputStream.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Do you know which JRE is being used?
Your Java headless
and environment DISPLAY
settings may influence this, too.
您知道正在使用哪个 JRE 吗?
1.8.0_241
您知道正在使用哪个 JRE 吗?
system is KylinV10
您的 Java
headless
和环境DISPLAY
设置也可能会影响这一点。
Is jfree related to the system?
Do you know which JRE is being used?
thanks
您的 Java
headless
和环境DISPLAY
设置也可能会影响这一点。
thanks
Is jfree related to the system?
JFreeChart is pure Java, but the Java runtime relies on the system. As suggested here, you may need to enable headless
mode—"a system configuration in which the display device, keyboard, or mouse is lacking"— or check for recent changes in your graphics environment.
jfree 和系统有关系吗?
JFreeChart 是纯Java,但Java 运行时依赖于系统。正如此处所建议的,您可能需要启用
headless
模式——“缺少显示设备、键盘或鼠标的系统配置”——或检查图形环境中最近的变化。
add java config -Dawt.toolkit=sun.awt.HeadlessToolkit
Why not java -Djava.awt.headless=true…
?
为什么不
java -Djava.awt.headless=true…
呢?
chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
ok thanks
您知道正在使用哪个 JRE 吗?
chart.getRenderingHints().put(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
ok thanks
Are you saying that headless mode precludes RenderingHints
? What happens without them? Also check your DISPLAY
environment variable and window manager.
We fixed the image disorder issue on ARM64 by moving from Oracle JDK 8 to Amazon Corretto JDK 8
Does the latest version has fixed it? We also have this in arm-kylinV10 OS by oracle JRE
Does the latest version has fixed it? We also have this in arm-kylinV10 OS by oracle JRE
This is fixed in jdk8u311 or later