Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » CrossTab Cell formating
CrossTab Cell formating [message #1051719] Mon, 29 April 2013 06:35 Go to next message
Harry Virtanen is currently offline Harry VirtanenFriend
Messages: 5
Registered: April 2013
Junior Member
Hi,

I have report with several graphs and one crosstab. The layout of the crosstab is as follows:

index.php/fa/14528/0/

The data is produced by a database query and all computation is done (in Java) before pushing the data to the report.

Everything works okay, for the exception of the rows (and a specific columns) containing percentages. All data, including percentage is pushed in the double datatype from Java, i.e. 0.055 for 5.5%. The report design data type is decimal.

The requirement of the rows and columns containing percentages is that its shows the %-sign and if value is positive the color of the cell/number should be green, if negative then red.

I have managed to get the colors on the correct row and column cells containing the percentages. However I am unable to get the % sign into those same cells.

In the crosstab script I have:
function onCreateCell( cellInst, reportContext )
{
   if( cellInst.getDataValue("columnName")=="ComparedToPreviousMonth"      || 
     cellInst.getDataValue("dataType")=="ROI")
   {       
        

        // cellInst.getStyle().setNumberFormat("##.##%");
                        
        if(cellInst.getDataValue("data_TypeGroup/dataType_columns/columnName") < 0) 
           cellInst.getStyle().setColor("RGB(253,120,120)");
        
        if(cellInst.getDataValue("data_TypeGroup/dataType_columns/columnName") > 0) 
          cellInst.getStyle().setColor("RGB(0,139,8)");


    }

}



This is how a small part of the rows for a DataFrom object with 5 dataTypes looks like without setNumberFormat in the if-block:

index.php/fa/14529/0/Attached Image

Clearly, the if-block works correctly and colors the specified row and column. But when I add ( remove the comment) the setNumberFormat into that same if-block, we get a contradiction and it looks like this:

index.php/fa/14530/0/Attached Image

How is it possible that an if-block colors correctly the specified rows and a column, but formats the percentages all over??

As Mr. S.Holmes would say: "....what ever remains must be the truth!" In my opinion, the setNumberFormat, when first set to a single cell, appears to be globally set to all cells!!

Any ideas? Should I redesign the crosstab? All data is pushed into the design from java-code with db queries. The crosstab should only show the data and format it!

  • Attachment: crosstab.png
    (Size: 10.34KB, Downloaded 2696 times)
  • Attachment: beforebirt.png
    (Size: 17.69KB, Downloaded 2665 times)
  • Attachment: afterbirt.png
    (Size: 15.87KB, Downloaded 2622 times)
Re: CrossTab Cell formating [message #1053191 is a reply to message #1051719] Fri, 03 May 2013 04:39 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

What's your BIRT version?

Michael

Developer Evangelist, Silanis
Re: CrossTab Cell formating [message #1053214 is a reply to message #1053191] Fri, 03 May 2013 07:35 Go to previous messageGo to next message
Harry Virtanen is currently offline Harry VirtanenFriend
Messages: 5
Registered: April 2013
Junior Member

Birt version is 3.7.2v20120213

Re: CrossTab Cell formating [message #1053873 is a reply to message #1053214] Wed, 08 May 2013 04:09 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Sorry for the delay. I used your same script and set up a similar crosstab and I don't have the same issue. Everything appears to work correctly. Can you try to recreate this with sample data and attach it, so I can run it?

Michael

Developer Evangelist, Silanis
Re: CrossTab Cell formating [message #1058531 is a reply to message #1053873] Tue, 14 May 2013 12:10 Go to previous messageGo to next message
Harry Virtanen is currently offline Harry VirtanenFriend
Messages: 5
Registered: April 2013
Junior Member
My turn to say sorry for the delay.

The fact that you got it worked, made me try
to create a new crosstab in the same report with exactly the same setup as the
crosstab in which the % did go crazy.

To my amazement I had two crosstabs, which to my (beginners) view were created exactly the same way
(apparently not though), the first (earlier) got % all over, while the new "xtab" had the % signs exactly
in the right column and row.

I guess the the first "xtab" had the wires "xrossed".

I deleted the firs and replaced it with the new one.

Thanks for the help anyway!

regards,
Harry
Re: CrossTab Cell formating [message #1058590 is a reply to message #1058531] Tue, 14 May 2013 14:05 Go to previous message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Very odd, but I'm happy to hear that it's now working. Let us know whenever you have questions. Smile

Michael

Developer Evangelist, Silanis
Previous Topic:Sort button on x-axis is disabled
Next Topic:Sum of each bar in a bar chart
Goto Forum:
  


Current Time: Fri Apr 19 10:31:26 GMT 2024

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

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

Back to the top