• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Chart with WebObjects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Chart with WebObjects


  • Subject: Re: Chart with WebObjects
  • From: Mark Morris <email@hidden>
  • Date: Sun, 5 Feb 2006 15:31:09 -0600

I guess I should have mentioned this is using JFreeChart.  ;-)

On Feb 5, 2006, at 3:25 PM, Mark Morris wrote:

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

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Chart with WebObjects (From: Amedeo Mantica <email@hidden>)
 >Re: Chart with WebObjects (From: James Cicenia <email@hidden>)
 >Re: Chart with WebObjects (From: Amedeo Mantica <email@hidden>)
 >Re: Chart with WebObjects (From: Mark Morris <email@hidden>)

  • Prev by Date: Re: Chart with WebObjects
  • Next by Date: Re: Chart with WebObjects
  • Previous by thread: Re: Chart with WebObjects
  • Next by thread: Re: Chart with WebObjects
  • Index(es):
    • Date
    • Thread