Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Customize a Pie Chart with Java under Eclispe
Customize a Pie Chart with Java under Eclispe [message #653294] Wed, 09 February 2011 09:19 Go to next message
kkt8 Missing name is currently offline kkt8 Missing name
Messages: 23
Registered: November 2010
Junior Member
Hello,

I'm developing a java plugin for eclipse, where I present the data as a PieChart.
These data are managed and communicated via this same plugin.

I built a collection of Objects which contain my data and I see these datas via a ChartWithoutAxes, withTextDataSet, the Series and PieSeries, I caught an example I am not sure to understand everything, here is a piece of my code:
ChartWithoutAxes cwoaPie = ChartWithoutAxesImpl.create( );
cwoaPie.setSeriesThickness( 20 );
cwoaPie.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
		cwoaPie.setDimension(ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL);
		
// Plot
Plot p = cwoaPie.getPlot( );
p.getClientArea( ).setBackground( null );
p.getClientArea( ).getOutline( ).setVisible( false );
	
// Legend
Legend lg = cwoaPie.getLegend( );
lg.getOutline( ).setVisible( false );
lg.getText( ).getFont( ).setSize( 8 );
lg.getClientArea().setBackground(ColorDefinitionImpl.create(255, 255, 204));
		((ColorDefinitionImpl)lg.getClientArea().getBackground()).brighter();
lg.setAnchor(Anchor.NORTH_LITERAL);
lg.setItemType( LegendItemType.CATEGORIES_LITERAL );
	
// Title
cwoaPie.getTitle( ).getLabel( ).getCaption( ).setValue(title);
cwoaPie.getTitle( ).getOutline( ).setVisible( false );

//Base Data Set
List<String> textLabels = new ArrayList<String>();
for (DataObject obj : objData) {
		//String label = nameField.getValue(obj);
		String label = obj.nameSection;
		textLabels.add(label);
}
TextDataSet categoryValues = TextDataSetImpl.create(textLabels );

// Base Series
Series seCategory = SeriesImpl.create( );
seCategory.setDataSet( categoryValues );
		
SeriesDefinition sdBase = SeriesDefinitionImpl.create( );
cwoaPie.getSeriesDefinitions( ).add( sdBase );
sdBase.getSeriesPalette( ).shift( -1 );
sdBase.getSeries( ).add( seCategory );
		
SeriesDefinition sdValue = SeriesDefinitionImpl.create( );
sdBase.getSeriesDefinitions( ).add( sdValue );

List<Double> doubleValues = new ArrayList<Double>();
or (DataObject obj : objData) {
		doubleValues.add(obj.size);
}
			
NumberDataSet Values = NumberDataSetImpl.create(doubleValues);
			
// Pie Series
PieSeries sePie = (PieSeries) PieSeriesImpl.create( );
sePie.setSeriesIdentifier( "fnfn");
sePie.setExplosion(3);
sePie.setDataSet( Values );
sePie.getLabel().getCaption().getFont().setSize(8);
		sePie.setLeaderLineStyle(LeaderLineStyle.FIXED_LENGTH_LITERAL);
sePie.setLeaderLineLength(15);
		
DataPointComponent dpc = DataPointComponentImpl.create( DataPointComponentType.ORTHOGONAL_VALUE_LITERAL,
		JavaNumberFormatSpecifierImpl.create( "###.###,00" ) );
sePie.getDataPoint( ).getComponents( ).clear( );
sePie.getDataPoint( ).getComponents( ).add( dpc );		
		
//By default the title of the Value Series is not visible
sePie.getTitle().setVisible(false);
			
//Mouse over the Serie to Show Tooltips
setTriggering(sePie,lg);
			
sdValue.getSeries( ).add( sePie);


it works really well although I display my chart with my data entry!

I would just customize it all:
I have 2 types of data eg 5 data "type 1"and 10 data "type 2", I would like in one PieChart, post a first quarter "Type 1" which contains 5 sub-districts with cool colors and 2nd district "type 2" containing 10 sub districts it with warm colors, all representing a PieChart.

how to specify this?
A track?

Thank you
K Razz
Re: Customize a Pie Chart with Java under Eclispe [message #653449 is a reply to message #653294] Wed, 09 February 2011 18:45 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

What are you trying to specify the data?
Does the code you posted not work?
Remember when specifying category and series values that each has to
have the same number of points for a particular chart. Ie in your code
doubleValues and textLabels have to be the same size for one chart.

Jason

On 2/9/2011 4:20 AM, kkt8 wrote:
> Hello,
>
> I'm developing a java plugin for eclipse, where I present the data as a
> PieChart.
> These data are managed and communicated via this same plugin.
>
> I built a collection of Objects which contain my data and I see these
> datas via a ChartWithoutAxes, withTextDataSet, the Series and PieSeries,
> I caught an example I am not sure to understand everything, here is a
> piece of my code:
>
> ChartWithoutAxes cwoaPie = ChartWithoutAxesImpl.create( );
> cwoaPie.setSeriesThickness( 20 );
> cwoaPie.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
> cwoaPie.setDimension(ChartDimension.TWO_DIMENSIONAL_WITH_DEP TH_LITERAL);
>
> // Plot
> Plot p = cwoaPie.getPlot( );
> p.getClientArea( ).setBackground( null );
> p.getClientArea( ).getOutline( ).setVisible( false );
>
> // Legend
> Legend lg = cwoaPie.getLegend( );
> lg.getOutline( ).setVisible( false );
> lg.getText( ).getFont( ).setSize( 8 );
> lg.getClientArea().setBackground(ColorDefinitionImpl.create( 255, 255,
> 204));
> ((ColorDefinitionImpl)lg.getClientArea().getBackground()).br ighter();
> lg.setAnchor(Anchor.NORTH_LITERAL);
> lg.setItemType( LegendItemType.CATEGORIES_LITERAL );
>
> // Title
> cwoaPie.getTitle( ).getLabel( ).getCaption( ).setValue(title);
> cwoaPie.getTitle( ).getOutline( ).setVisible( false );
>
> //Base Data Set
> List<String> textLabels = new ArrayList<String>();
> for (DataObject obj : objData) {
> //String label = nameField.getValue(obj);
> String label = obj.nameSection;
> textLabels.add(label);
> }
> TextDataSet categoryValues = TextDataSetImpl.create(textLabels );
>
> // Base Series
> Series seCategory = SeriesImpl.create( );
> seCategory.setDataSet( categoryValues );
>
> SeriesDefinition sdBase = SeriesDefinitionImpl.create( );
> cwoaPie.getSeriesDefinitions( ).add( sdBase );
> sdBase.getSeriesPalette( ).shift( -1 );
> sdBase.getSeries( ).add( seCategory );
>
> SeriesDefinition sdValue = SeriesDefinitionImpl.create( );
> sdBase.getSeriesDefinitions( ).add( sdValue );
>
> List<Double> doubleValues = new ArrayList<Double>();
> or (DataObject obj : objData) {
> doubleValues.add(obj.size);
> }
>
> NumberDataSet Values = NumberDataSetImpl.create(doubleValues);
>
> // Pie Series
> PieSeries sePie = (PieSeries) PieSeriesImpl.create( );
> sePie.setSeriesIdentifier( "fnfn");
> sePie.setExplosion(3);
> sePie.setDataSet( Values );
> sePie.getLabel().getCaption().getFont().setSize(8);
> sePie.setLeaderLineStyle(LeaderLineStyle.FIXED_LENGTH_LITERA L);
> sePie.setLeaderLineLength(15);
>
> DataPointComponent dpc = DataPointComponentImpl.create(
> DataPointComponentType.ORTHOGONAL_VALUE_LITERAL,
> JavaNumberFormatSpecifierImpl.create( "###.###,00" ) );
> sePie.getDataPoint( ).getComponents( ).clear( );
> sePie.getDataPoint( ).getComponents( ).add( dpc );
>
> //By default the title of the Value Series is not visible
> sePie.getTitle().setVisible(false);
>
> //Mouse over the Serie to Show Tooltips
> setTriggering(sePie,lg);
>
> sdValue.getSeries( ).add( sePie);
>
>
> it works really well although I display my chart with my data entry!
>
> I would just customize it all:
> I have 2 types of data eg 5 data "type 1"and 10 data "type 2", I would
> like in one PieChart, post a first quarter "Type 1" which contains 5
> sub-districts with cool colors and 2nd district "type 2" containing 10
> sub districts it with warm colors, all representing a PieChart.
>
> how to specify this?
> A track?
>
> Thank you
> K :p
Re: Customize a Pie Chart with Java under Eclispe [message #653526 is a reply to message #653449] Thu, 10 February 2011 06:43 Go to previous messageGo to next message
kkt8 Missing name is currently offline kkt8 Missing name
Messages: 23
Registered: November 2010
Junior Member
Hello,

I just want to specify the color of the chart, and to differencie 2 sorts of data in the same chart, I want to specify my self the color : 1 sort with cold colors for ex, and the sd sort with hot colors.
The code works well, I put it in ex to let see what I'm doing.

do you have any idea to specify the color ?
Re: Customize a Pie Chart with Java under Eclispe [message #653699 is a reply to message #653526] Thu, 10 February 2011 18:14 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Try:

final Fill[] fillcolors= {
ColorDefinitionImpl.ORANGE( ),
ColorDefinitionImpl.RED( ),
ColorDefinitionImpl.GREEN( )
};

sdVal.getSeriesPalette( ).getEntries( ).clear( );
for (final Fill element : fillcolors) {
sdVal.getSeriesPalette( ).getEntries( ).add( element );
}

Jason


On 2/10/2011 1:43 AM, kkt8 wrote:
> Hello,
>
> I just want to specify the color of the chart, and to differencie 2
> sorts of data in the same chart, I want to specify my self the color : 1
> sort with cold colors for ex, and the sd sort with hot colors.
> The code works well, I put it in ex to let see what I'm doing.
>
> do you have any idea to specify the color ?
Re: Customize a Pie Chart with Java under Eclispe [message #653779 is a reply to message #653699] Fri, 11 February 2011 07:08 Go to previous messageGo to next message
kkt8 Missing name is currently offline kkt8 Missing name
Messages: 23
Registered: November 2010
Junior Member
YES ! thank you Very Happy it's very difficult to find some documentation about the API ...

Do you know if it's possible and how to do in the same chart, 2 series of datas .
For ex, I've 2 sorts of datas:
DATA : 100, 200, 1500 and 3000
CODE : 450, 200, 700, 4500
I want to represente all the datas : 100, 200, 1500 and 3000 and 450, 200, 700, 4500 in one piechart, BUT I want see differently the datas DATA and the datas CODE.
Make datas DATA in hot colors (RED, ORANGE...)
Make datas CODE in cold colors (BLUE, GREEN...)
And put next the datas DATA a title and put next the datas CODE another title.

I'm clear ?
If you have a task .... Rolling Eyes

Thank !
Re: Customize a Pie Chart with Java under Eclispe [message #653871 is a reply to message #653779] Fri, 11 February 2011 16:13 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

For a pie chart a new series will create a separate pie. Multiple
series on one pie is currently not supported. You could do multiple
series on a line. Do you want an example of that?

Jason

On 2/11/2011 2:08 AM, kkt8 wrote:
> YES ! thank you :d it's very difficult to find some documentation about
> the API ...
>
> Do you know if it's possible and how to do in the same chart, 2 series
> of datas .
> For ex, I've 2 sorts of datas:
> DATA : 100, 200, 1500 and 3000
> CODE : 450, 200, 700, 4500
> I want to represente all the datas : 100, 200, 1500 and 3000 and 450,
> 200, 700, 4500 in one piechart, BUT I want see differently the datas
> DATA and the datas CODE.
> Make datas DATA in hot colors (RED, ORANGE...)
> Make datas CODE in cold colors (BLUE, GREEN...)
> And put next the datas DATA a title and put next the datas CODE another
> title.
>
> I'm clear ?
> If you have a task .... :roll:
> Thank !
Re: Customize a Pie Chart with Java under Eclispe [message #653885 is a reply to message #653871] Fri, 11 February 2011 17:35 Go to previous messageGo to next message
kkt8 Missing name is currently offline kkt8 Missing name
Messages: 23
Registered: November 2010
Junior Member
Oh yes, I'll see what is it.

In fact, I've done a pie chart with my specific color,as I know in what order are the data, once I know associate each given a color. But I still have the problem of putting a title at a set of color, maybe I'll do it in the legend.

thank you for your precious help.

Do you know where find an help about the BIRT API ?
Have a good week-end Very Happy
Re: Customize a Pie Chart with Java under Eclispe [message #653893 is a reply to message #653885] Fri, 11 February 2011 18:01 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Have you looked over these pages:
http://www.eclipse.org/birt/phoenix/deploy/

You will also want to look at the chart faq:
http://wiki.eclipse.org/BIRT/FAQ/Charts2.2

There are also webinars and examples located on birt-exchange.org

Jason

On 2/11/2011 12:35 PM, kkt8 wrote:
> Oh yes, I'll see what is it.
>
> In fact, I've done a pie chart with my specific color,as I know in what
> order are the data, once I know associate each given a color. But I
> still have the problem of putting a title at a set of color, maybe I'll
> do it in the legend.
>
> thank you for your precious help.
>
> Do you know where find an help about the BIRT API ?
> Have a good week-end :d
Re: Customize a Pie Chart with Java under Eclispe [message #653894 is a reply to message #653885] Fri, 11 February 2011 18:02 Go to previous message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Also in Eclipse there is a view call Chart Examples that you can open
that will show you how to create a lot of different chart types.

Jason

On 2/11/2011 12:35 PM, kkt8 wrote:
> Oh yes, I'll see what is it.
>
> In fact, I've done a pie chart with my specific color,as I know in what
> order are the data, once I know associate each given a color. But I
> still have the problem of putting a title at a set of color, maybe I'll
> do it in the legend.
>
> thank you for your precious help.
>
> Do you know where find an help about the BIRT API ?
> Have a good week-end :d
Previous Topic:Chinese fonts
Next Topic:Crosstab inside of a table
Goto Forum:
  


Current Time: Wed Sep 17 09:41:07 GMT 2014

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

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