Hello Amedeo,
Here's an example of a pie chart. This method can be bound directly to the "data" binding of a WOImage. (Of course, then it will regenerate each time the page is displayed.) This is only an example, and don't worry about what an OPDataCategory does, just know we're setting the values in a DefaultPieDataset.
public NSData pieChart1() { DefaultPieDataset result = new DefaultPieDataset(); Enumeration aCatEnum = ((Session)session()).pieChartCategories.objectEnumerator(); while( aCatEnum.hasMoreElements() ) { OPDataCategory aCat = (OPDataCategory)aCatEnum.nextElement(); result.setValue( aCat.categoryName(), aCat.dataItemForTimePeriodAndType( (Integer)((Session)session()).pieChartPeriods.anyObject(), ((Session)session()).currentTimePeriodType ).dataItemValue() ); }
JFreeChart aChart = ChartFactory.createPieChart( "Comparison", // chart title result, // data true, // include legend true, false ); final PiePlot plot = (PiePlot) aChart.getPlot(); plot.setNoDataMessage("No data available"); plot.setSectionPaint( 0, Color.green );
ByteArrayOutputStream myByteStream = new ByteArrayOutputStream();
try { ChartUtilities.writeChartAsJPEG( myByteStream, aChart, 680, 430 ); } catch (Exception e) { NSLog.err.appendln( "ChartsPage: pieChart1: Error: " + e.toString() ); }
return new NSData( myByteStream.toByteArray() ); }
Hope this helps.
Regards, Mark On Feb 5, 2006, at 2:18 PM, Amedeo Mantica wrote: Thanks, does anyone have a progect example?
Amedeo
|