2013-02-21 2 views
2
아래 그림과 같이 내가 보고서를 생성 할 필요가

:생성 된 PDF 보고서 : JFreeChart가와 DynamicReports

enter image description here 나는 세부 사항 입력 넷빈즈의 스윙을 사용하여 GUI 디자인 한

:

enter image description here

jFreeChart를 사용하여 생성 한 플롯 :

JFreeChart chart = ChartFactory.createXYLineChart(
"Hysteresis Plot", // chart title 
"Pounds(lb)", // domain axis label 
"Movement(inch)", // range axis label 
dataset, // data 
PlotOrientation.VERTICAL, // orientation 
false, // include legend 
true, // tooltips 
false // urls 
); 
,

출력 :

enter image description here

내가

http://www.dynamicreports.org/getting_started.html#step9

내가 동적 쉽게보고 사용하여 발견 인터넷을 검색하고 있었고, 난이 iText를 또는 JasperReports를 또는 DynamicReports을 사용할 수 있습니다 (재스퍼 보고서 기준) 읽기 . 내 질문은 - 내 예제를 위해 DynamicReports를 사용할 수 있는가? (샘플 보고서를보고 있음) 그렇다면 어떻게 jFreeChart를 보고서로 내보낼 수 있습니까?

이 프로젝트를 완료하는 데 많은 시간이 필요하지 않으므로 도와주세요.

감사

답변

1

대신 JFreeChart가의 DynamicReports 직접 차트를 만들 수 있습니다. 이를 수행하려면 DynamicReports XYLineChartReport 구성 요소를 사용하십시오. 예제 코드는 http://www.dynamicreports.org/examples/xylinechartreport.html입니다. GUI를에 표시에 위의 그림과 같이

// Create the chart. 
JFreeChart chart = ChartFactory.createXYLineChart(
    "Hysteresis Plot", // chart title 
    "Pounds(lb)", // domain axis label 
    "Movement(inch)", // range axis label 
    dataset, // data 
    PlotOrientation.VERTICAL, // orientation 
    false, // include legend 
    true, // tooltips 
    false // urls 
); 

// Export the chart to an image. 
BufferedImage image = chart.createBufferedImage(300, 300); 

report() 
    .title(cmp.text("XYZ HOSPITAL")) 
    .columns(fieldNameColumn, fieldValueColumn) 
    .summary(
     cmp.verticalList() 
      .add(cmp.text("HYSTERISIS PLOT")) 
      .add(cmp.text("A brief description of what this plot signifies")) 
      .add(cmp.image(image)) // Add the exported chart image to the report. 
      .add(cmp.text("REMARKS")) 
    ) 
    .setDataSource(createDataSource()) 
    .toPDF(outputStream); 
+0

이미 만들었습니다

당신은 다음의 JFreeChart의 출력을 사용하여 이미지에 차트를 내보내려면

cmp.image()를 사용하여 보고서에서 해당 이미지를 포함 패널을 만든 다음 보고서로 내보낼 필요가 있습니다. –

+0

수정 된 답변은 JFreeChart를 사용하여 예제를 추가합니다. –

+0

jFreeChart를 .png 또는 .jpeg 이미지로 저장 한 다음 보고서에 포함시킨 다음 이미지 파일을 삭제할 수 있습니다. 기본적으로 이미지 파일은 임시 파일로 사용됩니다. iText처럼 직접 내보낼 수 있을지 궁금 해서요? –