drawing on canvas

TeeChart for ActiveX, COM and ASP
Post Reply
ivan
Newbie
Newbie
Posts: 4
Joined: Wed Oct 06, 2004 4:00 am
Location: North Italy

drawing on canvas

Post by ivan » Wed Nov 24, 2004 2:13 pm

Hi
Is there an easy way to draw lines and arcs on the graph area only?
I have a problem because custom drawings on the canvas and series do not share the same area, the canvas is bigger.
Suppose this situation

Private Sub Form_Load()
X = Array(1, 2, 3, 4, 5)
Y = Array(2, 3, 1, 5, 8)
With TChart1
.ClearChart
.AddSeries scLine
.Aspect.View3d = False
.Series(0).AddArray 5, Y, X
.Axis.Left.Automatic = False
.Axis.Bottom.Automatic = False
.Axis.Bottom.Minimum = 0
.Axis.Bottom.Maximum = 10
.Axis.Left.Minimum = 0
.Axis.Left.Maximum = 10
End With
end sub

Private Sub TChart1_OnBeforeDrawAxes()
With TChart1
posx = .Axis.Bottom.CalcXPosValue(-2)
posy = .Axis.Left.CalcYPosValue(-2)
.Canvas.MoveTo posx, posy
posx = .Axis.Bottom.CalcXPosValue(2)
posy = .Axis.Left.CalcYPosValue(2)
.Canvas.LineTo posx, posy
End With
End Sub

the line is partly drawn outside the axis' region, and partly within the axis region together with the series.
Is there an easy way to display drawings only in the series region and not outside axises?
Any help would be very much appreciated, it would avoid me a great deal of work.

Thanks in advance
Ivan

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Nov 25, 2004 12:45 pm

Hi Ivan,

yes, you can use the ClipRectangle method :

Code: Select all

Private Sub TChart1_OnBeforeDrawSeries()
With TChart1
  .Canvas.ClipRectangle .Axis.Left.Position, 0, .Axis.Right.Position, .Axis.Bottom.Position
  .Canvas.Pen.Color = vbBlack
    posx1 = .Axis.Bottom.CalcXPosValue(-2)
    posy1 = .Axis.Left.CalcYPosValue(-2)
    .Canvas.MoveTo posx1, posy1
    posx = .Axis.Bottom.CalcXPosValue(2)
    posy = .Axis.Left.CalcYPosValue(2)
    .Canvas.LineTo posx, posy
End With
End Sub

ivan
Newbie
Newbie
Posts: 4
Joined: Wed Oct 06, 2004 4:00 am
Location: North Italy

Drawing on canvas

Post by ivan » Thu Nov 25, 2004 1:58 pm

Great!

Thank you very much, I was getting crazy by calculating intersections of arcs and lines with the 4 axis... :?

Thank you
Ivan

P.S. Have you had any luck with the isometric bug?

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Nov 25, 2004 2:25 pm

Hi Ivan,

I'm working on some bugs now, hope to found a solution soon.

Post Reply