Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I am using chart control to show data of my project.I want to plot point according to higth and width
of chart area.So can anybody suggest me the method to do that or how can i convert the Datapoints
into pixel format???????? :doh:
Posted

1 solution

That shouldn't be to hard. You just need to scale the data up to the available pixels. An important thing to remember is to always use single, or even better a double floating point values to avoid rounding errors. Rounding should only be applied when actual drawing is done.

About the scaling values to pixels:
Simply divide the number-of-pixels by the highest data value. Lets assume the chart area is 800x600 and your data is 4000x6000.

You get:
800 / 4000 = 0.2
600 / 6000 = 0.1

This means that every x value is multiplied by 0.2 and every y value is multiplied by -0.1 (the minus is because you probably would like the lowest value at the bottom and the highest at the top but for screen drawing it is the opposite).

Good luck!
 
Share this answer
 
Comments
YOGESH DHAGE 27-Oct-10 1:49am    
Thanks Sir Its Really Helpfull

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900