我想删除连接极坐标图端点的直线。它不是数据集的一部分。我也尝试过插入 Double.NaN 但结果不能令人满意,它创建了一些与 Double.Nan 的额外连接而不是破坏它。
public class PolarPanel extends JPanel {
private static final long serialVersionUID = 1L;
XYSeriesCollection dataset;
public PolarPanel() {
setLayout(new BorderLayout());
dataset = new XYSeriesCollection();
add(new JLabel("No Data Available", JLabel.CENTER), BorderLayout.CENTER);
}
public void setGraph(XYSeries polarseries) {
dataset.removeAllSeries();
dataset.addSeries(polarseries);
JFreeChart chart = ChartFactory.createPolarChart("Polar", dataset, isBackgroundSet(),
getIgnoreRepaint(),getFocusTraversalKeysEnabled());
PolarPlot plot = (PolarPlot) chart.getPlot();
var renderer = new DefaultPolarItemRenderer();
renderer.setShapesVisible(false);
NumberAxis xAxis = (NumberAxis) plot.getAxis();
xAxis.setTickUnit(new NumberTickUnit(10));
plot.setRenderer(renderer);
plot.setBackgroundPaint(Color.WHITE);
plot.setAngleGridlinesVisible(true);
plot.setAngleGridlinePaint(Color.BLACK);
plot.setRadiusGridlinesVisible(true);
plot.setRadiusGridlinePaint(Color.BLACK);
chart.getLegend().setFrame(BlockBorder.NONE);
chart.setTitle(new TextTitle("Polar", new Font("Serif", java.awt.Font.BOLD, 18)));
chart.removeLegend();
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
chartPanel.setBackground(Color.WHITE);
BorderLayout layout = (BorderLayout) this.getLayout();
if(layout.getLayoutComponent(BorderLayout.CENTER)!=null)
this.remove(layout.getLayoutComponent(BorderLayout.CENTER));
this.add(chartPanel, BorderLayout.CENTER);
}
}
最佳答案
使用DefaultPolarItemRenderer
方法setConnectFirstAndLastPoint()
改变默认行为。从检查的示例开始 here ,以下更改会产生如下所示的图表:
renderer.setConnectFirstAndLastPoint(false);
关于java - 如何删除jfree极坐标图中端点之间的连接/线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73219552/