Focal Point
[SOLVED] WebFocus 8 - Colorize cell

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/2917034296

January 27, 2020, 07:05 AM
Mateusz
[SOLVED] WebFocus 8 - Colorize cell
Hi all,

I display table in which I want colorize cell depends on value which is in it.
I try search but do not found anything.
Does anyone try do something like that?

Maybe this information is important I use 2 levels of across to build this table.

Regards,
Mateusz

This message has been edited. Last edited by: FP Mod Chuck,
January 27, 2020, 09:03 AM
BabakNYC
1. What version of WebFOCUS are you using? (Very useful info that you should probably put into your Focal Point Signature.)
2. Which authoring tool are you using? (InfoAssist or App Studio)
3. Search the doc for Traffic Light or Conditional Styling. https://infocenter.information...ource%2Ftopic168.htm

4. It's always helpful to provide an example of what you've tried using a WebFOCUS Sample file so we can give you more specific answers.


WebFOCUS 8206, Unix, Windows
January 28, 2020, 03:01 AM
Mateusz
1. I use WebFocus 8.1
2. I developing via App Studio.
3. Thank you for this url. I will look at it.
4. I want receive the following result
 TABLE FILE CAR
SUM
SALES
BY COUNTRY
ACROSS SEATS

ON TABLE SET STYLESHEET *
TYPE=REPORT, ACROSSCOLUMN=SALES, BACKCOLOR=SILVER, WHEN= SEATS EQ 4,$
END  


But using styling from this file:
INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,

Also I want color cells contain via row, but manual for formating which I found works via column.

Is it possible?
January 29, 2020, 10:28 AM
jnc
Hello Mateusz,

Sometimes workarounds are the solution, if you can't immediately determine how to code something directly.

Seeing your question, this coding example comes to mind as a possible solution.

-* pull all the records for the report to a hold file
TABLE FILE CAR
SUM SALES BY COUNTRY BY SEATS
ON TABLE HOLD
END
-* make a hold file to flag for the countries that have 4 seats.
TABLE FILE HOLD
PRINT COUNTRY AS 'FLAGGED'
BY COUNTRY
WHERE SEATS EQ 4
ON TABLE SET ASNAMES ON
ON TABLE HOLD AS HOLD1
END
-* produce the report
JOIN COUNTRY IN HOLD TO COUNTRY IN HOLD1
END
TABLE FILE HOLD
SUM SALES FLAGGED NOPRINT BY COUNTRY
ACROSS SEATS
ON TABLE SET STYLESHEET *
TYPE=REPORT, ACROSSCOLUMN=SALES, BACKCOLOR=SILVER, WHEN=FLAGGED NE ' ',$
END

is this a possible solution until you can determine how to code it directly?


WebFocus 7x, 8x, Win / Linux, any output format
January 29, 2020, 10:59 AM
Hallway
quote:
Sometimes workarounds are the solution

Truer words...I've been thinking about writing a book called 1001 IBI workarounds


Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs:
 
 
 
 
January 29, 2020, 11:27 AM
Hallway
quote:
Originally posted by Mateusz:
1. I use WebFocus 8.1
2. I developing via App Studio.
3. Thank you for this url. I will look at it.
4. I want receive the following result
 TABLE FILE CAR
SUM
SALES
BY COUNTRY
ACROSS SEATS

ON TABLE SET STYLESHEET *
TYPE=REPORT, ACROSSCOLUMN=SALES, BACKCOLOR=SILVER, WHEN= SEATS EQ 4,$
END  


But using styling from this file:
INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,

Also I want color cells contain via row, but manual for formating which I found works via column.

Is it possible?


Is this what you are looking for?
  
TABLE FILE CAR
SUM 
    CAR.BODY.SALES
BY  CAR.ORIGIN.COUNTRY
ACROSS CAR.BODY.SEATS
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE SET ASNAMES ON
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLEMBEDIMG ON
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
     INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,
$
     DEFMACRO=COND0001,
     MACTYPE=RULE,
     WHEN=A1 EQ 4,
$
TYPE=DATA,
     ACROSSCOLUMN=N1,
     BACKCOLOR='SILVER',
     MACRO=COND0001,
$
ENDSTYLE
END



Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs:
 
 
 
 
January 30, 2020, 06:54 AM
Mateusz
Hi all,

Thank you very much for answers and your help.
Unfortunately, my business case is unusual.

Yes - I can confirm - workaround is the solution ; - )

The javascrpt call resolve my issue,
because values are defined via rows - not columns.

This is code which do the job:
 
-HTMLFORM BEGIN
<HTML>
	<script type="text/javascript">
		var body = document.getElementsByTagName('body')[0];
		var table = document.getElementsByTagName('table')[0];

		// colors
		var green = 'rgba(0, 176, 80, 1)';
		var light_green = 'rgb(228,242,239)';
		var yellow = 'rgba(255, 255, 0, 1)';
		var orange = 'rgb(249,178,88)';
		var dark_orange = 'rgba(255, 192, 0, 1)';
		var red = 'rgb(252,0,25)';

		function f1(row) {
			for (var i=1; i<row.length-1; i++) {
				if (parseInt(row[i].innerText) >= 0 && parseInt(row[i].innerText) <= 14) {
					row[i].style.backgroundColor = green; // green
				} else {
					row[i].style.backgroundColor = red; // red
				}
			}
		}

		function f2(row) {
			for (var i=1; i<row.length-1; i++) {
				if (parseInt(row[i].innerText) >= 0 && parseInt(row[i].innerText) <= 4) {
					row[i].style.backgroundColor = green; // green
				} else if (parseInt(row[i].innerText) >= 5 && parseInt(row[i].innerText) <= 9) {
					row[i].style.backgroundColor = yellow; // yellow
				} else {
					row[i].style.backgroundColor = red; // red
				}
			}
		}

		if (table) {
			var rows = table.children[0].children;

			for (var i=4; i<rows.length-2; i++) {

				switch(i) {
				
					case 4:
						// f1
						f1(rows[i].cells);
					break;

					case 5:
						// f2
						f2(rows[i].cells);
					break;

					default:
						console.log('default');

				}
			}
		}
	</script>


</HTML>

-HTMLFORM END

-RUN