我是JFreeChart的新手,并且创建了堆积面积图。我的问题是要删除图表中的GridLines。我整天都在搜索这个问题。我没有找到适当的解决方案。请帮我整理一下。
final JFreeChart chart = ChartFactory.createStackedAreaChart(
"", //Chart title
"", // domain axis label
"Millions", // range axis label
otherdataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
false,
true);
LegendTitle legend = chart.getLegend();
legend.setPosition(RectangleEdge.LEFT);
legend.setFrame(BlockBorder.NONE);
chart.setBackgroundPaint(Color.white);
final CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.getRenderer().setSeriesPaint(0, new java.awt.Color(0, 0, 128));
plot.getRenderer().setSeriesPaint(1, new java.awt.Color(192, 80, 77));
plot.getRenderer().setSeriesPaint(2, new java.awt.Color(155, 187, 83));
plot.getRenderer().setSeriesPaint(3, new java.awt.Color(79, 129, 189));
plot.getRenderer().setSeriesPaint(4, new java.awt.Color(75, 0, 130));
plot.getRenderer().setSeriesPaint(5, new java.awt.Color(233, 125, 35));
plot.setBackgroundPaint(Color.WHITE);
plot.setDomainGridlinesVisible(false);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinesVisible(false);
plot.setRangeGridlinePaint(Color.white);
plot.setNoDataMessage("No data found");
int width = 1000; // Width of the image
int height = 200; // Height of the image
File stackedAreaChart = new File("D:/graph.jpeg");
ChartUtilities.saveChartAsJPEG(stackedAreaChart, chart, width, height);
电流输出:
要求的输出:
最佳答案
最后,我通过添加以下声明解决了该问题。
chart.setAntiAlias(false);
关于java - JFreeChart中的定制堆积面积图,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48150670/