Download MetaTrader 5

Canvas class scroll

To add comments, please log in or register
Giovanni Catti
58
Giovanni Catti  
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
71933
Vladimir Karputov  
You can immediately get the height and width of graphics: CHART_HEIGHT_IN_PIXELS and CHART_WIDTH_IN_PIXELS.
Vladimir Karputov
Moderator
71933
Vladimir Karputov  
And one more thing: the Canvas you need to create only one time.
Giovanni Catti
58
Giovanni Catti  
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
71933
Vladimir Karputov  
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?
Giovanni Catti
58
Giovanni Catti  
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
71933
Vladimir Karputov  
Instead of scrolling, I propose: track the movement of the mouse and redraw the canvas.
To add comments, please log in or register