How do I remove the points in XYLineAndShapeRenderer?
Asked Answered
O

1

3

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:

enter image description here

Here is the code:

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);
Outstanding answered 21/2, 2019 at 10:13 Comment(5)
Can you update your question with codeBombardon
What part of the code do you want to see? Because there's a lot of code unrelated with the chart and I don't want to post it allOutstanding
only that used for graph generationBombardon
I think it was that one, if i don't mix it up with the legend(try it - if you had given a code I could have checked it ;) ): jfree.org/jfreechart/api/javadoc/org/jfree/chart/renderer/xy/…Backbite
thaks, it workedOutstanding
P
3

By default, the no-argument constructor of XYLineAndShapeRenderer "Creates a new renderer with both lines and shapes visible." To remove the points, you can

Polytypic answered 22/2, 2019 at 16:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.