CursorTool in vertically stacked multiple custom Y-axis

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
asupriya
Advanced
Posts: 179
Joined: Mon Dec 01, 2008 12:00 am

CursorTool in vertically stacked multiple custom Y-axis

Post by asupriya » Thu Apr 15, 2010 4:15 am

I have a vertical stack of custom y-axes as shown in the sample code below. I need to get the cursor tool of the chart to showup on every series associated with separate custom y-axis. Currently, the cursor tool only showsup on the first series. Can you please suggest what i should do?

Code: Select all

Imports Steema.TeeChart

Public Class Form1
    Private fs(128) As Steema.TeeChart.Styles.FastLine
    Private myAxis(128) As Steema.TeeChart.Axis

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.WindowState = FormWindowState.Maximized

        'Chart object
        Dim tchart1 As New Steema.TeeChart.TChart
        tchart1.Aspect.View3D = False
        tchart1.Dock = DockStyle.Fill
        tchart1.Aspect.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
        tchart1.Aspect.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit

        'Now cursor tool
        Dim cursorTool1 As New Steema.TeeChart.Tools.CursorTool(tchart1.Chart)
        cursorTool1.FollowMouse = True
        cursorTool1.FastCursor = True
        cursorTool1.Pen.Style = System.Drawing.Drawing2D.DashStyle.Solid
        cursorTool1.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical
        cursorTool1.Pen.Color = Color.Orange
        cursorTool1.Pen.Width = 1

        'Now fast lines
        For i As Integer = 0 To 9
            'fastlines
            fs(i) = New Steema.TeeChart.Styles.FastLine(tchart1.Chart)
            fs(i).FillSampleValues(18000)
            fs(i).DrawAllPoints = False

            'axis
            If i = 0 Then
                myAxis(i) = tchart1.Chart.Axes.Left
                myAxis(i).StartEndPositionUnits = Steema.TeeChart.PositionUnits.Percent
                myAxis(i).StartPosition = 0
                myAxis(i).EndPosition = 10
                fs(i).VertAxis = Styles.VerticalAxis.Left
            Else
                myAxis(i) = New Steema.TeeChart.Axis(tchart1.Chart)
                myAxis(i).StartEndPositionUnits = Steema.TeeChart.PositionUnits.Percent
                tchart1.Axes.Custom.Add(myAxis(i))
                myAxis(i).StartPosition = myAxis(i - 1).EndPosition + 1
                myAxis(i).EndPosition = myAxis(i).StartPosition + 9
                fs(i).CustomVertAxis = myAxis(i)
            End If

        Next

        Dim myYAxis As New Steema.TeeChart.Axis
        tchart1.Axes.Custom.Add(myYAxis)
        myYAxis.Grid.Visible = False
        myYAxis.MinimumOffset = 15

        'fastline
        Dim fs2 As New Steema.TeeChart.Styles.FastLine(tchart1.Chart)
        fs2.FillSampleValues()
        fs2.DrawAllPoints = False
        fs2.CustomVertAxis = myYAxis
        myYAxis.StartPosition = 0
        myYAxis.EndPosition = 12
        'myYAxis.RelativePosition = -10
        myYAxis.StartEndPositionUnits = Steema.TeeChart.PositionUnits.Percent
        myYAxis.OtherSide = True
        Me.Controls.Add(tchart1)
    End Sub
End Class

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

Re: CursorTool in vertically stacked multiple custom Y-axis

Post by Sandra » Thu Apr 15, 2010 12:47 pm

Hello asupriya,

I think your problem appears, because you need to add for each custom axes a cursortool. Please see next simple code that do what I said previously and check works as you want.

Code: Select all

    Private fastline1, fastline2, fastline3, fastline4 As Steema.TeeChart.Styles.FastLine
    Private axis1, axis2, axis3 As Steema.TeeChart.Axis
    Private cursorTool1, cursorTool2, cursorTool3, cursorTool4 As Steema.TeeChart.Tools.CursorTool
    Private Sub InitializeChart()
        tChart1.Aspect.View3D = False
        tChart1.Dock = DockStyle.Fill
        tChart1.Panel.MarginLeft = 5
        '-----------FastLines---------------//
        fastline1 = New Steema.TeeChart.Styles.FastLine(tChart1.Chart)
        fastline2 = New Steema.TeeChart.Styles.FastLine(tChart1.Chart)
        fastline3 = New Steema.TeeChart.Styles.FastLine(tChart1.Chart)
        fastline4 = New Steema.TeeChart.Styles.FastLine(tChart1.Chart)

        fastline1.FillSampleValues(1800)
        fastline2.FillSampleValues(1800)
        fastline3.FillSampleValues(1800)
        fastline4.FillSampleValues(1800)
        '---------------Axes----------------//
        axis1 = New Steema.TeeChart.Axis(tChart1.Chart)
        axis2 = New Steema.TeeChart.Axis(tChart1.Chart)
        axis3 = New Steema.TeeChart.Axis(tChart1.Chart)

        TChart1.Axes.Custom.Add(axis1)
        TChart1.Axes.Custom.Add(axis2)
        TChart1.Axes.Custom.Add(axis3)

        fastline1.CustomVertAxis = tChart1.Axes.Left
        fastline2.CustomVertAxis = axis1
        fastline3.CustomVertAxis = axis2
        fastline4.CustomVertAxis = axis3

        axis1.AxisPen.Color = Color.Green
        axis2.AxisPen.Color = Color.Blue
        axis3.AxisPen.Color = Color.Red

        tChart1.Axes.Left.StartPosition = 75
        tChart1.Axes.Left.EndPosition = 100

        axis1.StartPosition = 50
        axis1.EndPosition = 75

        axis2.StartPosition = 25
        axis2.EndPosition = 50

        axis3.StartPosition = 0
        axis3.EndPosition = 25

        '---------------CursorTool-------------------//
        cursorTool1 = New Steema.TeeChart.Tools.CursorTool(tChart1.Chart)
        cursorTool2 = New Steema.TeeChart.Tools.CursorTool(tChart1.Chart)
        cursorTool3 = New Steema.TeeChart.Tools.CursorTool(tChart1.Chart)
        cursorTool4 = New Steema.TeeChart.Tools.CursorTool(tChart1.Chart)

        cursorTool1.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical
        cursorTool2.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical
        cursorTool3.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical
        cursorTool4.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical

        cursorTool4.Series = fastline4
        cursorTool3.Series = fastline3
        cursorTool2.Series = fastline2
        cursorTool1.Series = fastline1

        cursorTool1.Pen.Color = fastline1.Color
        cursorTool2.Pen.Color = fastline2.Color
        cursorTool3.Pen.Color = fastline3.Color
        cursorTool4.Pen.Color = fastline4.Color
    End Sub
Also, if previous code doesn't works as you want, I have made other solution that consist in put all axes custom and leave left axes for default and you doesn't assign it any series. Please see next code and check if it works as you want.

Code: Select all

Public Sub New()
        InitializeComponent()
        InitializeChart()
    End Sub
    Private fastline1, fastline2, fastline3, fastline4 As Steema.TeeChart.Styles.FastLine
    Private axis1, axis2, axis3, axis4 As Steema.TeeChart.Axis
    Private cursorTool1 As Steema.TeeChart.Tools.CursorTool
    Private Sub InitializeChart()
        tChart1.Aspect.View3D = False
        tChart1.Dock = DockStyle.Fill
        TChart1.Panel.MarginLeft = 10
        '-----------FastLines---------------//
        fastline1 = New Steema.TeeChart.Styles.FastLine(TChart1.Chart)
        fastline2 = New Steema.TeeChart.Styles.FastLine(TChart1.Chart)
        fastline3 = New Steema.TeeChart.Styles.FastLine(TChart1.Chart)
        fastline4 = New Steema.TeeChart.Styles.FastLine(TChart1.Chart)

        fastline1.FillSampleValues(1800)
        fastline2.FillSampleValues(1800)
        fastline3.FillSampleValues(1800)
        fastline4.FillSampleValues(1800)
        '---------------Axes----------------//
        axis1 = New Steema.TeeChart.Axis(TChart1.Chart)
        axis2 = New Steema.TeeChart.Axis(TChart1.Chart)
        axis3 = New Steema.TeeChart.Axis(TChart1.Chart)
        axis4 = New Steema.TeeChart.Axis(TChart1.Chart)
        TChart1.Axes.Custom.Add(axis1)
        TChart1.Axes.Custom.Add(axis2)
        TChart1.Axes.Custom.Add(axis3)
        TChart1.Axes.Custom.Add(axis4)

        fastline1.CustomVertAxis = axis4
        fastline2.CustomVertAxis = axis1
        fastline3.CustomVertAxis = axis2
        fastline4.CustomVertAxis = axis3

        axis1.AxisPen.Color = Color.Green
        axis2.AxisPen.Color = Color.Blue
        axis3.AxisPen.Color = Color.Red

        axis4.StartPosition = 75
        axis4.EndPosition = 100

        axis1.StartPosition = 50
        axis1.EndPosition = 75

        axis2.StartPosition = 25
        axis2.EndPosition = 50

        axis3.StartPosition = 0
        axis3.EndPosition = 25
        '---------------CursorTool-------------------//
        cursorTool1 = New Steema.TeeChart.Tools.CursorTool(TChart1.Chart)
        cursorTool1.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical
        cursorTool1.Pen.Color = Color.Red
    End Sub
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

Post Reply