Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » How to hide an item from a choosen Legend on 2 Y-Axis chart?
How to hide an item from a choosen Legend on 2 Y-Axis chart? [message #644314] Fri, 10 December 2010 09:00 Go to next message
Stanislav  is currently offline Stanislav
Messages: 10
Registered: December 2010
Junior Member
Hi,

I have a chart with number X axis, String category grouping and 2 Y axises (Line series) with numbers.
I have 4 lines, 3 for the first Y axis and 1 for the 2nd axis.
Unfortunately in the Legend I have 4 labels for each of the two Y axies i.e. 8 labels in total.
I want to have 3 labels for the first Y axis and 1 for the second.

http://pics.daskalov.net/Chart.JPG

so I want to see the Man, Lon and Liv labels from "Y1 series" and the UK on "Y2 series".
I wrote some code in beforeDrawLegendItem and I can hide them but it is too complicated and I do not trust that code.
Is there a way to hide the legend for anyone but the first axis?
Here you can download the the report design and the 2 CVS files. You only need to set correct pathnames for data sources.

Thanks in advance.

[Updated on: Fri, 10 December 2010 09:01]

Report message to a moderator

Re: How to hide an item from a choosen Legend on 2 Y-Axis chart? [message #644353 is a reply to message #644314] Fri, 10 December 2010 11:26 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Can you post the script you are using?

Jason

On 12/10/2010 9:00 AM, Stanislav wrote:
> Hi,
>
> I have a chart with number X axis, String category grouping and 2 Y
> axises (Line series) with numbers.
> I have 4 lines, 3 for the first Y axis and 1 for the 2nd axis.
> Unfortunately in the Legend I have 4 labels for each of the two Y axies
> i.e. 8 labels in total.
> I want to have 3 labels for the first Y axis and 1 for the second.
>
>
>
> so I want to see the Man, Lon and Liv labels from "Y1 series" and the UK
> on "Y2 series".
> I wrote some code in beforeDrawLegendItem and I can hide them but it is
> too complicated and I do not trust that code.
> Is there a way to hide the legend for anyone but the first axis?
> http://pics.daskalov.net/BIRT/chartReportDesign.zip you can download the
> the report design and the 2 CVS files. You only need to set correct
> pathnames for data sources.
>
> Thanks in advance.


Jason Weathersby

BIRT Exchange
Re: How to hide an item from a choosen Legend on 2 Y-Axis chart? [message #644611 is a reply to message #644353] Mon, 13 December 2010 08:13 Go to previous messageGo to next message
Stanislav  is currently offline Stanislav
Messages: 10
Registered: December 2010
Junior Member
Sorry, I do not understand what do you mean with "script"?
The .rptdesign file together with both CSV files used as data sets is in the zip file (http://pics.daskalov.net/BIRT/chartReportDesign.zip).
Re: How to hide an item from a choosen Legend on 2 Y-Axis chart? [message #644659 is a reply to message #644611] Mon, 13 December 2010 11:38 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

I thought you said you had a script working but you did not trust it.

I did not see the script in the report.

Jason

On 12/13/2010 8:13 AM, Stanislav wrote:
> Sorry, I do not understand what do you mean with "script"?
> The .rptdesign file together with both CSV files used as data sets is in
> the zip file (http://pics.daskalov.net/BIRT/chartReportDesign.zip).


Jason Weathersby

BIRT Exchange
Re: How to hide an item from a choosen Legend on 2 Y-Axis chart? [message #644866 is a reply to message #644659] Tue, 14 December 2010 09:27 Go to previous messageGo to next message
Stanislav  is currently offline Stanislav
Messages: 10
Registered: December 2010
Junior Member
The script associated to that chart was :

function beforeDrawLegendItem( lerh, bounds, icsc )
{
importPackage(Packages.org.eclipse.birt.chart.model.attribut e);

if (lerh.getFill().getBlue() == lerh.getFill().getGreen()) {
if (lerh.getFill().getBlue() == lerh.getFill().getRed()) {
if (lerh.getFill().getBlue() < 5) {
importPackage( Packages.org.eclipse.birt.chart.model.attribute.impl );
var mycolor = ColorDefinitionImpl.TRANSPARENT();
r = mycolor.getRed();
g = mycolor.getGreen();
b = mycolor.getBlue();
lerh.getFill().set(r, g, b);

lerh.getLabel().setVisible(false);

return;
}
}
}

if( lerh.getLabel().getCaption().getValue() == "UK"){
importPackage( Packages.org.eclipse.birt.chart.model.attribute.impl );
var mycolor = ColorDefinitionImpl.TRANSPARENT();
r = mycolor.getRed();
g = mycolor.getGreen();
b = mycolor.getBlue();
lerh.getFill().set(r, g, b);

lerh.getLabel().setVisible(false);
}
}



/**
* Called after drawing the legend item.
*
* @param lerh
* LegendEntryRenderingHints
* @param bounds
* Bounds
* @param icsc
* IChartScriptContext
* @since Version 2.2.0
*/

function afterDrawLegendItem( lerh, bounds, icsc )
{
lerh.getLabel().setVisible(true);
}


------------------------
and to work it needs all colours in the pallete for second Y axis to be black.
Very amateur solution Sad.
That';s why I hope there is a more proper solution. May be even adding a filter to the each of axises (so I might remove all vunneded values that are used as Legend items later)

Thanks.

[Updated on: Tue, 14 December 2010 09:28]

Report message to a moderator

Re: How to hide an item from a choosen Legend on 2 Y-Axis chart? [message #644904 is a reply to message #644866] Tue, 14 December 2010 11:51 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Unfortunately modifying the legend can be complicated. You can move the
order around delete entries etc, but the code can be quite complex. In
you example can you turn on the value Label in the legend and then do
something like:

function beforeDrawLegendItem( lerh, bounds, icsc )
{


if( lerh.getValueLabel().getCaption().getValue() == null){
bounds.setHeight(0);
bounds.setWidth(0);
lerh.getLabel().setVisible(false);
lerh.getValueLabel().setVisible(false);
lerh.getValueLabel().getCaption().setValue("");
}else{
lerh.getLabel().setVisible(true)
lerh.getValueLabel().setVisible(true);
}
}

Jason

On 12/14/2010 9:27 AM, Stanislav wrote:
> Teh script associated to that cahrt was :
>
> function beforeDrawLegendItem( lerh, bounds, icsc )
> {
> importPackage(Packages.org.eclipse.birt.chart.model.attribut e);
>
> if (lerh.getFill().getBlue() == lerh.getFill().getGreen()) {
> if (lerh.getFill().getBlue() == lerh.getFill().getRed()) {
> if (lerh.getFill().getBlue() < 5) {
> importPackage( Packages.org.eclipse.birt.chart.model.attribute.impl );
> var mycolor = ColorDefinitionImpl.TRANSPARENT();
> r = mycolor.getRed();
> g = mycolor.getGreen();
> b = mycolor.getBlue();
> lerh.getFill().set(r, g, b);
> lerh.getLabel().setVisible(false);
> return;
> }
> }
> }
>
> if( lerh.getLabel().getCaption().getValue() == "UK"){
> importPackage( Packages.org.eclipse.birt.chart.model.attribute.impl );
> var mycolor = ColorDefinitionImpl.TRANSPARENT();
> r = mycolor.getRed();
> g = mycolor.getGreen();
> b = mycolor.getBlue();
> lerh.getFill().set(r, g, b);
> lerh.getLabel().setVisible(false);
> }
> }
>
>
>
> /**
> * Called after drawing the legend item.
> * * @param lerh
> * LegendEntryRenderingHints
> * @param bounds
> * Bounds
> * @param icsc
> * IChartScriptContext
> * @since Version 2.2.0
> */
>
> function afterDrawLegendItem( lerh, bounds, icsc )
> {
> lerh.getLabel().setVisible(true);
> }
>
>
> ------------------------
> and to work it needs all colours in the pallete for second Y axis to be
> black.
> Very amateur solution :(.
> That';s why I hope there is a more proper solution. May be even adding a
> filter to the each of axises (so I might remove all vunneded values that
> are used as Legend items later)
>
> Thanks.


Jason Weathersby

BIRT Exchange
Re: How to hide an item from a choosen Legend on 2 Y-Axis chart? [message #645275 is a reply to message #644904] Thu, 16 December 2010 07:05 Go to previous messageGo to next message
Stanislav  is currently offline Stanislav
Messages: 10
Registered: December 2010
Junior Member
Thanks you for the example - it works almost perfect.
The only issue is that even when I hide the value labels they still take place and alignment of the legen items is not good enought (you have a lot of empty space).
Is there a way to say to the chart object or any other component to re-align all visible components ?

thanks again for the help.
Re: How to hide an item from a choosen Legend on 2 Y-Axis chart? [message #645366 is a reply to message #645275] Thu, 16 December 2010 13:37 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

This becomes quite complex when you want to changes the bounds (fill
holes). See attached example where a lot of hard coding had to occur.
Essentially I took the beforeRender script and rebuilt the legend.

Jason


<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.21"
id="1">
<property name="createdBy">Eclipse BIRT Designer Version
2.5.2.v20100208 Build &lt;2.5.2.v20100210-0630></property>
<property name="units">in</property>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="bidiLayoutOrientation">ltr</property>
<data-sources>
<oda-data-source
extensionID="org.eclipse.datatools.connectivity.oda.flatfile "
name="CVSs" id="63">
<property name="HOME">C:\test35\chartReportDesign</property>
<property name="DELIMTYPE">COMMA</property>
<property name="CHARSET">UTF-8</property>
<property name="INCLCOLUMNNAME">YES</property>
<property name="INCLTYPELINE">NO</property>
</oda-data-source>
</data-sources>
<data-sets>
<oda-data-set
extensionID="org.eclipse.datatools.connectivity.oda.flatfile.dataSet "
name="Temperatures" id="64">
<list-property name="computedColumns">
<structure>
<property name="name">teperatureAsInt</property>
<expression
name="expression">parseInt(row["temperature"])</expression >
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">hourAsInt</property>
<expression
name="expression">parseInt(row["hour"])</expression>
<property name="dataType">integer</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">temperature</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">hour</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">city</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">4</property>
<property name="name">teperatureAsInt</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">5</property>
<property name="name">hourAsInt</property>
<property name="dataType">integer</property>
</structure>
</list-property>
</structure>
<property name="dataSource">CVSs</property>
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">temperature</property>
<property name="nativeName">temperature</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">hour</property>
<property name="nativeName">hour</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">city</property>
<property name="nativeName">city</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
</list-property>
<xml-property name="queryText"><![CDATA[select
"temperature", "hour", "city" from temperatures.txt :
{"temperature","temperature",STRING;"hour","hour",STRING; "city","city",STRING}]]></xml-property>
<xml-property name="designerValues"><![CDATA[<?xml
version="1.0" encoding="UTF-8"?>
<model:DesignValues
xmlns:design="http://www.eclipse.org/datatools/connectivity/oda/design"
xmlns:model="http://www.eclipse.org/birt/report/model/adapter/odaModel">
<Version>1.0</Version>
<design:ResultSets derivedMetaData="true">
<design:resultSetDefinitions>
<design:resultSetColumns>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>temperature</design:name>
<design:position>1</design:position>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>-1</design:precision>
<design:scale>-1</design:scale>
<design:nullability>Unknown</design:nullability>
</design:attributes>
<design:usageHints>
<design:label>temperature</design:label>
<design:formattingHints/>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>date</design:name>
<design:position>2</design:position>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>-1</design:precision>
<design:scale>-1</design:scale>
<design:nullability>Unknown</design:nullability>
</design:attributes>
<design:usageHints>
<design:label>date</design:label>
<design:formattingHints/>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>city</design:name>
<design:position>3</design:position>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>-1</design:precision>
<design:scale>-1</design:scale>
<design:nullability>Unknown</design:nullability>
</design:attributes>
<design:usageHints>
<design:label>city</design:label>
<design:formattingHints/>
</design:usageHints>
</design:resultColumnDefinitions>
</design:resultSetColumns>
</design:resultSetDefinitions>
</design:ResultSets>
</model:DesignValues>]]></xml-property>
</oda-data-set>
<oda-data-set
extensionID="org.eclipse.datatools.connectivity.oda.flatfile.dataSet "
name="Crashes" id="65">
<list-property name="computedColumns">
<structure>
<property name="name">hourAsInt</property>
<expression
name="expression">parseInt(row["hour"])</expression>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">countAsInt</property>
<expression
name="expression">parseInt(row["count"])</expression>
<property name="dataType">integer</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">count</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">hour</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">Country</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">4</property>
<property name="name">hourAsInt</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">5</property>
<property name="name">countAsInt</property>
<property name="dataType">integer</property>
</structure>
</list-property>
</structure>
<property name="dataSource">CVSs</property>
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">count</property>
<property name="nativeName">count</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">hour</property>
<property name="nativeName">hour</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">Country</property>
<property name="nativeName">Country</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
</list-property>
<xml-property name="queryText"><![CDATA[select "count",
"hour", "Country" from crashes.txt :
{"count","count",STRING;"hour","hour",STRING;"Country ","Country",STRING}]]></xml-property>
<xml-property name="designerValues"><![CDATA[<?xml
version="1.0" encoding="UTF-8"?>
<model:DesignValues
xmlns:design="http://www.eclipse.org/datatools/connectivity/oda/design"
xmlns:model="http://www.eclipse.org/birt/report/model/adapter/odaModel">
<Version>1.0</Version>
<design:ResultSets derivedMetaData="true">
<design:resultSetDefinitions>
<design:resultSetColumns>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>count</design:name>
<design:position>1</design:position>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>-1</design:precision>
<design:scale>-1</design:scale>
<design:nullability>Unknown</design:nullability>
</design:attributes>
<design:usageHints>
<design:label>count</design:label>
<design:formattingHints/>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>date</design:name>
<design:position>2</design:position>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>-1</design:precision>
<design:scale>-1</design:scale>
<design:nullability>Unknown</design:nullability>
</design:attributes>
<design:usageHints>
<design:label>date</design:label>
<design:formattingHints/>
</design:usageHints>
</design:resultColumnDefinitions>
</design:resultSetColumns>
</design:resultSetDefinitions>
</design:ResultSets>
</model:DesignValues>]]></xml-property>
</oda-data-set>
<joint-data-set name="TEST" id="89">
<list-property name="computedColumns">
<structure>
<property name="name">category</property>
<expression name="expression">if (row["city"] ==
null) {&#13;
row["Country"]&#13;
}&#13;
else {&#13;
row["city"]&#13;
}</expression>
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">totalHour</property>
<expression name="expression">if
(row["Temperatures::hour"] == null) {&#13;
row["Crashes::hourAsInt"]&#13;
}&#13;
else {&#13;
row["Temperatures::hourAsInt"]&#13;
}</expression>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">totalValue</property>
<expression name="expression">if
(row["temperature"] == null) {&#13;
row["countAsInt"]&#13;
}&#13;
else {&#13;
row["teperatureAsInt"]&#13;
}</expression>
<property name="dataType">integer</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property
name="columnName">Temperatures::teperatureAsInt</property >
<property name="alias">teperatureAsInt</property>
<text-property
name="displayName">Temperatures::teperatureAsInt</text-property >
</structure>
<structure>
<property name="columnName">Crashes::count</property>
<property name="alias">count</property>
<text-property
name="displayName">Crashes::count</text-property>
</structure>
<structure>
<property
name="columnName">Temperatures::hourAsInt</property>
<property
name="alias">Temperatures::hourAsInt</property>
<text-property
name="displayName">Temperatures::hourAsInt</text-property >
</structure>
<structure>
<property
name="columnName">Crashes::hourAsInt</property>
<property name="alias">Crashes::hourAsInt</property>
<text-property
name="displayName">Crashes::hourAsInt</text-property>
</structure>
<structure>
<property
name="columnName">Temperatures::hour</property>
<property name="alias">Temperatures::hour</property>
<text-property
name="displayName">Temperatures::hour</text-property>
</structure>
<structure>
<property name="columnName">Crashes::hour</property>
<property name="alias">Crashes::hour</property>
<text-property
name="displayName">Crashes::hour</text-property>
</structure>
<structure>
<property name="columnName">Crashes::Country</property>
<property name="alias">Country</property>
<text-property
name="displayName">Crashes::Country</text-property>
</structure>
<structure>
<property
name="columnName">Crashes::countAsInt</property>
<property name="alias">countAsInt</property>
<text-property
name="displayName">Crashes::countAsInt</text-property>
</structure>
<structure>
<property
name="columnName">Temperatures::city</property>
<property name="alias">city</property>
<text-property
name="displayName">Temperatures::city</text-property>
</structure>
<structure>
<property
name="columnName">Temperatures::temperature</property>
<property name="alias">temperature</property>
<text-property
name="displayName">Temperatures::temperature</text-property >
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">temperature</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">Temperatures::hour</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">city</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">4</property>
<property name="name">teperatureAsInt</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">5</property>
<property
name="name">Temperatures::hourAsInt</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">6</property>
<property name="name">count</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">7</property>
<property name="name">Crashes::hour</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">8</property>
<property name="name">Country</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">9</property>
<property name="name">Crashes::hourAsInt</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">10</property>
<property name="name">countAsInt</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">11</property>
<property name="name">category</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">12</property>
<property name="name">totalHour</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">13</property>
<property name="name">totalValue</property>
<property name="dataType">integer</property>
</structure>
</list-property>
</structure>
<simple-property-list name="dataSets">
<value>Temperatures</value>
<value>Crashes</value>
</simple-property-list>
<list-property name="joinConditions">
<structure>
<property name="joinType">full-out</property>
<property name="joinOperator">eq</property>
<property name="leftDataSet">Temperatures</property>
<property name="rightDataSet">Crashes</property>
<expression
name="leftExpression">dataSetRow["city"]</expression>
<expression
name="rightExpression">dataSetRow["Country"]</expression >
</structure>
</list-property>
</joint-data-set>
</data-sets>
<styles>
<style name="report" id="4">
<property name="fontFamily">sans-serif</property>
<property name="fontSize">10pt</property>
</style>
<style name="crosstab-cell" id="5">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="crosstab" id="6">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property
name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<extended-item extensionName="Chart" name="CHART" id="91">
<xml-property
name="xmlRepresentation"><![CDATA[<model:ChartWithAxes
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:attribute="http://www.birt.eclipse.org/ChartModelAttribute"
xmlns:data="http://www.birt.eclipse.org/ChartModelData"
xmlns:layout="http://www.birt.eclipse.org/ChartModelLayout"
xmlns:model="http://www.birt.eclipse.org/ChartModel"
xmlns:type="http://www.birt.eclipse.org/ChartModelType">
<Version>2.5.1</Version>
<Type>Line Chart</Type>
<SubType>Overlay</SubType>
<Block>
<Children xsi:type="layout:TitleBlock">
<Bounds>
<Left>0.0</Left>
<Top>0.0</Top>
<Width>0.0</Width>
<Height>0.0</Height>
</Bounds>
<Insets>
<Top>3.0</Top>
<Left>3.0</Left>
<Bottom>3.0</Bottom>
<Right>3.0</Right>
</Insets>
<Row>-1</Row>
<Column>-1</Column>
<Rowspan>-1</Rowspan>
<Columnspan>-1</Columnspan>
<Outline>
<Style>Solid</Style>
<Thickness>1</Thickness>
<Color>
<Transparency>255</Transparency>
<Red>0</Red>
<Green>0</Green>
<Blue>0</Blue>
</Color>
<Visible>false</Visible>
</Outline>
<Visible>true</Visible>
<Label>
<Caption>
<Value>Line Chart Title</Value>
<Font>
<Size>16.0</Size>
<Bold>true</Bold>
<Alignment>
<horizontalAlignment>Center</horizontalAlignment>
<verticalAlignment>Center</verticalAlignment>
</Alignment>
</Font>
</Caption>
<Background xsi:type="attribute:ColorDefinition">
<Transparency>0</Transparency>
<Red>255</Red>
<Green>255</Green>
<Blue>255</Blue>
</Background>
<Outline>
<Style>Solid</Style>
<Thickness>1</Thickness>
<Color>
<Transparency>255</Transparency>
<Red>0</Red>
<Green>0</Green>
<Blue>0</Blue>
</Color>
</Outline>
<Insets>
<Top>0.0</Top>
<Left>2.0</Left>
<Bottom>0.0</Bottom>
<Right>3.0</Right>
</Insets>
<Visible>true</Visible>
</Label>
</Children>
<Children xsi:type="layout:Plot">
<Bounds>
<Left>0.0</Left>
<Top>0.0</Top>
<Width>0.0</Width>
<Height>0.0</Height>
</Bounds>
<Insets>
<Top>3.0</Top>
<Left>3.0</Left>
<Bottom>3.0</Bottom>
<Right>3.0</Right>
</Insets>
<Row>-1</Row>
<Column>-1</Column>
<Rowspan>-1</Rowspan>
<Columnspan>-1</Columnspan>
<Outline>
<Style>Solid</Style>
<Thickness>1</Thickness>
<Color>
<Transparency>255</Transparency>
<Red>0</Red>
<Green>0</Green>
<Blue>0</Blue>
</Color>
<Visible>false</Visible>
</Outline>
<Visible>true</Visible>
<HorizontalSpacing>5</HorizontalSpacing>
<VerticalSpacing>5</VerticalSpacing>
<ClientArea>
<Outline>
<Style>Solid</Style>
<Thickness>0</Thickness>
<Color>
<Transparency>255</Transparency>
<Red>0</Red>
<Green>0</Green>
<Blue>0</Blue>
</Color>
<Visible>false</Visible>
</Outline>
<Insets>
<Top>0.0</Top>
<Left>0.0</Left>
<Bottom>0.0</Bottom>
<Right>0.0</Right>
</Insets>
</ClientArea>
</Children>
<Children xsi:type="layout:Legend">
<Bounds>
<Left>0.0</Left>
<Top>0.0</Top>
<Width>0.0</Width>
<Height>0.0</Height>
</Bounds>
<Stretch>Horizontal</Stretch>
<Insets>
<Top>3.0</Top>
<Left>3.0</Left>
<Bottom>3.0</Bottom>
<Right>3.0</Right>
</Insets>
<Row>-1</Row>
<Column>-1</Column>
<Rowspan>-1</Rowspan>
<Columnspan>-1</Columnspan>
<Outline>
<Style>Solid</Style>
<Thickness>1</Thickness>
<Color>
<Transparency>255</Transparency>
<Red>0</Red>
<Green>0</Green>
<Blue>0</Blue>
</Color>
<Visible>false</Visible>
</Outline>
<Visible>true</Visible>
<ClientArea>
<Outline>
<Style>Solid</Style>
<Thickness>0</Thickness>
<Color>
<Transparency>255</Transparency>
<Red>0</Red>
<Green>0</Green>
<Blue>0</Blue>
</Color>
<Visible>false</Visible>
</Outline>
<Insets>
<Top>2.0</Top>
<Left>2.0</Left>
<Bottom>2.0</Bottom>
<Right>2.0</Right>
</Insets>
</ClientArea>
<Text>
<Value></Value>
<Font>
<Alignment/>
</Font>
</Text>
<Orientation>Horizontal</Orientation>
<Direction>Left_Right</Direction>
<Separator>
<Style>Solid</Style>
<Thickness>1</Thickness>
<Color>
<Transparency>255</Transparency>
<Red>0</Red>
<Green>0</Green>
<Blue>0</Blue>
</Color>
<Visible>true</Visible>
</Separator>
<Position>Below</Position>
<ItemType>Series</ItemType>
<Title>
<Caption>
<Value></Value>
<Font>
<Alignment/>
</Font>
</Caption>
<Background xsi:type="attribute:ColorDefinition">
<Transparency>0</Transparency>
<Red>255</Red>
<Green>255</Green>
<Blue>255</Blue>
</Background>
<Outline>
<Style>Solid</Style>
<Thickness>1</Thickness>
<Color>
<Transparency>255</Transparency>
<Red>0</Red>
<Green>0</Green>
<Blue>0</Blue>
</Color>
<Visible>false</Visible>
</Outline>
<Insets>
<Top>0.0</Top>
<Left>2.0</Left>
<Bottom>0.0</Bottom>
<Right>3.0</Right>
</Insets>
<Visible>false</Visible>
</Title>
<TitlePosition>Above</TitlePosition>
<ShowValue>false</ShowValue>
</Children>
<Bounds>
<Left>0.0</Left>
<Top>0.0</Top>
<Width>569.25</Width>
<Height>348.0</Height>
</Bounds>
<Insets>
<Top>3.0</Top>
<Left>3.0</Left>
<Bottom>3.0</Bottom>
<Right>3.0</Right>
</Insets>
<Row>-1</Row>
<Column>-1</Column>
<Rowspan>-1</Rowspan>
<Columnspan>-1</Columnspan>
<Outline>
<Style>Solid</Style>
<Thickness>1</Thickness>
<Color>
<Transparency>255</Transparency>
<Red>0</Red>
<Green>0</Green>
<Blue>0</Blue>
</Color>
<Visible>false</Visible>
</Outline>
<Background xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>255</Red>
<Green>255</Green>
<Blue>255</Blue>
</Background>
<Visible>true</Visible>
</Block>
<Dimension>Two_Dimensional</Dimension>
<Script>&#xD;
&#xD;
function beforeRendering( gcs, icsc )&#xD;
{&#xD;
&#xD;
importPackage( Packages.java.util );&#xD;
importPackage( Packages.java.io );&#xD;
importPackage(Packages.org.eclipse.birt.chart.model.type.imp l);&#xD;
importPackage(Packages.org.eclipse.birt.chart.model.componen t.impl);&#xD;
importPackage(Packages.org.eclipse.birt.chart.model.type);&a mp;#xD;
importPackage(Packages.org.eclipse.birt.chart.model.componen t);&#xD;
importPackage(Packages.org.eclipse.birt.chart.computation);& amp;#xD;
&#xD;
var llh = gcs.getRunTimeContext().getLegendLayoutHints();&#xD;
var liha = llh.getLegendItemHints( );&#xD;
var nliha = [];//new LegendItemHints[liha.length-1];&#xD;
var grp=0&#xD;
if ( liha.length > 1 ){&#xD;
nidx = 0;&#xD;
for( idx=0; idx &lt; liha.length; idx++ ){&#xD;
&#xD;
tli = liha[idx];&#xD;
var currtop = tli.getTop();&#xD;
if( tli.getType() == LegendItemHints.Type.LG_ENTRY){&#xD;
lih = LegendItemHints.newEntry( tli.getItemText(),
tli.getValueText(), tli.getSeriesDefinition(), tli.getSeries(),
tli.getIndex() );&#xD;
lih.top(currtop);&#xD;
//lih.left(tli.getLeft());&#xD;
if( tli.getItemText() == &quot;UK&quot; &amp;&amp; grp ==
1){&#xD;
//delete entry&#xD;
&#xD;
}else if( tli.getItemText() != &quot;UK&quot; &amp;&amp; grp
> 1){&#xD;
//delete entry&#xD;
&#xD;
}else{&#xD;
if( tli.getItemText() == &quot;UK&quot; &amp;&amp; grp >
1){&#xD;
lih.left(liha[nidx].getLeft()+30);&#xD;
}else{&#xD;
lih.left(liha[nidx].getLeft());&#xD;
}&#xD;
nliha[nidx]=lih;&#xD;
nidx++;&#xD;
}&#xD;
&#xD;
}else if( tli.getType() ==
LegendItemHints.Type.LG_GROUPNAME){&#xD;
//new group Y Series 1 and Y Series 2 Labels&#xD;
lih = LegendItemHints.newGroupNameEntry( tli.getItemText()
);&#xD;
lih.top(currtop);&#xD;
if( tli.getItemText() == &quot;Y2 series&quot; ){&#xD;
lih.left(liha[nidx-1].getLeft()+30);&#xD;
}else{&#xD;
lih.left(liha[nidx].getLeft());&#xD;
}&#xD;
grp++;&#xD;
nliha[nidx]= lih;&#xD;
nidx++; &#xD;
}else if( tli.getType() ==
LegendItemHints.Type.LG_SEPERATOR){&#xD;
// bar separators&#xD;
lih = LegendItemHints.createSeperator();&#xD;
lih.top(currtop);&#xD;
lih.width(tli.getWidth());&#xD;
lih.left(liha[nidx].getLeft());&#xD;
lih.itemHeight(liha[nidx].getItemHeight()); &#xD;
grp++;&#xD;
nliha[nidx]= lih;&#xD;
nidx++; &#xD;
} &#xD;
}&#xD;
} &#xD;
nllh = new LegendLayoutHints(
llh.getLegendSize(),llh.getTitleSize(),null,
llh.isMinSliceApplied(),llh.getMinSliceText(),nliha );&#xD;
gcs.getRunTimeContext().setLegendLayoutHints(nllh);&#xD;
}&#xD;


function beforeDrawBlock( block, icsc )
{&#xD;
//Bump legend over&#xD;
if( block.isLegend() ){&#xD;
block.getBounds().setLeft(block.getBounds().getLeft()+70);&a mp;#xD;
}
}
</Script>
<Units>Points</Units>
<SeriesThickness>10.0</SeriesThickness>
<ExtendedProperties>
<Name>enable.area.alt</Name>
<Value>false</Value>
</ExtendedProperties>
<SampleData>
<BaseSampleData>
<DataSetRepresentation>6,4,12,8,10</DataSetRepresentation>
</BaseSampleData>
<OrthogonalSampleData>
<DataSetRepresentation>6,4,12,8,10</DataSetRepresentation>
<SeriesDefinitionIndex>0</SeriesDefinitionIndex>
</OrthogonalSampleData>
<OrthogonalSampleData>
<DataSetRepresentation>42,91,62,9,21</DataSetRepresentation >
<SeriesDefinitionIndex>1</SeriesDefinitionIndex>
</OrthogonalSampleData>
</SampleData>
<Interactivity>
<Enable>false</Enable>
<LegendBehavior>None</LegendBehavior>
</Interactivity>
<EmptyMessage>
<Caption>
<Value>This chart contains no data.</Value>
<Font>
<Alignment>
<horizontalAlignment>Center</horizontalAlignment>
<verticalAlignment>Center</verticalAlignment>
</Alignment>
</Font>
</Caption>
<Background xsi:type="attribute:ColorDefinition">
<Transparency>64</Transparency>
<Red>127</Red>
<Green>127</Green>
<Blue>127</Blue>
</Background>
<Outline>
<Color>
<Transparency>128</Transparency>
<Red>127</Red>
<Green>127</Green>
<Blue>127</Blue>
</Color>
<Visible>true</Visible>
</Outline>
<Insets>
<Top>10.0</Top>
<Left>10.0</Left>
<Bottom>10.0</Bottom>
<Right>10.0</Right>
</Insets>
<Visible>false</Visible>
</EmptyMessage>
<Axes>
<Type>Linear</Type>
<Title>
<Caption>
<Value>X-Axis Title</Value>
<Font>
<Size>14.0</Size>
<Bold>true</Bold>
<Alignment>
<horizontalAlignment>Center</horizontalAlignment>
<verticalAlignment>Center</verticalAlignment>
</Alignment>
</Font>
</Caption>
<Background xsi:type="attribute:ColorDefinition">
<Transparency>0</Transparency>
<Red>255</Red>
<Green>255</Green>
<Blue>255</Blue>
</Background>
<Outline>
<Style>Solid</Style>
<Thickness>1</Thickness>
<Color>
<Transparency>255</Transparency>
<Red>0</Red>
<Green>0</Green>
<Blue>0</Blue>
</Color>
</Outline>
<Insets>
<Top>0.0</Top>
<Left>2.0</Left>
<Bottom>0.0</Bottom>
<Right>3.0</Right>
</Insets>
<Visible>false</Visible>
</Title>
<TitlePosition>Below</TitlePosition>
<AssociatedAxes>
<Type>Linear</Type>
<Title>
<Caption>
<Value>Y-Axis Title</Value>
<Font>
<Size>14.0</Size>
<Bold>true</Bold>
<Alignment>
<horizontalAlignment>Center</horizontalAlignment>
<verticalAlignment>Center</verticalAlignment>
</Alignment>
<Rotation>90.0</Rotation>
</Font>
</Caption>
<Background xsi:type="attribute:ColorDefinition">
<Transparency>0</Transparency>
<Red>255</Red>
<Green>255</Green>
<Blue>255</Blue>
</Background>
<Outline>
<Style>Solid</Style>
<Thickness>1</Thickness>
<Color>
<Transparency>255</Transparency>
<Red>0</Red>
<Green>0</Green>
<Blue>0</Blue>
</Color>
</Outline>
<Insets>
<Top>0.0</Top>
<Left>2.0</Left>
<Bottom>0.0</Bottom>
<Right>3.0</Right>
</Insets>
<Visible>false</Visible>
</Title>
<TitlePosition>Left</TitlePosition>
<SeriesDefinitions>
<Query>
<Definition>row[&quot;category&quot;];</Definition >
<Grouping>
<GroupType>Text</GroupType>
<AggregateExpression>Sum</AggregateExpression>
</Grouping>
</Query>
<SeriesPalette>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>80</Red>
<Green>166</Green>
<Blue>218</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>242</Red>
<Green>88</Green>
<Blue>106</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>232</Red>
<Green>172</Green>
<Blue>57</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>128</Red>
<Green>255</Green>
<Blue>128</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>64</Red>
<Green>128</Green>
<Blue>128</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>128</Red>
<Green>128</Green>
<Blue>192</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>170</Red>
<Green>85</Green>
<Blue>85</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>128</Red>
<Green>128</Green>
<Blue>0</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>192</Red>
<Green>192</Green>
<Blue>192</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>255</Red>
<Green>255</Green>
<Blue>128</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>128</Red>
<Green>192</Green>
<Blue>128</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>7</Red>
<Green>146</Green>
<Blue>94</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>0</Red>
<Green>128</Green>
<Blue>255</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>255</Red>
<Green>128</Green>
<Blue>192</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>0</Red>
<Green>255</Green>
<Blue>255</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>255</Red>
<Green>128</Green>
<Blue>128</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>0</Red>
<Green>128</Green>
<Blue>192</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>128</Red>
<Green>128</Green>
<Blue>192</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>255</Red>
<Green>0</Green>
<Blue>255</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>128</Red>
<Green>64</Green>
<Blue>64</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>255</Red>
<Green>128</Green>
<Blue>64</Blue>
</Entries>
<Entries xsi:type="attribute:ColorDefinition">
<Transparency>255</Transparency>
<Red>80</Red>
<Green>240</Green>
<Blue>120</


Jason Weathersby

BIRT Exchange
Re: How to hide an item from a choosen Legend on 2 Y-Axis chart? [message #645449 is a reply to message #645366] Fri, 17 December 2010 04:52 Go to previous messageGo to next message
Stanislav  is currently offline Stanislav
Messages: 10
Registered: December 2010
Junior Member
Thank you.
With little modification of the script I did what I needed.

Thanks again and have a nice day.
Re: How to hide an item from a choosen Legend on 2 Y-Axis chart? [message #645938 is a reply to message #645449] Tue, 21 December 2010 04:37 Go to previous messageGo to next message
Stanislav  is currently offline Stanislav
Messages: 10
Registered: December 2010
Junior Member
Hi again,
Another issue related to the Legend.
Once I layout the items correctly I have a lot of extra space for the legend that I don't need.
I found how to decrease the legend hight but can;t increase the height of the blokc above it.
http://pics.daskalov.net/BIRT/birt_chart_with_gap.JPG

In that picture the while block (marked with 2 ugly red arrows) should dissapear, but I can;t find how. I found how to resize the chart itself, or the part above the legend, but the Y axis still stays on same size. Is there some way to resize it, or to say to the BIRT engine to do the layout again?
Re: How to hide an item from a choosen Legend on 2 Y-Axis chart? [message #646007 is a reply to message #645938] Tue, 21 December 2010 09:30 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Can you add similar script to the below to determine which block you
want to re-size?

function beforeDrawBlock( block, scriptContext )
{

importPackage(
Packages.org.eclipse.birt.chart.model.attribute.impl );
importPackage(
Packages.org.eclipse.birt.chart.model.attribute );
if ( block.isLegend( ) )
{
block.getOutline( ).setVisible( true );
block.getOutline( ).getColor( ).set( 21,244,231 );
block.setBackground( ColorDefinitionImpl.YELLOW( ) );
block.setAnchor( Anchor.NORTH_LITERAL );
}
else if ( block.isPlot( ) )
{
block.getOutline( ).setVisible( true );
block.getOutline( ).getColor( ).set( 21,244,231 );

}
else if ( block.isTitle( ) )
{
block.getOutline( ).setVisible( true );
block.getOutline( ).getColor( ).set( 21,244,231 );

}
else if ( block.isCustom( ) ) //Main Block
{
block.getOutline( ).setVisible( true );
block.getOutline( ).getColor( ).set( 255,0,0 );

}

}

Then use the setter methods in
block.getBounds().set...

to adjust the one you want.

Jason

On 12/21/2010 4:37 AM, Stanislav wrote:
> Hi again,
> Another issue related to the Legend.
> Once I layout the items correctly I have a lot of extra space for the
> legend that I don't need. I found how to decrease the legend hight but
> can;t increase the height of the blokc above it.
>
>
> In that picture the while block (marked with 2 ugly red arrows) should
> dissapear, but I can;t find how. I found how to resize the chart itself,
> or the part above the legend, but the Y axis still stays on same size.
> Is there some way to resize it, or to say to the BIRT engine to do the
> layout again?


Jason Weathersby

BIRT Exchange
Re: How to hide an item from a choosen Legend on 2 Y-Axis chart? [message #646115 is a reply to message #646007] Wed, 22 December 2010 03:17 Go to previous messageGo to next message
Stanislav  is currently offline Stanislav
Messages: 10
Registered: December 2010
Junior Member
Hi
I am talking about the space (white) between the block surrounded with RED and the yellow block (Legend).

http://pics.daskalov.net/BIRT/birt_chart_with_colors.JPG

The red one uses his original height when the legend was not modified, while the yellow's height is decresed by me because most (half) of the items are not visible already.

Even when I resize the block in red, the real chart is not resized and axies stays with same height.
http://pics.daskalov.net/BIRT/birt_chart_with_colors_resized.JPG

So obviously I have to resize not only the red block (this is the if ( block.isPlot( ) ) case), but the content too.
Re: How to hide an item from a choosen Legend on 2 Y-Axis chart? [message #646178 is a reply to message #646115] Wed, 22 December 2010 09:51 Go to previous message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Not certain this will work but can you try it on the custom block?
else if ( block.isCustom( ) ) //Main Block
{
block.getOutline( ).setVisible( true );
block.getOutline( ).getColor( ).set( 255,0,0 );
block.getBounds().setHeight(block.getBounds().getHeight()+10 );

}

Jason

On 12/22/2010 3:17 AM, Stanislav wrote:
> Hi
> I am talking about the space (white) between the block surrounded with
> RED and the yellow block (Legend).
>
>
>
> The red one uses his original height when the legend was not modified,
> while the yellow's height is decresed by me because most (half) of the
> items are not visible already.
>
> Even when I resize the block in red, the real chart is not resized and
> axies stays with same height.
>
>
> So obviously I have to resize not only the red block (this is the if (
> block.isPlot( ) ) case), but the content too.


Jason Weathersby

BIRT Exchange
Previous Topic:Report engine / run and render problem
Next Topic:Reloading birt viewer plugin's scriptlibs without restarting eclipse
Goto Forum:
  


Current Time: Wed Apr 23 20:47:02 EDT 2014

Powered by FUDForum. Page generated in 0.03965 seconds