Multiple Axis Positioning

TeeChart for ActiveX, COM and ASP
Post Reply
tirby
Newbie
Newbie
Posts: 84
Joined: Mon Mar 16, 2009 12:00 am

Multiple Axis Positioning

Post by tirby » Fri Sep 13, 2013 9:05 pm

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?

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Multiple Axis Positioning

Post by Sandra » Tue Sep 17, 2013 9:20 am

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,
Best Regards,
Sandra Pazos / 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

tirby
Newbie
Newbie
Posts: 84
Joined: Mon Mar 16, 2009 12:00 am

Re: Multiple Axis Positioning

Post by tirby » Fri Sep 20, 2013 9:07 pm

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!

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Multiple Axis Positioning

Post by Sandra » Mon Sep 23, 2013 8:26 am

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,
Best Regards,
Sandra Pazos / 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

tirby
Newbie
Newbie
Posts: 84
Joined: Mon Mar 16, 2009 12:00 am

Re: Multiple Axis Positioning

Post by tirby » Mon Sep 23, 2013 6:08 pm

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!

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

Re: Multiple Axis Positioning

Post by Narcís » Tue Sep 24, 2013 8:28 am

Hi tirby,

Please see my reply here about this subject.
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

tirby
Newbie
Newbie
Posts: 84
Joined: Mon Mar 16, 2009 12:00 am

Re: Multiple Axis Positioning

Post by tirby » Tue Sep 24, 2013 3:19 pm

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!

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

Re: Multiple Axis Positioning

Post by Narcís » Wed Sep 25, 2013 8:06 am

Hi tirby,

Sorry, here you have 2 ActiveX examples on custom axes zooming.
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