0

Here is a sandbox (http://jsfiddle.net/qeyqe/).
Here is a beautiful picture of what I expect saying «stretch the graph vertically».

So, I have an array of dots for my graph and a canvas with 100 px height. The maximum and the minimum values of my graph are 84 (0.8425) and 44 (0.439) respectively — so, graph's height range is 40 px (84 - 44). But I need to stretch this graph so it take the whole 100 px height range — I need to transform value «84» to 100 and value «44» to 0; other intermediate values needs to be also transformed (stretched) to fit new 0-100 px range, not old 0-40 px (see picture above).

So, the main question is not how to «scale» the graph, but how to «stretch» it vertically.

artuska
  • 864
  • 2
  • 12
  • 23

1 Answers1

3

You may stretch the value directly in your code by replacing the line

value = Math.round(ratesValues[i] * 100);

with the following lines:

min = 0.439;
max = 0.8425;

value = Math.round((ratesValues[i]-min)/(max-min)*100);

You may change the numbers 0.439 and 0.8425 to reflect the actual minimum and maximum of your graph.

Howard
  • 38,639
  • 9
  • 64
  • 83