Gostaria de saber se alguém poderia postar ou mandar um link de um simples exemplo de gráfico em pizza com seus repectivos valores sobre cada fatia no Jfreechart para que eu possa carregá-lo no meu jsp. Agradeceria muito, pois falta somente isso para eu terminar um projeto. Já baixei a lib do Jfreechart.
Você precisa do CeWolf também, para usar o JFreeChart em JSPs. Baixe esse fulano também (ele disponibiliza uma tag library que facilita muito o uso do JFreeChart em JSP).
D
danyelsanches
Olá, ai vai um exemplo do próprio JfreeChart…
<html><head><linkrel="stylesheet"href="sample.css"type="text/css"/><title>PieChartCreationCode</title></head><body><imgsrc="images/top_bar.png"width=1004height=75border=0><tableborder=0><tr><tdwidth=170><imgsrc="images/spacer.png"width=170height=1></td><td><h2>PieChartCreationCode</h2>Fromorg.jfree.chart.demo.servlet.WebHitChart(Seealsopie_chart.jsp)<xmp>publicstaticStringgeneratePieChart(DatehitDate,HttpSessionsession,PrintWriterpw){Stringfilename=null;try{// Retrieve list of WebHitsWebHitDataSetwhDataSet=newWebHitDataSet();ArrayListlist=whDataSet.getDataBySection(hitDate);// Throw a custom NoDataException if there is no dataif(list.size()==0){System.out.println("No data has been found");thrownewNoDataException();}// Create and populate a PieDataSetDefaultPieDatasetdata=newDefaultPieDataset();Iteratoriter=list.listIterator();while(iter.hasNext()){WebHitwh=(WebHit)iter.next();data.setValue(wh.getSection(),newLong(wh.getHitCount()));}// Create the chart objectPiePlotplot=newPiePlot(data);plot.setInsets(newInsets(0,5,5,5));plot.setURLGenerator(newStandardPieURLGenerator("xy_chart.jsp","section"));plot.setToolTipGenerator(newStandardPieItemLabelGenerator());JFreeChartchart=newJFreeChart("",JFreeChart.DEFAULT_TITLE_FONT,plot,true);chart.setBackgroundPaint(java.awt.Color.white);// Write the chart image to the temporary directoryChartRenderingInfoinfo=newChartRenderingInfo(newStandardEntityCollection());filename=ServletUtilities.saveChartAsPNG(chart,500,300,info,session);// Write the image map to the PrintWriterChartUtilities.writeImageMap(pw,filename,info);pw.flush();}catch(NoDataExceptione){System.out.println(e.toString());filename="public_nodata_500x300.png";}catch(Exceptione){System.out.println("Exception - "+e.toString());e.printStackTrace(System.out);filename="public_error_500x300.png";}returnfilename;}</xmp><tableborder=0cellpadding=2width=400><tr><tdalign=left><ahref="pie_chart.jsp">Backtothechart</a></td><tdalign=right><ahref="index.html">Backtothehomepage</a></td></tr></table></td></tr></table></body></html>