I am developing an Android application, and I am trying to develop a chart with points, but I am struggling with some (probably) basic math.
So, the point is: I am drawing a price chart, and I know that the maximum price, being 50000€ is drawn at the 0px. At the other end, the minimum price, being 20000€ is drawn at the 800px. Now, let's suppose that I got a price between the minimum and maximum like 27500€. How can I calculate the px for that price knowing the information I gave earlier?
If someone could help me with this calculation, or at least point me in the right direction, I would really appreciate it!
Begin by seeing you have 800 px for $(50,000-20,000) = 30,000 units$ so you have $\frac{800}{30000} \frac {p}{unit}$. Since 50,000 is your zero mark, it simply becomes $px = \frac{800}{30000}*(50,000-Price) $
So for Price = 27500, you have $px = \frac{8}{300}*(50,000-27,500) = 600px$