简体   繁体   English

如何删除jfree极坐标图中端点之间的连接/线?

[英]How to remove connection/line between end points in jfree polar chart?

I want to remove the straight line which is connecting the end points of the polar graph.我想删除连接极坐标图端点的直线。 It is not the part of dataset.它不是数据集的一部分。 I have also tried by inserting Double.NaN but results were not satisfiable, it created some extra connection to Double.Nan instead of breaking it.我也尝试过插入 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);
}

} }

Use the DefaultPolarItemRenderer method setConnectFirstAndLastPoint() to alter the default behavior.使用DefaultPolarItemRenderer方法setConnectFirstAndLastPoint()更改默认行为。 Starting from the example examined here , the following change produces the chart shown below:此处检查的示例开始,以下更改会生成如下所示的图表:

renderer.setConnectFirstAndLastPoint(false);

极地图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM