Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » One meter chart with multiple datasets
One meter chart with multiple datasets [message #848652] Wed, 18 April 2012 09:02 Go to next message
Chris K is currently offline Chris K
Messages: 18
Registered: February 2012
Junior Member
Hi all!

I have problems generating a meter chart with multiple datasets via API (3.7.1). The interesting part of my class looks like:

protected void buildSeries() {
		
		String[] x = new String[] { "A", "B", "C"};
		Double[] y = new Double[] { 20.0, 30.0, 40.0 };

		TextDataSet categoryValues = TextDataSetImpl.create(x);
		NumberDataSet seriesValues = NumberDataSetImpl.create(y);

		// Base Series
		SeriesDefinition sd = SeriesDefinitionImpl.create();
		((ChartWithoutAxes) chart).getSeriesDefinitions().add(sd);

		Series seCategory = (Series) SeriesImpl.create();
		seCategory.setDataSet(categoryValues);
		sd.getSeriesPalette().shift(0);
		sd.getSeries().add(seCategory);

		// Orthogonal Series
		for (int i = 0; i < y.length; i++) {
			SeriesDefinition sdY = SeriesDefinitionImpl.create();
			sd.getSeriesDefinitions().add(sdY);
			DialSeries ds = (DialSeries) DialSeriesImpl.create();
			ds.setDataSet(seriesValues);
			sdY.getSeries().add(ds);
		}
	}


But as a result, only the first dataset "A" is visible, despite the fact that the whole plot ranges from 0.0 to 40.0, so somehow the other data is only considered for displaying the range.

How can I change my method in order to have one dialplot with several pointers?

Thank you very much! (:
Re: One meter chart with multiple datasets [message #849134 is a reply to message #848652] Wed, 18 April 2012 18:57 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Chris,

Are you intentionally trying to create three dial series with the same data?

Do you want three meter charts or one meter chart with 3 dials. Look at
this example from the source:

public static final Chart highlight_MeterChart( )
{
DialChart dChart = (DialChart) DialChartImpl.create( );
dChart.setDialSuperimposition( false );
dChart.setGridColumnCount( 2 );
dChart.setSeriesThickness( 25 );

// Title/Plot
dChart.getBlock( ).setBackground( ColorDefinitionImpl.WHITE( ) );
Plot p = dChart.getPlot( );
p.getClientArea( ).setBackground( ColorDefinitionImpl.CREAM( ) );
p.getClientArea( ).getOutline( ).setVisible( false );
p.getOutline( ).setVisible( false );

dChart.getTitle( ).getLabel( ).getCaption( ).setValue( "Meter Chart" );
dChart.getTitle( ).getOutline( ).setVisible( false );

// Legend
Legend lg = dChart.getLegend( );
LineAttributes lia = lg.getOutline( );
lg.getText( ).getFont( ).setSize( 16 );
lia.setStyle( LineStyle.SOLID_LITERAL );
lg.getInsets( ).setLeft( 10 );
lg.getInsets( ).setRight( 10 );
lg.setBackground( null );
lg.getOutline( ).setVisible( false );
lg.setShowValue( true );
lg.getClientArea( ).setBackground( ColorDefinitionImpl.PINK( ) );

lg.getClientArea( ).getOutline( ).setVisible( true );
lg.getTitle( ).getCaption( ).getFont( ).setSize( 20 );
lg.getTitle( ).setInsets( InsetsImpl.create( 10, 10, 10, 10 ) );
lg.setTitlePosition( Position.ABOVE_LITERAL );
lg.setPosition( Position.BELOW_LITERAL );
lg.setItemType( LegendItemType.SERIES_LITERAL );
lg.getTriggers( ).add(
TriggerImpl.create(
TriggerCondition.ONCLICK_LITERAL,
ActionImpl.create(
ActionType.HIGHLIGHT_LITERAL,
SeriesValueImpl.create( "not-used" ) ) ) ); //$NON-NLS-1$

TextDataSet categoryValues = TextDataSetImpl
.create( new String[]{"Moto"} );

SeriesDefinition sd = SeriesDefinitionImpl.create( );
dChart.getSeriesDefinitions( ).add( sd );
Series seCategory = (Series) SeriesImpl.create( );

seCategory.setDataSet( categoryValues );
sd.getSeries( ).add( seCategory );

SeriesDefinition sdCity = SeriesDefinitionImpl.create( );

final Fill[] fiaOrth = {ColorDefinitionImpl.PINK( ),
ColorDefinitionImpl.ORANGE( ), ColorDefinitionImpl.WHITE( )};
sdCity.getSeriesPalette( ).getEntries( ).clear( );
for ( int i = 0; i < fiaOrth.length; i++ )
{
sdCity.getSeriesPalette( ).getEntries( ).add( fiaOrth[i] );
}

// Dial 1
DialSeries seDial1 = (DialSeries) DialSeriesImpl.create( );
seDial1.setDataSet( NumberDataSetImpl.create( new double[]{20} ) );
seDial1.getDial( ).setFill(
GradientImpl.create(
ColorDefinitionImpl.create( 225, 255, 225 ),
ColorDefinitionImpl.create( 225, 225, 255 ),
45,
false ) );
seDial1.setSeriesIdentifier( "Temperature" );
seDial1.getNeedle( ).setDecorator( LineDecorator.CIRCLE_LITERAL );
seDial1.getDial( ).setStartAngle( -45 );
seDial1.getDial( ).setStopAngle( 225 );
seDial1.getDial( ).getMinorGrid( ).getTickAttributes( ).setVisible(
true );
seDial1.getDial( ).getMinorGrid( ).getTickAttributes( ).setColor(
ColorDefinitionImpl.BLACK( ) );
seDial1.getDial( ).getMinorGrid( ).setTickStyle(
TickStyle.BELOW_LITERAL );
seDial1
.getDial( )
.getScale( )
.setMin( NumberDataElementImpl.create( 0 ) );
seDial1.getDial( ).getScale( ).setMax(
NumberDataElementImpl.create( 90 ) );
seDial1.getDial( ).getScale( ).setStep( 10 );
seDial1.getLabel( ).setOutline(
LineAttributesImpl.create(
ColorDefinitionImpl.GREY( ).darker( ),
LineStyle.SOLID_LITERAL,
1 ) );
seDial1.getLabel( ).setBackground(
ColorDefinitionImpl.GREY( ).brighter( ) );

DialRegion dregion1 = DialRegionImpl.create( );
dregion1.setFill( ColorDefinitionImpl.GREEN( ) );
dregion1.setOutline( LineAttributesImpl.create( ColorDefinitionImpl
.BLACK( )
.darker( ), LineStyle.SOLID_LITERAL, 1 ) );
dregion1.setStartValue( NumberDataElementImpl.create( 70 ) );
dregion1.setEndValue( NumberDataElementImpl.create( 90 ) );
dregion1.setInnerRadius( 40 );
dregion1.setOuterRadius( -1 );
seDial1.getDial( ).getDialRegions( ).add( dregion1 );

DialRegion dregion2 = DialRegionImpl.create( );
dregion2.setFill( ColorDefinitionImpl.YELLOW( ) );
dregion2.setOutline( LineAttributesImpl.create( ColorDefinitionImpl
.BLACK( )
.darker( ), LineStyle.SOLID_LITERAL, 1 ) );
dregion2.setStartValue( NumberDataElementImpl.create( 40 ) );
dregion2.setEndValue( NumberDataElementImpl.create( 70 ) );
dregion2.setOuterRadius( 70 );
seDial1.getDial( ).getDialRegions( ).add( dregion2 );

DialRegion dregion3 = DialRegionImpl.create( );
dregion3.setFill( ColorDefinitionImpl.RED( ) );
dregion3.setOutline( LineAttributesImpl.create( ColorDefinitionImpl
.BLACK( )
.darker( ), LineStyle.SOLID_LITERAL, 1 ) );
dregion3.setStartValue( NumberDataElementImpl.create( 0 ) );
dregion3.setEndValue( NumberDataElementImpl.create( 40 ) );
dregion3.setInnerRadius( 40 );
dregion3.setOuterRadius( 90 );
seDial1.getDial( ).getDialRegions( ).add( dregion3 );

// Dial 2
DialSeries seDial2 = (DialSeries) DialSeriesImpl.create( );
seDial2.setDataSet( NumberDataSetImpl.create( new double[]{58} ) );
seDial2.getDial( ).setFill(
GradientImpl.create(
ColorDefinitionImpl.create( 225, 255, 225 ),
ColorDefinitionImpl.create( 225, 225, 255 ),
45,
false ) );
seDial2.setSeriesIdentifier( "Wind Speed" );
seDial2.getNeedle( ).setDecorator( LineDecorator.CIRCLE_LITERAL );
seDial2.getDial( ).setStartAngle( -45 );
seDial2.getDial( ).setStopAngle( 225 );
seDial2.getDial( ).getMinorGrid( ).getTickAttributes( ).setVisible(
true );
seDial2.getDial( ).getMinorGrid( ).getTickAttributes( ).setColor(
ColorDefinitionImpl.BLACK( ) );
seDial2.getDial( ).getMinorGrid( ).setTickStyle(
TickStyle.BELOW_LITERAL );
seDial2
.getDial( )
.getScale( )
.setMin( NumberDataElementImpl.create( 0 ) );
seDial2.getDial( ).getScale( ).setMax(
NumberDataElementImpl.create( 90 ) );
seDial2.getDial( ).getScale( ).setStep( 10 );
seDial2.getLabel( ).setOutline(
LineAttributesImpl.create(
ColorDefinitionImpl.GREY( ).darker( ),
LineStyle.SOLID_LITERAL,
1 ) );
seDial2.getLabel( ).setBackground(
ColorDefinitionImpl.GREY( ).brighter( ) );

seDial2.getDial( ).getDialRegions( ).add( dregion1 );
seDial2.getDial( ).getDialRegions( ).add( dregion2 );
seDial2.getDial( ).getDialRegions( ).add( dregion3 );

// Dial 3
DialSeries seDial3 = (DialSeries) DialSeriesImpl.create( );
seDial3.setDataSet( NumberDataSetImpl.create( new double[]{80} ) );
seDial3.getDial( ).setFill(
GradientImpl.create(
ColorDefinitionImpl.create( 225, 255, 225 ),
ColorDefinitionImpl.create( 225, 225, 255 ),
45,
false ) );
seDial3.setSeriesIdentifier( "Viscosity" );
seDial3.getNeedle( ).setDecorator( LineDecorator.CIRCLE_LITERAL );
seDial3.getDial( ).setStartAngle( -45 );
seDial3.getDial( ).setStopAngle( 225 );
seDial3.getDial( ).getMinorGrid( ).getTickAttributes( ).setVisible(
true );
seDial3.getDial( ).getMinorGrid( ).getTickAttributes( ).setColor(
ColorDefinitionImpl.BLACK( ) );
seDial3.getDial( ).getMinorGrid( ).setTickStyle(
TickStyle.BELOW_LITERAL );
seDial3
.getDial( )
.getScale( )
.setMin( NumberDataElementImpl.create( 0 ) );
seDial3.getDial( ).getScale( ).setMax(
NumberDataElementImpl.create( 90 ) );
seDial3.getDial( ).getScale( ).setStep( 10 );
seDial3.getLabel( ).setOutline(
LineAttributesImpl.create(
ColorDefinitionImpl.GREY( ).darker( ),
LineStyle.SOLID_LITERAL,
1 ) );
seDial3.getLabel( ).setBackground(
ColorDefinitionImpl.GREY( ).brighter( ) );

seDial3.getDial( ).getDialRegions( ).add( dregion1 );
seDial3.getDial( ).getDialRegions( ).add( dregion2 );
seDial3.getDial( ).getDialRegions( ).add( dregion3 );

dChart.setDialSuperimposition( true );
sd.getSeriesDefinitions( ).add( sdCity );
sdCity.getSeries( ).add( seDial1 );
sdCity.getSeries( ).add( seDial2 );
sdCity.getSeries( ).add( seDial3 );

return dChart;

}


Jason

On 4/18/2012 9:02 AM, Chris K wrote:
> Hi all!
>
> I have problems generating a meter chart with multiple datasets via API
> (3.7.1). The interesting part of my class looks like:
>
>
> protected void buildSeries() {
>
> String[] x = new String[] { "A", "B", "C"};
> Double[] y = new Double[] { 20.0, 30.0, 40.0 };
>
> TextDataSet categoryValues = TextDataSetImpl.create(x);
> NumberDataSet seriesValues = NumberDataSetImpl.create(y);
>
> // Base Series
> SeriesDefinition sd = SeriesDefinitionImpl.create();
> ((ChartWithoutAxes) chart).getSeriesDefinitions().add(sd);
>
> Series seCategory = (Series) SeriesImpl.create();
> seCategory.setDataSet(categoryValues);
> sd.getSeriesPalette().shift(0);
> sd.getSeries().add(seCategory);
>
> // Orthogonal Series
> for (int i = 0; i < y.length; i++) {
> SeriesDefinition sdY = SeriesDefinitionImpl.create();
> sd.getSeriesDefinitions().add(sdY);
> DialSeries ds = (DialSeries) DialSeriesImpl.create();
> ds.setDataSet(seriesValues);
> sdY.getSeries().add(ds);
> }
> }
>
>
> But as a result, only the first dataset "A" is visible, despite the fact
> that the whole plot ranges from 0.0 to 40.0, so somehow the other data
> is only considered for displaying the range.
>
> How can I change my method in order to have one dialplot with several
> pointers?
>
> Thank you very much! (:
Re: One meter chart with multiple datasets [message #849567 is a reply to message #849134] Thu, 19 April 2012 05:03 Go to previous message
Chris K is currently offline Chris K
Messages: 18
Registered: February 2012
Junior Member
wow, thank you jason! That did the trick.
Previous Topic:Report generation failing at excel generation
Next Topic:Using BIRT with jsf4birt.jar on tomcat server/websphere
Goto Forum:
  


Current Time: Sat Jul 26 03:24:45 EDT 2014

Powered by FUDForum. Page generated in 0.01547 seconds