So I'm working on the cohort analysis, creating a table from the database, and having a trouble when it comes to coloring. I'm not an expert at javascript, so I dont really know how to do it.
So for example, I have 10,2,6,4.
And then in the table, I wanted to give a coloring from the biggest value.
like
10 => Darkest Green
2 => Lightest Green
6 => Dark Green
4 => Light Green
So if we sort it to make it easier,
10 => Darkest Green
6 => Dark Green
4 => Light Green
2 => Lightest Green
Edit: The 4 number above just a raw example, I'm doing a monthly cohort, which means I will have 12 number, and it will be random, and many months will also have 0, which means it will be white/super light green.
How can I do that? Thanks a lot, and sorry for my english
you can create an array with high priority of colors to low. like:
$colors = array( "Darkest Green", "Dark Green", "Light Green", "Lightest Green" );
now you can use 'foreach' in php to assign that color. like:
$i = 0;
$new_result = array();
foreach( $cohort_result as $row ) {
$new_result[ $row ] = $colors[ $i ];
$i++;
}
Regards.