我对2D折线图中的点大小有疑问。
我正在使用XYLineAndShapeRenderer和XYSeries绘制2D图形。
如您所知,每个点都有相同的大小。
但是,我的客户希望每个点都有不同的大小。
我该怎么做?
public class LinePlot {
private XYSeriesCollection dataset;
public LinePlot (List<Point> points, Color color) {
dataset = new XYSeriesCollection();
XYSeries data = new XYSeries("data", false);
for(Point point : points){
data.add(point.getX(), point.getY());
}
dataset.addSeries(data);
showGraph(color);
}
private void showGraph(Color color) {
final JFreeChart chart = createChart(dataset, color);
final ChartPanel chartPanel = new ChartPanel(chart);
//chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
final ApplicationFrame frame = new ApplicationFrame("Gesture Data");
frame.setContentPane(chartPanel);
frame.pack();
frame.setVisible(true);
}
private JFreeChart createChart(final XYDataset dataset, Color color) {
final JFreeChart chart = ChartFactory.createScatterPlot(
"XY Chart", // chart title
"X", // x axis label
"Y", // y axis label
dataset, // data
PlotOrientation.VERTICAL,
true, // include legend
true, // tooltips
false // urls
);
XYPlot plot = (XYPlot) chart.getPlot();
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
renderer.setSeriesPaint(0, color);
renderer.setSeriesLinesVisible(0, true);
plot.setRenderer(renderer);
return chart;
}