Home » Archived » 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 14:00 |
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.
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 14: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 16:26 |
|
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.
|
|
| | |
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 14:27 |
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 .
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 14: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 16:51 |
|
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.
|
|
| |
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 18:37 |
|
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 <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) {
row["Country"]
}
else {
row["city"]
}</expression>
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">totalHour</property>
<expression name="expression">if
(row["Temperatures::hour"] == null) {
row["Crashes::hourAsInt"]
}
else {
row["Temperatures::hourAsInt"]
}</expression>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">totalValue</property>
<expression name="expression">if
(row["temperature"] == null) {
row["countAsInt"]
}
else {
row["teperatureAsInt"]
}</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>

function beforeRendering( gcs, icsc )
{

importPackage( Packages.java.util );
importPackage( Packages.java.io );
importPackage(Packages.org.eclipse.birt.chart.model.type.imp l);
importPackage(Packages.org.eclipse.birt.chart.model.componen t.impl);
importPackage(Packages.org.eclipse.birt.chart.model.type);&a mp;#xD;
importPackage(Packages.org.eclipse.birt.chart.model.componen t);
importPackage(Packages.org.eclipse.birt.chart.computation);& amp;#xD;

var llh = gcs.getRunTimeContext().getLegendLayoutHints();
var liha = llh.getLegendItemHints( );
var nliha = [];//new LegendItemHints[liha.length-1];
var grp=0
if ( liha.length > 1 ){
nidx = 0;
for( idx=0; idx < liha.length; idx++ ){

tli = liha[idx];
var currtop = tli.getTop();
if( tli.getType() == LegendItemHints.Type.LG_ENTRY){
lih = LegendItemHints.newEntry( tli.getItemText(),
tli.getValueText(), tli.getSeriesDefinition(), tli.getSeries(),
tli.getIndex() );
lih.top(currtop);
//lih.left(tli.getLeft());
if( tli.getItemText() == "UK" && grp ==
1){
//delete entry

}else if( tli.getItemText() != "UK" && grp
> 1){
//delete entry

}else{
if( tli.getItemText() == "UK" && grp >
1){
lih.left(liha[nidx].getLeft()+30);
}else{
lih.left(liha[nidx].getLeft());
}
nliha[nidx]=lih;
nidx++;
}

}else if( tli.getType() ==
LegendItemHints.Type.LG_GROUPNAME){
//new group Y Series 1 and Y Series 2 Labels
lih = LegendItemHints.newGroupNameEntry( tli.getItemText()
);
lih.top(currtop);
if( tli.getItemText() == "Y2 series" ){
lih.left(liha[nidx-1].getLeft()+30);
}else{
lih.left(liha[nidx].getLeft());
}
grp++;
nliha[nidx]= lih;
nidx++; 
}else if( tli.getType() ==
LegendItemHints.Type.LG_SEPERATOR){
// bar separators
lih = LegendItemHints.createSeperator();
lih.top(currtop);
lih.width(tli.getWidth());
lih.left(liha[nidx].getLeft());
lih.itemHeight(liha[nidx].getItemHeight()); 
grp++;
nliha[nidx]= lih;
nidx++; 
} 
}
} 
nllh = new LegendLayoutHints(
llh.getLegendSize(),llh.getTitleSize(),null,
llh.isMinSliceApplied(),llh.getMinSliceText(),nliha );
gcs.getRunTimeContext().setLegendLayoutHints(nllh);
}
function beforeDrawBlock( block, icsc )
{
//Bump legend over
if( block.isLegend() ){
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["category"];</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</
|
|
| | |
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 14:30 |
|
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?
|
|
| |
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 14:51 |
|
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.
|
|
|
Goto Forum:
Current Time: Fri Apr 26 19:22:48 GMT 2024
Powered by FUDForum. Page generated in 0.04608 seconds
|