Page 1 of 1

Multiple Axis - Adapting start/end position in run mode

Posted: Wed Jun 15, 2005 8:43 pm
by 9524808
Hi,

We have 3 drawings on top of each other, all with the same date/time bottom axis.
I tried to use the "drag colorline tool" to adapt the start/end position of a vertical axis using the end drag method. Please, is there any way to bring the colorline-value in correlation with the chart X/Y dimensions? Or please, do you have a better solution for this? :(

Or do you recommend me to use several Tcharts on a form when dimensions need to be adapted by a user?
With several Tcharts I am afraid to encounter problems regarding correct allignement between the different TCharts regarding grid, labels, legende, date and printing? Should I indeed be worried for this? :cry:

Posted: Mon Jun 20, 2005 11:04 am
by narcis
Hi you can do this using:

Code: Select all

Private Sub Form_Load()
    TChart1.Series(0).FillSampleValues 10
    TChart1.Series(1).FillSampleValues 10
    TChart1.Series(2).FillSampleValues 10

    TChart1.Axis.Left.PositionUnits = puPixels   
End Sub

Private Sub TChart1_OnColorLineToolEndDragLine()
    TChart1.Axis.Left.PositionPercent = TChart1.Axis.Bottom.CalcXPosValue(TChart1.Tools.Items(0).asColorLine.Value) - TChart1.Axis.Left.Position
End Sub

Posted: Mon Jun 20, 2005 4:15 pm
by 9524808
Mny thx yr reply.
I am sorry, I do not mean how to move the axis scale, but how to move the vertical start/end position of each Tchart area. :(

In my sample, I have 3 horizontal areas, separated with 2 horizontal colorlines.
Each area has a few series, the bottom axis is the same for all.
The vertical axis are not commom, custom axis are used.

So if we start with 3 areas equal in size, then we have for start/end position:
0 - 33.3% left axis
33.33-66.66 left custom axis
66.6 -100 another left custom axis

We are searching how to drag the first horizontal colorline, to have let's us say, 50%-17%-33%

Posted: Tue Jun 21, 2005 1:08 pm
by narcis
Hi,

You could do something like:

Code: Select all

Dim Axis0Start, Axis1Start As Integer

Private Sub Form_Load()
    Dim i As Integer
    
    For i = 0 To TChart1.SeriesCount - 1
        TChart1.Series(i).FillSampleValues 10
    Next
    
    For j = 0 To TChart1.Axis.CustomCount - 1
        TChart1.Axis.Custom(j).PositionUnits = puPixels
    Next
    
    TChart1.Axis.Left.PositionUnits = puPixels
    
    Me.ScaleMode = 3
    
    Axis0Start = 0
    Axis1Start = 0
End Sub

Private Sub TChart1_OnColorLineToolEndDragLine()
    If (Axis1Start = 0) Then
        TChart1.Axis.Left.EndPosition = Axis0Start
        TChart1.Axis.Custom(0).StartPosition = Axis0Start
    Else
        TChart1.Axis.Custom(0).EndPosition = Axis1Start
        TChart1.Axis.Custom(1).StartPosition = Axis1Start
    End If
End Sub

Private Sub TChart1_OnMouseUp(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
    If (TChart1.Tools.Items(1).asColorLine.Clicked(X, Y) <> -1) Then
        Axis0Start = (Y / TChart1.Height) * 100
        Axis1Start = 0
    Else
        If (TChart1.Tools.Items(0).asColorLine.Clicked(X, Y) <> -1) Then
            Axis0Start = 0
            Axis1Start = (Y / TChart1.Height) * 100
        End If
    End If
End Sub