2013-03-26 45 views
0

使用的JFreeChart我想直線添加到BoxAndWhiskerChart,這樣的結果是這樣的:如何將一行添加到BoxAndWhiskerChart?

7 | - - 
6 | x  - 
5 |  x x 
4 | - - 
3 |   - 
2 |------------ <- ? 
1 | 
0 +------------ 
     A B C 

這基本上是我用於創建圖表代碼:

DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset(); 
//adding data to dataset... 
BoxAndWhiskerRenderer rnd = new BoxAndWhiskerRenderer(); 
CategoryPlot plot = new CategoryPlot(dataset, x, y, rnd); 
JFreeChart chart = new JFreeChart(plot); 

是有一種簡單的方法可以將一條線添加到圖表中?

回答

2

是的 - 你需要添加一個Marger到範圍軸。你可以找到一個例子here

你可以添加以下代碼:

final Marker valueMarker= new ValueMarker(2.0); 
valueMarker.setPaint(Color.green); 
plot.addRangeMarker(valueMarker);