Page 1 of 1
How to reset the dragged drag marks
Posted: Fri Aug 26, 2005 9:20 pm
by 9079416
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
Posted: Mon Aug 29, 2005 8:46 am
by narcis
Hi Shawn,
Yes, use:
Code: Select all
TChart1.Series(0).Marks.ResetPositions
DragMarks throws error
Posted: Tue Aug 30, 2005 8:19 pm
by 9079416
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
Posted: Wed Aug 31, 2005 8:39 am
by narcis
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.
Code
Posted: Wed Aug 31, 2005 3:55 pm
by 9079416
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
Posted: Fri Sep 02, 2005 7:20 am
by narcis
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
Posted: Fri Feb 27, 2009 8:12 am
by narcis
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!