Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » [chart]Mixing stacked and unstacked bars
[chart]Mixing stacked and unstacked bars [message #907758] Tue, 04 September 2012 08:57 Go to next message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 59
Registered: July 2009
Member
(could be double post - if so delete this, their is something wrong here. after submitting a topic or reply i see the post but with no contents)

i just made my first steps with birt charting api. i created some stacked and not-stacked (grouped) bar charts, but i need also a mix of them: some of the bar series should be stacked and some of the should be grouped. how to achieve this?


(setting some but not all series to bs1.setStacked(true); yields an exception ... contains a mix of stacked and unstacked series.)
Re: [chart]Mixing stacked and unstacked bars [message #908030 is a reply to message #907758] Tue, 04 September 2012 15:07 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Currently I do not believe this is supported. Can you post a
screenshot of what you want it to look like, and I may be able to show
you another way to do this.

Jason

On 9/4/2012 4:57 AM, Missing name Mising name wrote:
> (could be double post - if so delete this, their is something wrong
> here. after submitting a topic or reply i see the post but with no
> contents)
>
> i just made my first steps with birt charting api. i created some
> stacked and not-stacked (grouped) bar charts, but i need also a mix of
> them: some of the bar series should be stacked and some of the should be
> grouped. how to achieve this?
>
>
> (setting some but not all series to bs1.setStacked(true); yields an
> exception ... contains a mix of stacked and unstacked series.)
>
>
Re: [chart]Mixing stacked and unstacked bars [message #908072 is a reply to message #908030] Tue, 04 September 2012 16:40 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

This is supported if you specify a new series definition for the
unstacked series. You can not mix stacked and unstacked in the same
series definition.

public Chart createStackedBar()

{

ChartWithAxes cwaBar = ChartWithAxesImpl.create();

cwaBar.setType("Bar Chart"); //$NON-NLS-1$

//cwaBar.setSubType("Stacked"); //$NON-NLS-1$


// Plot

cwaBar.getBlock().setBackground(ColorDefinitionImpl.WHITE());

cwaBar.getBlock().getOutline().setVisible(true);

Plot p = cwaBar.getPlot();

p.getClientArea().setBackground(ColorDefinitionImpl.create(255,

255,

225));

// Title

cwaBar.getTitle()

.getLabel()

.getCaption()

.setValue("Stacked Bar Chart"); //$NON-NLS-1$

// Legend

Legend lg = cwaBar.getLegend();

lg.setItemType(LegendItemType.CATEGORIES_LITERAL);


Axis xAxisPrimary = cwaBar.getPrimaryBaseAxes()[0];

xAxisPrimary.setType(AxisType.TEXT_LITERAL);


xAxisPrimary.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL);

xAxisPrimary.getOrigin().setType(IntersectionType.MIN_LITERAL);

// Y-Axis

Axis yAxisPrimary = cwaBar.getPrimaryOrthogonalAxis(xAxisPrimary);

yAxisPrimary.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL);

yAxisPrimary.setType(AxisType.LINEAR_LITERAL);

yAxisPrimary.setLabelPosition(Position.RIGHT_LITERAL);
yAxisPrimary.getLabel().getCaption().getFont().setRotation(45);



// Data Set

TextDataSet categoryValues = TextDataSetImpl.create(new String[] {
"Item 1a", "Item 2", "Item 3", "Item 4", "Item 5" }); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$

NumberDataSet orthoValues1 = NumberDataSetImpl.create(new double[] {

25, 35, 15, 5, 20

});

NumberDataSet orthoValues2 = NumberDataSetImpl.create(new double[] {

5, 10, 25, 10, 5

});
NumberDataSet orthoValues3 = NumberDataSetImpl.create(new double[] {

15, 12, 28, 10, 25

});
SampleData sd = DataFactory.eINSTANCE.createSampleData();

BaseSampleData sdBase = DataFactory.eINSTANCE.createBaseSampleData();

sdBase.setDataSetRepresentation("");//$NON-NLS-1$

sd.getBaseSampleData().add(sdBase);

OrthogonalSampleData sdOrthogonal1 = DataFactory.eINSTANCE
.createOrthogonalSampleData();

sdOrthogonal1.setDataSetRepresentation("");//$NON-NLS-1$

sdOrthogonal1.setSeriesDefinitionIndex(0);

sd.getOrthogonalSampleData().add(sdOrthogonal1);

OrthogonalSampleData sdOrthogonal2 = DataFactory.eINSTANCE
.createOrthogonalSampleData();

sdOrthogonal2.setDataSetRepresentation("");//$NON-NLS-1$

sdOrthogonal2.setSeriesDefinitionIndex(1);

sd.getOrthogonalSampleData().add(sdOrthogonal2);

cwaBar.setSampleData(sd);

// X-Series

Series seCategory = SeriesImpl.create();

seCategory.setDataSet(categoryValues);

SeriesDefinition sdX = SeriesDefinitionImpl.create();

xAxisPrimary.getSeriesDefinitions().add(sdX);

sdX.getSeries().add(seCategory);
sdX.getSeriesPalette().shift(0);

// Y-Series

BarSeries bs1 = (BarSeries) BarSeriesImpl.create();


bs1.setDataSet(orthoValues1);

bs1.setStacked(true);

bs1.getLabel().setVisible(true);

bs1.setLabelPosition(Position.INSIDE_LITERAL);
bs1.setRiserOutline(ColorDefinitionImpl.TRANSPARENT());

BarSeries bs2 = (BarSeries) BarSeriesImpl.create();

bs2.setDataSet(orthoValues2);

bs2.setStacked(true);

bs2.setRiserOutline(ColorDefinitionImpl.TRANSPARENT());
bs2.getLabel().setVisible(true);

bs2.setLabelPosition(Position.INSIDE_LITERAL);

BarSeries bs3 = (BarSeries) BarSeriesImpl.create();

bs3.setDataSet(orthoValues3);

bs3.setStacked(false);


SeriesDefinition sdY = SeriesDefinitionImpl.create();

sdY.getSeriesPalette().shift(0);

yAxisPrimary.getSeriesDefinitions().add(sdY);

SeriesDefinition sdY2 = SeriesDefinitionImpl.create();

sdY2.getSeriesPalette().shift(0);

yAxisPrimary.getSeriesDefinitions().add(sdY2);

sdY.getSeries().add(bs1);

sdY.getSeries().add(bs2);

sdY2.getSeries().add(bs3);

return cwaBar;

}

Jason

On 9/4/2012 11:07 AM, Jason Weathersby wrote:
> Currently I do not believe this is supported. Can you post a
> screenshot of what you want it to look like, and I may be able to show
> you another way to do this.
>
> Jason
>
> On 9/4/2012 4:57 AM, Missing name Mising name wrote:
>> (could be double post - if so delete this, their is something wrong
>> here. after submitting a topic or reply i see the post but with no
>> contents)
>>
>> i just made my first steps with birt charting api. i created some
>> stacked and not-stacked (grouped) bar charts, but i need also a mix of
>> them: some of the bar series should be stacked and some of the should be
>> grouped. how to achieve this?
>>
>>
>> (setting some but not all series to bs1.setStacked(true); yields an
>> exception ... contains a mix of stacked and unstacked series.)
>>
>>
>
Re: [chart]Mixing stacked and unstacked bars [message #908331 is a reply to message #908072] Wed, 05 September 2012 07:21 Go to previous message
moritz du is currently offline moritz duFriend
Messages: 98
Registered: February 2010
Member
thx! it is working
Previous Topic:Problem charting datetime
Next Topic:BIRT usage of Web Services
Goto Forum:
  


Current Time: Mon Dec 22 09:23:53 GMT 2014

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

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