2014-04-03 21 views
1

我生成一個透明的圖表,通過它可以看到網頁的背景。如何用jFreeChart格式化極簡主義圖表?

到目前爲止,我已經做到了這一點(被遺漏的數據集爲簡潔的填充):

lineChartObject=ChartFactory.createLineChart("Title","Legend","Amount",line_chart_dataset,PlotOrientation.VERTICAL,true,true,false); 
    CategoryPlot p = lineChartObject.getCategoryPlot(); 

    Color trans = new Color(0xFF, 0xFF, 0xFF, 0); 
    lineChartObject.setBackgroundPaint(trans); 
    p.setBackgroundPaint(trans); 

    for (int i=0;i<=3;i++){ 
     lineChartObject.getCategoryPlot().getRenderer().setSeriesStroke(i, new BasicStroke(3.0f)); 
     lineChartObject.getCategoryPlot().getRenderer().setBaseItemLabelsVisible(false); 
    } 

這使得這樣的:

enter image description here

我無法找到一個辦法:

  • 刪除圖的邊界(1) (3)
  • 去除邊界並使其透明(3)
  • 使X軸上的標籤(2)與Y軸標籤(A)一起智能地運行。的Y軸空間本身,從而,如果我提供的圖表小不雜亂的圖形,例如標籤,它會顯示較少的標籤,就像這樣:

編輯: X標籤域是日期。

enter image description here

回答

3

對於(1)嘗試:

plot.setOutlineVisible(false); 

對於(2),用於沿x軸具有太多類別的一個常見原因是該數據是實際的數值,其中你應該使用XYPlot而不是CategoryPlot。使用XY繪圖時,x軸刻度的調整方式與y軸相同。

從OP編輯:使用帶TimeSeriesCollection的TimeSeriesChart作爲XYDataSet做了工作! (fotgot說X訪問日期)

對於(3)嘗試:

LegendTitle legend = chart.getLegend(); 
legend.setFrame(BlockBorder.NONE); 
legend.setBackgroundPaint(new Color(0, 0, 0, 0));