I’ve been asked to make a chart that displays how many users are on each page. This chart will be color-coded, where the page with the most users will have 100% opacity, the page with the least viewers will have 40% opacity and the pages in between will have a corresponding opacity.
So, I have a set of numbers, I need
- The largest number to be 100%
- The smallest number to be 40%
- The numbers in between to fall between 100% and 40%
The numbers can be any whole number 1 or greater.
So given 1000, 500, 100, 50
- 1000 should be 100%
- 500 should be ??
- 100 should be ??
- 50 should be 40%
Or, given 2, 1
- 2 should be 100%
- 1 should be 40%
Or given 1000, 1
- 1000 should be 100%
- 1 should be 40%
Or given 7485, 395, 3
- 7485 should be 100%
- 395 should be ??
- 3 should be 40%
I hope that makes sense.
What equation can I use to solve this?
I know to get the percent is just (# / largest_number) * 100
but I’m lost trying to get it between 100% and 40%
The closest I could get is ((#/largest_number) * 60) + 40
, but that assumes 0 is the smallest number and gives me 43 for my smallest number in the 1st set of numbers (50) instead of 40% like I need.
Thanks in advance!