JFree Chart3d如何获取XYZ折线图上显示的数据点

问题描述 投票:0回答:1

我使用 java 使用 Orson Charts 库中的 JFree.chart3d 绘制了 3D 折线图。如何获取我画的折线图上鼠标选中的两点之间的数据?

我深入搜索,但在库中没有找到 getDataset 或类似的方法。我尝试用鼠标获取点击点处的线,但没有找到这样的方法。任何帮助,将不胜感激。有关于 2D 图表的解决方案,但我还没有遇到过 jfree.chart3d 库的这样的解决方案

java jfreechart
1个回答
0
投票

我尝试读取鼠标选择的折线图中的数据集。第一次单击鼠标定义了子线的起点,第二次单击鼠标定义了鼠标所选线的子线的终点。我尝试按如下方式读取数据集。但我收到“getRenderer() 对于 Plot3D 类型未定义”错误:

chart3DPanel.addChartMouseListener(new Chart3DMouseListener() {
        
        @Override
        public void chartMouseMoved(Chart3DMouseEvent arg0) {
        }
        @Override
        public void chartMouseClicked(Chart3DMouseEvent arg0) {
              // Retrieve the chart from the event
            Chart3D chart = arg0.getChart();
            // Retrieve the plot from the chart
            Plot3D plot = chart.getPlot();
            // Retrieve the renderer from the plot
            XYZRenderer renderer = (XYZRenderer)plot.getRenderer();//Error
            // Retrieve the dataset from the plot
            XYZDataset dataset = renderer.getPlot().getDataset();
        }
    });
© www.soinside.com 2019 - 2024. All rights reserved.