Page 1 of 1

[CLOSED] line drawn out of boundaries of the chart

Posted: Fri Apr 12, 2013 11:45 am
by 16665441
after Scoll, the line drawn on top of the chart is outside the boundaries of the chart

Re: line drawn out of boundaries of the chart

Posted: Fri Apr 12, 2013 12:07 pm
by yeray
Hello,

I assume you followed the example I wrote here.
That was just an example to show you how to start. There are basically used:
- FirstValueIndex and LastValueIndex properties to loop through the series.
- IsNull function to check what points are the nulls. In that example the nulls are the frontier between two arrows. Your case may be different.
- CalcXPos to get the X position in pixels of a point.
- GetChartRect Left and Right properties to get the limits of the chart in pixels.
- Canvas DrawLine to draw the different parts of the arrows.
- Canvas TextOut to draw the texts.

The rest is just logic to determine when to draw what part of the arrows. If you find something isn't being drawn as you expected please, feel free to modify that code to fit your needs.

Re: line drawn out of boundaries of the chart

Posted: Fri Apr 12, 2013 12:26 pm
by 16665441
Your example is very clear.
I used to make my program.
everything works fine,
thank you

there is one little problem that I have not solve.
when I scroll the chart, the lines drawn outside the chart.

for marks
Marks.clip = true
for points
tchart1.clip = true

but for lines and text
???

Re: line drawn out of boundaries of the chart

Posted: Fri Apr 12, 2013 1:19 pm
by yeray
Hi,

Right. These clip functions control whether a mark or a point has to be drawn out of the boundaries or not.
However, since these arrows are being drawn manually at OnAfterDraw event, you have to fully control it in the same event.

On the other hand, when I scroll that example, the arrow looks fine for me here:
clipping.png
clipping.png (17.68 KiB) Viewed 9072 times
I'm using TeeChart v2012.0.0.9, VB6 and Windows 7 x64

Also note you can also set a region clipping before using the drawing functions at OnafterDraw event, and unclip the region after the drawing. For example:

Code: Select all

Private Sub TChart1_OnAfterDraw()
  With TChart1.GetChartRect
    TChart1.Canvas.ClipRectangle .Left, 0, .Right, .Bottom
  End With

  'Drawing stuff

  TChart1.Canvas.UnClipRectangle
End Sub