Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Create pie chart programatically?
Create pie chart programatically? [message #43709] Tue, 07 June 2005 11:30 Go to next message
ChangWoo Jung is currently offline ChangWoo JungFriend
Messages: 4
Registered: July 2009
Junior Member
Hello folks,

Eclipse Chart Engine seems promising for chartting with SWT.
Can anyone upload snippet for creating pie chart (2d with depth) with SWT
programatically?
I'd like to use pie chart within SWT application.
Thanks in advance.
Re: Create pie chart programatically? [message #43945 is a reply to message #43709] Tue, 07 June 2005 15:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mpadhye.actuate.com

Hi,

Take a look at the code to create a Line chart programmatically as
given in a separate thread in this group 'create a line chart
programmatically'.

Here is the code for creating a Pie chart programmatically. It is
loosely based on the code for the line chart so you can get a better
feel for the structural differences between these two chart types.

NOTE: It is also possible to take a look at how basic models for other
chart types are created if you have downloaded the code. The code for
the chart types resides in the org.eclipse.birt.chart.ui.extension
plug-in under the org.eclipse.birt.chart.ui.swt.type package. (Take a
look at the getModel() method in the various classes.

// Code Start
/**
* Creates a pie chart model as a reference implementation
* @return An instance of a pie chart model (with sample data)
*/
public static final Chart createSimplePieChart()
{
ChartWithoutAxes cwoaPie = ChartWithoutAxesImpl.create();
cwoaPie.setType("Pie Chart");
cwoaPie.setSubType("Standard Pie Chart");

cwoaPie.setDimension(ChartDimension.TWO_DIMENSIONAL_WITH_DEP TH_LITERAL);
cwoaPie.getBlock().setBackground(ColorDefinitionImpl.WHITE() );
Plot p = cwoaPie.getPlot();
p.getClientArea().setBackground(ColorDefinitionImpl.create(2 55,
255, 225));
cwoaPie.getTitle().getLabel().getCaption().setValue("Sample Pie
Chart");

Legend lg = cwoaPie.getLegend();
LineAttributes lia = lg.getOutline();
lg.getText().getFont().setSize(16);
lia.setStyle(LineStyle.SOLID_LITERAL);
lg.getInsets().set(10, 5, 0, 0);
lg.getOutline().setVisible(false);
lg.setAnchor(Anchor.NORTH_LITERAL);

// CREATE THE CATEGORY SERIES
Series seCategory = SeriesImpl.create();

// CREATE THE PRIMARY DATASET
PieSeries ls = (PieSeries) PieSeriesImpl.create();
ls.setSeriesIdentifier("My Pie Series");
ls.setSliceOutline(ColorDefinitionImpl.CREAM());
ls.getLabel().setVisible(true);

SeriesDefinition sdX = SeriesDefinitionImpl.create();
sdX.getSeriesPalette().update(0); // SET THE COLORS IN THE PALETTE
sdX.setQuery(QueryImpl.create(""));

SeriesDefinition sdY = SeriesDefinitionImpl.create();
sdY.getSeriesPalette().update(1); // SET THE COLORS IN THE PALETTE
sdY.setQuery(QueryImpl.create(""));
sdX.getSeriesDefinitions().add(sdY);

sdX.getSeries().add(seCategory);
sdY.getSeries().add(ls);

cwoaPie.getSeriesDefinitions().add(sdX);
addSampleData(cwoaPie);

return cwoaPie;
}
// Code End


Thanks,
Milind

jungcw@kr.ibm.com wrote:
> Hello folks,
>
> Eclipse Chart Engine seems promising for chartting with SWT.
> Can anyone upload snippet for creating pie chart (2d with depth) with SWT
> programatically?
> I'd like to use pie chart within SWT application.
> Thanks in advance.
Re: Create pie chart programatically? [message #685794 is a reply to message #43945] Mon, 20 June 2011 06:40 Go to previous message
chinnii  is currently offline chinnii Friend
Messages: 6
Registered: June 2011
Junior Member
hi Jung and Folks,

i want to create a PlugIn for Eclipse-Helios which draws a Piechart.
So i am using JFreeChart for SWT.
But when i create PlugIn and run as Eclipse application it is neither creates pie chart nor running and showing error like could not instantiate view. But i have added all the libraries. The problem is it is not able load the JFreechart libraries dynamically.
Could you explain why it is happening.

Thanks in advance.
kranti Kumar Ch
Previous Topic:SQL Query changes take long
Next Topic:Table footer for every page
Goto Forum:
  


Current Time: Fri Apr 19 21:51:41 GMT 2024

Powered by FUDForum. Page generated in 0.03320 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top