如何使用Swing繪製這樣的圖形?我已經使用了一個JFreeChart
庫,但我不知道如何使用該庫來繪製這樣的線圖?如何在Swing中繪製此圖表?
import org.jfree.chart.*;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.*;
public class DrawGraph{
public void drawGraph(int[][] drawPoints) {
XYSeries series = new XYSeries("Average Weight");
for(int i=0;i<drawPoints.length;i++){
for(int j=0;j<=1;j+=2){
if(drawPoints[i][j]!=0){
series.add(bla...bla...bla...);
}
}
}
XYDataset xyDataset = new XYSeriesCollection(series);
JFreeChart chart = ChartFactory.createXYLineChart
("XYLine Chart using JFreeChart", "Age", "Weight",
xyDataset, PlotOrientation.VERTICAL, true, true, false);
ChartFrame frame1=new ChartFrame("XYLine Chart",chart);
frame1.setVisible(true);
frame1.setSize(300,300);
}
}
我畫圖表利用這一點,但不工作...
一張圖片描繪了千言萬語。 ***你的***圖是什麼樣的? – 2012-02-03 07:18:47
@AndrewThompson:我已經給出了一個圖表的鏈接...在頂部或點擊[這裏](http://i.imgur.com/ahyiQ.jpg) – Parth 2012-02-03 07:27:48
因此,你想畫一個像在頂部還是您繪製的頂部? – Kris 2012-02-03 07:28:59