我有一个动态XYAreaChart,我希望线条边框清晰,因为该区域全部都填充了渐变色,但我希望线条边框的颜色不同,例如我的区域用渐变绿色和红色填充我希望线条边框为黑色。怎么做?
这是我的代码:
final XYSeries series = new XYSeries("Data");
XYSeriesCollection dataset = new XYSeriesCollection(series);
// Creation du area chart
JFreeChart chart = ChartFactory.createXYAreaChart("Fun Meter", "", "",
dataset, PlotOrientation.VERTICAL, false, false, false);
// jframe=new ChartFrame("Fun Meter", chart);
ChartPanel CP = new ChartPanel(chart);
XYPlot xyPlot = (XYPlot) chart.getPlot();
GradientPaint gp0 = new GradientPaint(0.0f, 100.0f, new Color(50, 205,
50), 0.0f, 100.0f, Color.red);
xyPlot.getRenderer().setSeriesPaint(0, gp0);
xyPlot.setForegroundAlpha(0.75f);
答案 0 :(得分:1)
您应该在渲染器上使用setSeriesOutlinePaint(int, Paint)
方法。
假设您使用XYAreaRenderer
如下所示:
XYAreaRenderer renderer = (XYAreaRenderer) xyPlot.getRenderer();
renderer.setSeriesOutlinePaint(0, Color.black);
renderer.setSeriesOutlineStroke(0, new BasicStroke(0.5f));
renderer.setOutline(true);