我是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);
答案 0 :(得分:1)
最后,我通过添加以下声明解决了这个问题。
chart.setAntiAlias(假);