Today I will share with you one very cool tricks used in Graphics and visualization.
The problem is you have given one range, for example, 0-10, and you have to convert this range to 0-100. Converting range from one scale to another is a typical math problem.
Use the following formula to scale one range to another.
scale(v)=(newMax-newMin)/(oldMax-oldMin)*(v-
oldMin)+newMin)
const rescale=(value)=>{
const oldScale=[0,10];
const newScale=[0,100];
const scale=(newScale[1]-newScale[0])/(oldScale[1]-oldScale[0])*(value-oldScale[0])+newScale[0];
return scale;
}
console.log(rescale(2));