I have a strange request on a project.
I have an HTML table with 30 columns – each column is displayed as a solid bar with the height set to the value of the column. The max value for the columns is set to 200. Each column is dynamically generated and sometimes the values exceed that of 200. ( for instance 680, 340, 210 etc etc).
What I want to know is how do I work this number down to less than 200? This sum would need to be applied to all each of the columns. So, value = x% of 200.
Any ideas?
You need to normalise. Take the maximum value (either the maximum of the data set – which is dynamic and must be calculated, or the maximum possible, which is static) and divide each actual value by this max, and multiply by column height:
renderedHeight = actualValue / max * columnHeight