joelwenzel
Programmer
- Jun 28, 2002
- 448
Hello,
I am writting an activeX control that I want to graph things in a certain way. My data is stored in 2 vectors, one for the date and the other for the y axis. So far I have been able to sucessfully graph data as a function of cell position. However, graphing data as a function of time is a bit tricky.
what I have done is developed a stupid system for my graphing. What I do is first get a conversion ratio for the y. This is
PixelsPerYUnit = windowheight/(yMax-yMin)
Now I can graph as a function of cell number by just saying
pDC->LineTo(cellNumber, windowheight-(y-yMin)*PixelsPerYUnit)
This just converts whatever my y data spacing to the correct spacing in pixels.
For time, it is much trickier. I have tried doing something similar by setting my
PixelsPerXUnit = width/(number_of_days_in_MaxDate - number_of_days_in_MinDate)
But now I have to convert all my dates into days and then convert them back to dates....that really sucks.
I made my own date class that stores days, months, and years because the CTime class only spans 68 years and I need much more than that.
I am writting an activeX control that I want to graph things in a certain way. My data is stored in 2 vectors, one for the date and the other for the y axis. So far I have been able to sucessfully graph data as a function of cell position. However, graphing data as a function of time is a bit tricky.
what I have done is developed a stupid system for my graphing. What I do is first get a conversion ratio for the y. This is
PixelsPerYUnit = windowheight/(yMax-yMin)
Now I can graph as a function of cell number by just saying
pDC->LineTo(cellNumber, windowheight-(y-yMin)*PixelsPerYUnit)
This just converts whatever my y data spacing to the correct spacing in pixels.
For time, it is much trickier. I have tried doing something similar by setting my
PixelsPerXUnit = width/(number_of_days_in_MaxDate - number_of_days_in_MinDate)
But now I have to convert all my dates into days and then convert them back to dates....that really sucks.
I made my own date class that stores days, months, and years because the CTime class only spans 68 years and I need much more than that.