Code: Select all
private void initializeGraph() {
XYZDataset dataset = createNewDataset();
Chart3D chart = createChart(dataset);
Chart3DPanel chartPanel = new Chart3DPanel(chart);
graphPanel.add(new DisplayPanel3D(chartPanel), java.awt.BorderLayout.CENTER);
chartPanel.zoomToFit();
}
private Chart3D createChart(XYZDataset dataset) {
Chart3D chart = Chart3DFactory.createXYZLineChart(
"XYZ Chart Test", //Title
"Subtitle here", //Subtitle
dataset, //Dataset
"X", //X-axis label
"Y", //Y-axis label
"Z" //Z-axis label
);
XYZPlot plot = (XYZPlot) chart.getPlot();
plot.setDimensions(new Dimension3D(15, 10, 8));
((NumberAxis3D)plot.getXAxis()).setAutoAdjustRange(false);
((NumberAxis3D)plot.getYAxis()).setAutoAdjustRange(false);
((NumberAxis3D)plot.getZAxis()).setAutoAdjustRange(false);
((NumberAxis3D)plot.getXAxis()).setRange(0.0, 10.0);
((NumberAxis3D)plot.getYAxis()).setRange(0.0, 10.0);
((NumberAxis3D)plot.getZAxis()).setRange(0.0, 10.0);
return chart;
}
private XYZSeries<String> series1;
private XYZDataset<String> createNewDataset() {
series1 = new XYZSeries<>("Series 1");
series1.add(0.0, 0.0, 0.0);
series1.add(1.0, 5.0, 1.0);
XYZSeriesCollection<String> dataset = new XYZSeriesCollection<>();
dataset.add(series1);
return dataset;
}
Thank you!
Also as a side note, is it possible to adjust the line renderer in such a way that it could display an arrow head? See image below.
