Download MetaTrader 5

Canvas class scroll

To add comments, please log in or register
Have you published a program in the Market? Place it in your blog as well - the widget will help!
gioooooo
47
gioooooo 2015.11.10 08:47 
Is it possible to fix canvas size to half of datas dimension and to set a scroll on the horizontal axis?

Here I attach a code which can set as input canva size. If canvas size is bigger than datas size no problem, othervise the chart doesn't display correctly. I'd like to have a scroll function to move data on canvas when datas size is bigger than canvas size. Is it possible? If yes is there any example?

Thanks in advance
Files:
Vladimir Karputov
Moderator
45460
Vladimir Karputov 2015.11.10 11:31  
You can immediately get the height and width of graphics: CHART_HEIGHT_IN_PIXELS and CHART_WIDTH_IN_PIXELS.
Vladimir Karputov
Moderator
45460
Vladimir Karputov 2015.11.10 12:53  
And one more thing: the Canvas you need to create only one time.
gioooooo
47
gioooooo 2015.11.12 10:09  
Ok, Thanks for suggestion, but I don't understand how to set the scroll. I found an example where they can scroll text on a canvas creating a OBJ_RECTANGLE_LABEL (Rectangle Label) (https://www.mql5.com/en/articles/751), but I'm not sure you can do the same with chart lines.
Vladimir Karputov
Moderator
45460
Vladimir Karputov 2015.11.12 11:54  
gioooooo:
Ok, Thanks for suggestion, but I don't understand how to set the scroll. I found an example where they can scroll text on a canvas creating a OBJ_RECTANGLE_LABEL (Rectangle Label) (https://www.mql5.com/en/articles/751), but I'm not sure you can do the same with chart lines.
And why do I need scrolling, if you can create canvas to size chart?
gioooooo
47
gioooooo 2015.11.12 15:18  
Karputov Vladimir:
And why do I need scrolling, if you can create canvas to size chart?

In the example I draw a sawtooth, but in the real case I need to draw the FFT spectrum of price datas.

I need scrolling because I want to draw a frequency spectrum that is bigger than canvas size.

However I solvet the problem using CChart instead of CCanvas.

Here what I mean (the code with CChart and the image of a scrolling sawtooth)

Files:
Vladimir Karputov
Moderator
45460
Vladimir Karputov 2015.11.13 06:38  
Instead of scrolling, I propose: track the movement of the mouse and redraw the canvas.
To add comments, please log in or register