Page 1 of 1

Multiple Axis Positioning

Posted: Fri Sep 13, 2013 9:05 pm
by 13052810
Hi!

I'm trying to create a graph similar to the one in the issue I posted last year for the .Net version (see link) except now I'm trying to do it with the 2013 version Active X component. My issue currently is with the multiple axis positioning.
http://www.teechart.net/support/viewtop ... =4&t=13633
In the above post/link, I was directed to this link:
http://www.teechart.net/support/viewtop ... xes#p58286
Sandra used a routine named PlaceAxes(), It uses .RelativePosition, which is not available in the Active X version.
I don't know how to place the Custom Axis's in a specific position.

I also would like to create an instance of the custom axis and and populate each new axis separately. Something along the lines of:

In a module:
Public CAxis(8) as Teechart.TChart.CustomAxis

then to use it in a form:
CAxis(0).Pen.Color = VBRed
CAxis(1).Pen.Color = VBGreen
...
CAxis(2).Title= "Pressure"
CAxis(2).Pen.Color = VBBlue
etc....

I know, I don't really have this laid out correctly - just a general idea.

Can you help?

Re: Multiple Axis Positioning

Posted: Tue Sep 17, 2013 9:20 am
by 10050769
Hello Tirby,
I have converted the code of threads you attached in previous post, to Activex code, in Visual Basic 6 and works fine for me:

Code: Select all

Private Sub Form_Load()
InitializeChart
End Sub
Private Sub InitializeChart()
TChart1.Aspect.View3D = False
TChart1.Legend.CheckBoxes = True
TChart1.Header.Visible = False
TChart1.Legend.Alignment = laBottom
Dim i As Integer
Dim vAxis As Integer
For i = 0 To 2
TChart1.AddSeries scLine
TChart1.Series(i).FillSampleValues
vAxis = TChart1.Axis.AddCustom(True)
  With TChart1.Axis.Custom(vAxis)
   .Horizontal = False
   .AxisPen.Color = TChart1.Series(i).Color
   .GridPen.Visible = False
   If (i Mod 2 = 0) Then
      .Title.Visible = True
    .Title.Caption = "Series " & Str(i)
   Else
    .Title.Visible = False
   End If
   
  End With
  TChart1.Series(i).VerticalAxisCustom = vAxis
  TChart1.Axis.Custom(vAxis).PositionUnits = puPixels
Next
TChart1.Panel.MarginUnits = muPixel
TChart1.Environment.InternalRepaint
PlaceAxis 0, 0, 0, 0, 0
TChart1.Environment.InternalRepaint
End Sub
Private Sub PlaceAxis(ByVal nSeries As Integer, ByVal NextXLeft As Integer, ByVal NextXRight As Integer, ByVal MarginLeft As Integer, ByVal MarginRight As Integer)
Const extraPos As Integer = 12
Const extraMargin As Integer = 15
'Variable
Dim MaxLabelsWidth As Integer
Dim lenghtTicks As Integer
Dim extraSpaceBetweenTitleAndLabels As Integer
Dim i As Integer
    For i = 0 To TChart1.SeriesCount - 1
        If TChart1.Series(i).Active Then
            With TChart1.Axis.Custom(i)
            .Visible = True
            MaxLabelsWidth = .Labels.MaxWidth
            lenghtTicks = .TickLength
            extraSpaceBetweenTitleAndLabels = Len(.Title.Caption) + 55
          '  TChart1.Axis.Custom.
            End With
            If TChart1.Axis.Custom(i).Title.Visible Then
                With TChart1.Axis.Custom(i)
                .PositionPercent = NextXLeft
                NextXLeft = NextXLeft - (MaxLabelWidth + lenghTicks + extraSpaceBetweenTitleAndLabels + extraPos)
                MarginLeft = MarginLeft + extraMargin
                End With
            Else
                With TChart1.Axis.Custom(i)
                .PositionPercent = NextXLeft
                NextXLeft = NextXLeft - (MaxLabelsWidth + lenghtTicks + extraPos)
                MarginLeft = MarginLeft + extraMargin
                End With
            End If
        TChart1.Panel.MarginLeft = MarginLeft
        TChart1.Panel.MarginRight = MarginRight
        Else
        TChart1.Axis.Custom(i).Visible = False
        End If
    Next i
End Sub
Private Sub TChart1_OnAfterDraw()
PlaceAxis 0, 0, 0, 0, 0
End Sub

Private Sub TChart1_OnClickLegend(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
TChart1.Environment.InternalRepaint
End Sub
Could you please tell us if my suggestion code works in your end? If you have any problems please let me know.

I hope will helps.

Thanks,

Re: Multiple Axis Positioning

Posted: Fri Sep 20, 2013 9:07 pm
by 13052810
Sandra,

Thank you so much for your assistance witht this. The modifications you made work well.
Now, I have an issue trying to figure out how to display horizontal grid lines while using custom vertical axis's.
When I was using the standard left & right axis, setting the .increment property worked fine.
I do not understand how to set these properties while using a custom vertical axis.
Can you assist?

Thanks!

Re: Multiple Axis Positioning

Posted: Mon Sep 23, 2013 8:26 am
by 10050769
Hello tirby,

If you want the custom axes horizontal Grid Lines are visbile for you, you must set the custom axes property GridPen.Visible to true as do in next lines of code:

Code: Select all

With TChart1.Axis.Custom(vAxis)
   .Horizontal = False
   .AxisPen.Color = TChart1.Series(i).Color
   .GridPen.Visible = True
   If (i Mod 2 = 0) Then
      .Title.Visible = True
    .Title.Caption = "Series " & Str(i)
   Else
    .Title.Visible = False
   End If
Could you confirm us my suggestion works in your end?

Thanks,

Re: Multiple Axis Positioning

Posted: Mon Sep 23, 2013 6:08 pm
by 13052810
Thanks Sandra!
Yes, that solved that problem.

Wow...Moving from the standard left/right axis to custom axis(s) is really involved.
I have a whole new array of issues I need to deal with.
So for the moment, here is the newest one I need help with!

Now, I have lost the vertical zoom capability for the custom vertical axis(s), although the pan function still works.
Can you help with this?

Do I need to start a new thread?

Thanks!

Re: Multiple Axis Positioning

Posted: Tue Sep 24, 2013 8:28 am
by narcis
Hi tirby,

Please see my reply here about this subject.

Re: Multiple Axis Positioning

Posted: Tue Sep 24, 2013 3:19 pm
by 13052810
Hi Narcis,

Thanks for looking at this.
I tried the suggestion you made in the referenced link, and I too have a simular problem:
I don't know how to get to the IZoom.Y0 and IZoom.Y1.
I've tried setting the Max & Min of the custom to the Max & Min of the left axis, but that doesn't work so well.
I'm actually using 3 Custom Axes positioned on the left and 3 Custom Axes positioned on the right for a total of 6 possible custom Axes. These may or may not be active at the same time, and/or any combination of the 6.
Each Axis/Series may or may not have different max values. So zooming and unzooming needs deal with all 6 possible Max axes values.

Can you provide greater detail in reference to the earlier post you cited?

Thanks!

Re: Multiple Axis Positioning

Posted: Wed Sep 25, 2013 8:06 am
by narcis
Hi tirby,

Sorry, here you have 2 ActiveX examples on custom axes zooming.