I am looking to create a gradient color scale and define classes for it based on a range of values. My scale ranges from 0 to 8.5, with increments of 0.25. This means I have a total of 34 different colors (8.5/0.25 = 34) to cover the entire spectrum. Each class will represent a slightly different shade on the gradient depending on the value in my database. For example, if the value is 2.25, I'd want to use the color at 29.4% ((2.25 * 100 / 8.5 = 29.4) along the gradient. How can I achieve this using CSS classes?
https://i.sstatic.net/7JUBv.png
My goal is to add color to icons on my map based on speed values. By assigning a class to each icon that corresponds to its speed, I can give it a background color matching the speed "value."
After searching online for solutions without success, I'm open to trying other methods to accomplish this task.
If relevant, I am utilizing MapBox
for my mapping needs.