2014-10-09 19 views

回答

0

第一我想推薦購買JFreeChart開發者指南。它包含了一大套很好的例子,它支持這個項目的維護者。

關於你的問題:我不知道你的主要目標是什麼。

一個好的起點是提供JFreeChart源的類TimeSeriesChartDemo1

private static JFreeChart createChart(XYDataset dataset) { 

    JFreeChart chart = ChartFactory.createTimeSeriesChart(
     "Legal & General Unit Trust Prices", // title 
     "Date",    // x-axis label 
     "Price Per Unit", // y-axis label 
     dataset,   // data 
     true,    // create legend? 
     true,    // generate tooltips? 
     false    // generate URLs? 
    ); 

    chart.setBackgroundPaint(Color.white); 

    XYPlot plot = (XYPlot) chart.getPlot(); 
    plot.setBackgroundPaint(Color.lightGray); 
    plot.setDomainGridlinePaint(Color.white); 
    plot.setRangeGridlinePaint(Color.white); 
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); 
    plot.setDomainCrosshairVisible(true); 
    plot.setRangeCrosshairVisible(true); 

    XYItemRenderer r = new XYAreaRenderer2(); 
    r.setSeriesPaint(0, new Color(255, 0, 0, 50)); 
    r.setSeriesPaint(0, new Color(0, 255, 0, 50)); 
    plot.setRenderer(r); 

    DateAxis axis = (DateAxis) plot.getDomainAxis(); 
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); 

    return chart; 

} 
+0

是否回答你的問題:

通過設置不同的渲染器修改此演示的createChart方法?在這種情況下,請將您的問題標記爲已解決。謝謝! – Uli 2015-02-04 08:44:09