Page 1 of 1

Changing the Bottom axis label while dragging a point

Posted: Fri Jul 15, 2005 1:45 pm
by 9083326
Hi,

I am drawing the spline curve by using the following example.

Private Sub Form_Load()
With TChart1
.Aspect.View3D = False
.AddSeries scLine
.Series(0).FillSampleValues (10)
.AddSeries scLine
.Series(1).SetFunction tfSmoothing
.Series(1).DataSource = "Series0"
.Series(0).asLine.LinePen.Visible = False
.Series(0).ShowInLegend = False
.Series(0).asLine.Pointer.Visible = True
.Series(0).asLine.Pointer.Style = psStar
End With
End Sub

While adding the points to the Series0, i am specifying the label also in the AddXY function.

When ever dragging a point in the Series0, my label is not changing correspondingly. I do not know how to set the changed X value to the bottom axis label.

Could you please suggest a method or provide a example code.

Thanks & Regards,
Rama

Posted: Fri Jul 15, 2005 2:13 pm
by narcis
Hi Rama,

That's because the labels you set on the AddXY method are strings. If you want points values after being dragged you should implement the OnGetAxisLabels event as in the code below.

Code: Select all

Private Sub Form_Load()
    With TChart1
        .Aspect.View3D = False
        .AddSeries scLine

        With .Series(0)
            For i = 0 To 10
                .AddXY i, i * i, "Point " + CStr(i + 1), clTeeColor
            Next
            .asLine.LinePen.Visible = False
            .ShowInLegend = False
            .asLine.Pointer.Visible = True
            .asLine.Pointer.Style = psStar
        End With

        .AddSeries scLine
        .Series(1).SetFunction tfSmoothing
        .Series(1).DataSource = "Series0"
        
        .Tools.Add tcDragPoint
        .Tools.Items(0).asDragPoint.Series = .Series(0)
        
        .Axis.Bottom.Labels.Separation = 0
    End With
    
    TeeCommander1.Chart = TChart1
End Sub

Private Sub TChart1_OnGetAxisLabel(ByVal Axis As Long, ByVal SeriesIndex As Long, ByVal ValueIndex As Long, LabelText As String)
    If ((Axis = 3) And (SeriesIndex = 0)) Then
        LabelText = CStr(TChart1.Series(0).XValues.Value(ValueIndex))
    End If
End Sub
Notice that in spite of adding custom labels when populating series they won't be displayed because they are immediately changed by OnGetAxisLabel event.

Posted: Mon Jul 18, 2005 7:13 am
by 9083326
Hi narcis,

Thanks for your example. It is working fine as expected.

Thanks & Regards,
Rama