can i draw freedom shape

TeeChart for ActiveX, COM and ASP
Post Reply
Jameh2020
Newbie
Newbie
Posts: 25
Joined: Fri Apr 08, 2005 4:00 am

can i draw freedom shape

Post by Jameh2020 » Thu Jun 14, 2007 8:40 am

hi
can i draw a freedom shape

and can i fill it by a color

thanks

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Jun 14, 2007 9:15 am

Hi Jameh2020,

What do you exactly mean with "a freedom shape"?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Jun 14, 2007 9:54 am

Hi Jameh2020,

Following up to your question, you may be interested on drawing polygons in TeeChart's canvas as shown here:

Code: Select all

Private Sub TChart1_OnAfterDraw()
    With TChart1.Canvas
        .Pen.Color = vbBlue
        .Brush.Color = vbRed
        
        a = Array(100, 100, 150, 50, 170, 100, 250, 100, 200, 200)
        .Polygon 5, a
    End With
End Sub
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Jameh2020
Newbie
Newbie
Posts: 25
Joined: Fri Apr 08, 2005 4:00 am

Post by Jameh2020 » Thu Jun 14, 2007 1:01 pm

thanks
that exacat what i need

but there is a problem

when i zoom the chart , the shape still in same place
what can i do to make it move with the chart ?

thanks

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Jun 14, 2007 1:14 pm

Hi Jameh2020,

This is because those are absolute pixel positions. In that case you should use pixel positions relative to some chart elements (series points, axes, etc.), for example:

Code: Select all

Private Sub Form_Load()
    TChart1.Series(0).FillSampleValues 10
End Sub

Private Sub TChart1_OnAfterDraw()
    With TChart1.Canvas
        .Pen.Color = vbBlue
        .Brush.Color = vbRed
       
        a = Array(TChart1.Axis.Left.Position, TChart1.Axis.Top.Position, _
                TChart1.Axis.Left.Position, TChart1.Axis.Bottom.Position, _
                TChart1.Series(0).CalcXPos(5), TChart1.Series(0).CalcYPos(5))
        .Polygon 3, a
        
    End With
End Sub
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Jameh2020
Newbie
Newbie
Posts: 25
Joined: Fri Apr 08, 2005 4:00 am

Post by Jameh2020 » Thu Jun 14, 2007 3:02 pm

thanks again

but the Polygon is on top
can i draw it down the Series

and

i have candle Series
can you help me how to draw polygon for example
from (candle2.HighValues to candle4.HighValues to candle4.LowValues to candle2.LowValues)

thanks

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Jun 14, 2007 3:15 pm

Hi Jameh2020,

Ok, in that case you can use OnBeforeDrawChart event and some code like this:

Code: Select all

Private Sub Form_Load()
    TChart1.Series(0).FillSampleValues 10
    TChart1.Environment.InternalRepaint
End Sub

Private Sub TChart1_OnBeforeDrawChart()
    With TChart1
        p1x = .Series(0).CalcXPos(2)
        p1y = .Axis.Left.CalcYPosValue(.Series(0).asCandle.HighValues.Value(2))
        
        p2x = .Series(0).CalcXPos(4)
        p2y = .Axis.Left.CalcYPosValue(.Series(0).asCandle.HighValues.Value(4))
        
        p3x = p2x
        p3y = .Axis.Left.CalcYPosValue(.Series(0).asCandle.LowValues.Value(4))
        
        p4x = p1x
        p4y = .Axis.Left.CalcYPosValue(.Series(0).asCandle.LowValues.Value(2))
    End With
    
    With TChart1.Canvas
        .Pen.Color = vbBlue
        .Brush.Color = vbRed
               
        a = Array(p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y)
        .Polygon 4, a
    End With
End Sub

Private Sub TChart1_OnScroll()
    TChart1.Environment.InternalRepaint
End Sub

Private Sub TChart1_OnUndoZoom()
    TChart1.Environment.InternalRepaint
End Sub

Private Sub TChart1_OnZoom()
    TChart1.Environment.InternalRepaint
End Sub
Please don't forget the InternalRepaint method calls to have the custom painting properly done.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Jameh2020
Newbie
Newbie
Posts: 25
Joined: Fri Apr 08, 2005 4:00 am

Post by Jameh2020 » Thu Jun 14, 2007 3:26 pm

that it's

thank you very very much

Post Reply