Jump to content

Javascript to color highlight different values in the report


Recommended Posts

HI I have a problem, I don't know how to write a script that will allow me, for example, to display the highest values in a given know and column in a specific font and background color so at it loocks like in MS Excel sales raport

Example 
show the highest values in row 5 and column 3 in a green yellow background
show the lowest values in line 6 and column 2 in red, pink background
Also, if the value is greater than 0, or any given value for a specific row and column, use blue etc.

I use this code in a footer to show negative values in a color for example red

<SCRIPT LANGUAGE="JavaScript">
var elems = document.getElementsByTagName("td");
for (var i=0, m=elems.length; i<m; i++) {

if (elems[i].innerHTML.charAt(0) == "-") {
elems[i].style.color="red";
elems[i].style.backgroundColor="#fde8f3";
}
}
</SCRIPT>
I would like to get such an effect under the graph
 

1.PNG

Link to comment
Share on other sites

  • 2 weeks later...

HI. Thank you for your interest.
I can change the color of negative and positive values using JavaScript, but I can not write a script that would allow me to change the correlation of the highest and lowest value in the report to show the decrease and increase in the percentage of sales compared to the previous period.

Best Regards

Java example:

 

<SCRIPT LANGUAGE="JavaScript">
var elems = document.getElementsByTagName("td");
for (var i=0, m=elems.length; i<m; i++) {

if (elems[i].innerHTML.charAt(0) == "-") {
elems[i].style.color="red";
elems[i].style.backgroundColor="#fde8f3";
}
}
</SCRIPT>

<SCRIPT LANGUAGE="JavaScript">
var elems = document.getElementsByTagName("td");
for (var i=0, m=elems.length; i<m; i++) {

if (elems[i].innerHTML.charAt(0) == "-") {
elems[i].style.color="red";
elems[i].style.backgroundColor="wgite";
}
if (elems[i].innerHTML.charAt(0) !== "-" && elems[i].innerHTML.indexOf("%") !== -1) {
elems[i].style.color="green";
elems[i].style.backgroundColor="#c7ffc3";
}
}
</SCRIPT>

03.PNG

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...