I am creating a horizontal bar chart with html/css/php. The first value is supposed to be 100% and will have a width of 425px. Every value after that (which is lower) needs to have it’s width calculated as a percentage of 425px.
So say the first value is 63 and gets a width of 425px (100%). I need to figure out the next’s width if the next is 50, then 31, 27 and so on…
I’m fine with markup, etc. it’s the math calculation I’m trying to get my head around.
Because
$value / $max_widthis the appropriate fraction, you can just multiple the maximum width by that fraction to get the appropriate width for later values.