How to reset the dragged drag marks

TeeChart for ActiveX, COM and ASP
Post Reply
Shawn
Newbie
Newbie
Posts: 10
Joined: Fri Nov 15, 2002 12:00 am

How to reset the dragged drag marks

Post by Shawn » Fri Aug 26, 2005 9:20 pm

Hi i have added a dragmarks tool

The problem is once i dragged i want to reset it to the original position, when i press reset.

How do i do it?

thanx

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

Post by Narcís » Mon Aug 29, 2005 8:46 am

Hi Shawn,

Yes, use:

Code: Select all

    TChart1.Series(0).Marks.ResetPositions
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

Shawn
Newbie
Newbie
Posts: 10
Joined: Fri Nov 15, 2002 12:00 am

DragMarks throws error

Post by Shawn » Tue Aug 30, 2005 8:19 pm

narcis,

Thanx, but
the problem is I have a command button that resets the dragmarks.

I have 1 or many series depending on runtime return values
If I give

For i = 0 To TChart1.SeriesCount
TChart1.Series(i).Marks.ResetPositions
Next

It Throws an error.-2147418113

method 'Resetpositions' of object 'IMarks' failed

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

Post by Narcís » Wed Aug 31, 2005 8:39 am

Hi Shawn,

Could you please send us an example we can run "as-is" to reproduce the problem here? You can post your files at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup.
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

Shawn
Newbie
Newbie
Posts: 10
Joined: Fri Nov 15, 2002 12:00 am

Code

Post by Shawn » Wed Aug 31, 2005 3:55 pm

Narcis,

thanx 4 the help
u cld use the following code. Please add a dragmarks tool to ur chart. ANd commandbutton named cmd_Reset and checkbox ckDragMark



Private Sub ckDragMarks_Click()
TChart1.Tools.Items(0).Active = True
End Sub

Private Sub cmdReset_Click()
Dim i As Integer
For i = 0 To TChart1.SeriesCount
TChart1.Series(i).Marks.ResetPositions
Next
TChart1.Tools.Items(0).Active = False
ckDragMarks.Value = 0
End Sub

Private Sub Form_Load()
LoadGraph
End Sub

Public Function LoadGraph()
TChart1.RemoveAllSeries

'i am actually getting this mina nd max date according to the least and biggest date in the dates i return from the DB
'Set the X Axis and Y Axis
With TChart1.Axis.Bottom
.Automatic = False
.SetMinMax CDate("01/01/2005"), CDate("12/31/2005")
.MaximumOffset = 4
.MinimumOffset = 4
.Labels.Separation = 0
.Labels.Size = 25
End With

With TChart1.Axis.Left
.Title.Caption = "Corrosion Rate"
.Automatic = False
.MaximumOffset = 4
.MinimumOffset = 4
.Labels.Size = 25
End With

For j = 0 To 5
'add a series
TChart1.AddSeries (scFastLine)

For k = 0 To j + 3
With TChart1.Series(j)
.XValues.DateTime = True
.AddXY Rnd(100), Rnd(100), "", clTeeColor
.AddXY CDate(DateTime.Now + j), CDbl(j), "", clTeeColor
.Marks.Arrow.Visible = True
.Marks.Arrow.Width = 5
.Marks.Arrow.Style = psDot
.Marks.Arrow.Color = TChart1.Series(j).Color
End With
Next
Next

With TChart1.Axis.Bottom
.Title.Caption = "Inspection Date"
.Increment = TChart1.GetDateTimeStep(dtOneDay)
.Labels.DateTimeFormat = "mm/dd/yyyy"
.Automatic = False 'This is redundant
End With
End Function

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

Post by Narcís » Fri Sep 02, 2005 7:20 am

Hi Shawn,

Thanks for the code, we have been able to reproduce the problem here. It is a bug and we have added that to our defect list to be fixed in future releases. The code below works fine.

Code: Select all

Private Sub ckDragMark_Click()
    TChart1.Tools.Items(0).Active = True
End Sub

Private Sub cmd_Reset_Click()
    For seriesindex = 0 To TChart1.SeriesCount - 1
        For i = 0 To TChart1.Series(seriesindex).Count - 1
          TChart1.Series(seriesindex).Marks.Positions.Automatic (i)
        Next i
    Next seriesindex
    TChart1.Environment.InternalRepaint
    
    TChart1.Tools.Items(0).Active = False
End Sub

Private Sub Form_Load()
    LoadGraph
End Sub

Public Function LoadGraph()
    TChart1.RemoveAllSeries
    
    'i am actually getting this mina nd max date according to the least and biggest date in the dates i return from the DB
    'Set the X Axis and Y Axis
    With TChart1.Axis.Bottom
        .Automatic = False
        .SetMinMax CDate("01/01/2005"), CDate("12/31/2005")
        .MaximumOffset = 4
        .MinimumOffset = 4
        .Labels.Separation = 0
        .Labels.Size = 25
    End With
    
    With TChart1.Axis.Left
        .Title.Caption = "Corrosion Rate"
        .Automatic = False
        .MaximumOffset = 4
        .MinimumOffset = 4
        .Labels.Size = 25
    End With
    
    For j = 0 To 5
        'add a series
        TChart1.AddSeries (scFastLine)
        
        For k = 0 To j + 3
            With TChart1.Series(j)
                .XValues.DateTime = True
                .AddXY Rnd(100), Rnd(100), "", clTeeColor
                .AddXY CDate(DateTime.Now + j), CDbl(j), "", clTeeColor
                .Marks.Visible = True
                .Marks.Arrow.Visible = True
                .Marks.Arrow.Width = 5
                .Marks.Arrow.Style = psDot
                .Marks.Arrow.Color = TChart1.Series(j).Color
            End With
        Next
    Next
    
    With TChart1.Axis.Bottom
        .Title.Caption = "Inspection Date"
        .Increment = TChart1.GetDateTimeStep(dtOneDay)
        .Labels.DateTimeFormat = "mm/dd/yyyy"
    End With
End Function
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 » Fri Feb 27, 2009 8:12 am

Hi Shawn,

We have investigated the issue and found that ResetPositions worked fine. the problem here is the loop that you should have looped from 0 to SeriesCount-1 so code below works fine:

Code: Select all

For i = 0 To TChart1.SeriesCount -1
     TChart1.Series(i).Marks.ResetPositions
Next 
Shame we didn't notice that before!
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

Post Reply