有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

JFreeChart中的java定制堆积面积图

我是JFreeChart的新手,我已经创建了堆叠面积图。我的问题是删除图表中的网格线。关于这个问题我搜索了一整天。我没有找到合适的解决办法。请帮我整理一下

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);

电流输出: Have to remove grid lines in current graph

所需输出: enter image description here


共 (1) 个答案

  1. # 1 楼答案

    最后,我通过添加以下声明解决了这个问题

    图表。setAntiAlias(假)