JFreeChart XY图上的图标

Sha*_*wnD 4 java jfreechart

我有一个位置的XY图,并希望最新的点是一个图标.这可能在JFreeChart中吗?

小智 6

在xy图上,您需要跟踪最后添加的xy点,然后使用以下内容添加它:

double x = 150;
double y = 300;
XYPlot plot = chart.getXYPlot();
ImageIcon imageIcon = new ImageIcon("/path/to/your/icon.png");
XYAnnotation xyannotation = new XYImageAnnotation(x, y, imageIcon.getImage());
plot.addAnnotation(xyannotation); 
Run Code Online (Sandbox Code Playgroud)