Re: [問題] 關於JFreeChart畫圖,顯示座標
1. 如果你是要畫點 或許用ChartFactory.createScatterPlot()會比較適合
ChartFactory.createXYLineChart()記得是折線圖
2. JFreeChart createScatterPlot(String title,
String xAxisLabel,
String yAxisLabel,
XYDataset dataset,
PlotOrientation orientation,
boolean legend,
boolean tooltips,
boolean urls)
倒數第二個引數 boolean tooltips 改成true 試看看是否為你想要的效果
如果你只是想要show出滑鼠所指的data座標 這個應該就夠了
※ 引述《mantos730 (饅頭)》之銘言:
: 我是一個Java新手,最近用JFreeChart寫一個畫點的座標圖
: 我是用一個series來存點的資料
: public XYSeries series1 = new XYSeries("Series 1");
: 並以XYSeriesCollection把series資料存在一個dataset中,然後以JFreechart畫出圖來
: JFreeChart chart = ChartFactory.createXYLineChart(title,"X","Y",dataset,
: PlotOrientation.VERTICAL,true,false,false);
: 最後再用Chartpanel輸出圖
: final ChartPanel chartPanel = new ChartPanel(chart);
: 最後結果show出來像這樣:
: http://rainbow-tuka.myweb.hinet.net/1.JPG
: 但接下來我想要再加上一個功能,當滑鼠移到輸出座標圖的點後,在滑鼠旁邊想要
: 顯示一個小方格的提示,顯示該點的座標位置
: 我用了mouseevent去寫,程式為:
: class MyMouseListener implements ChartMouseListener{
: public void chartMouseClicked(ChartMouseEvent arg0) {
: }
: public void chartMouseMoved(ChartMouseEvent arg0) {
: System.out.println("Move:"+arg0.getTrigger().getPoint());
: }
: }
: 然後再把chartpanel的地方加上這一行
: chartPanel.addChartMouseListener(new MyMouseListener());
: 但顯示的座標並不是該點的座標,而是滑鼠指到畫面上的位置座標
: 請問要使用什麼函數才能直接輸出座標上的點的座標呢?
: 謝謝....
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.14.44
推
09/25 00:32, , 1F
09/25 00:32, 1F
討論串 (同標題文章)