如何删除XYLineAndShapeRenderer中的点? [英] How do I remove the points in XYLineAndShapeRenderer?
问题描述
我正在使用JFreeChart在Java中创建一个应用程序,其中显示了XY折线图.问题在于它在行上显示了数据集的每个点,而我不想显示这些点.关于如何删除这些点或使其不可见的任何想法?
I'm making an application in Java using JFreeChart which shows an XY line chart. The problem is that it shows every point of the dataset on the lines, and I don't want to display these points. Any idea on how to remove the points or make them not visible?
这是一个示例屏幕截图:
This is a sample screenshot:
这是代码:
JFrame frame = new JFrame();
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
renderer.setSeriesPaint(0, Color.RED);
renderer.setSeriesStroke(0, new BasicStroke(2.0f,
BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
new float[] { 2.0f, 4.0f }, 0.0f));
XYDataset ds = createDataset(i, p, capacity);
JFreeChart xylineChart = ChartFactory.createXYLineChart("", "",
"", ds, PlotOrientation.VERTICAL, true, true, false);
XYPlot plot = xylineChart.getXYPlot();
plot.setDomainGridlinePaint(Color.BLACK);
plot.setRangeGridlinePaint(Color.BLACK);
plot.setBackgroundPaint(Color.WHITE);
plot.setRenderer(renderer);
ChartPanel cp = new ChartPanel(xylineChart);
frame.getContentPane().add(cp);
推荐答案
默认情况下,无参数构造器 /chart/renderer/xy/XYLineAndShapeRenderer.html"rel =" nofollow noreferrer> XYLineAndShapeRenderer
创建同时可见线和形状的新渲染器.要删除这些点,您可以
By default, the no-argument constructor of XYLineAndShapeRenderer
"Creates a new renderer with both lines and shapes visible." To remove the points, you can
Use the alternative constructor to specify the desired combination—lines without shapes, as shown here and in
ChartFactory.createXYLineChart
:
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
Invoke setSeriesShapesVisible()
, as @abhinavxeon suggests here and the author suggests here:
renderer.setSeriesShapesVisible(0, false)
这篇关于如何删除XYLineAndShapeRenderer中的点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!