Page 1 of 1

Custom Y Axes Positions to Clearly Show Labels

Posted: Sun Jun 21, 2009 4:00 am
by 13051032
I need to place custom axes and their labels without overlapping with each other. Can you please suggest something?

Here is the code that shows my problem.

Code: Select all

Public Class Form1
    Dim myChart As Steema.TeeChart.TChart

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.AutoScroll = True

            myChart = New Steema.TeeChart.TChart
            myChart.Dock = DockStyle.Top
            myChart.Height = 300
            Me.Controls.Add(myChart)
            Dim myFastLine As New Steema.TeeChart.Styles.FastLine(myChart.Chart)
            'myFastLine.DrawAllPoints = False
            myChart.Legend.Visible = False
            myChart.Aspect.View3D = False
            myFastLine.FillSampleValues(1800)

        'custom axis
        For i As Integer = 0 To 5
            Dim myFastLine2 As New Steema.TeeChart.Styles.FastLine(myChart.Chart)
            myFastLine2.FillSampleValues(900)
            Dim vAxis As New Steema.TeeChart.Axis(myChart.Chart)

            myFastLine2.CustomVertAxis = vAxis
            myChart.Chart.Axes.Custom.Add(vAxis)
            'vAxis.OtherSide = True
            vAxis.RelativePosition = -2
            vAxis.MaximumOffset = 20
            vAxis.MinimumOffset = 10
            vAxis.Title.Text = "Series " & i
            vAxis.Title.Angle = 90
        Next
    End Sub
End Class

Re: Custom Y Axes Positions to Clearly Show Labels

Posted: Mon Jun 22, 2009 10:50 am
by 10050769
Hello asupriya,

I modified your code using custom labels and I think that solve your problem, see next code and check that in your application works fine.

Code: Select all

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.AutoScroll = True

        myChart = New Steema.TeeChart.TChart
        myChart.Dock = DockStyle.Top
        myChart.Height = 300
        Me.Controls.Add(myChart)
        Dim myFastLine As New Steema.TeeChart.Styles.FastLine(myChart.Chart)
        'myFastLine.DrawAllPoints = False
        myChart.Legend.Visible = False
        myChart.Aspect.View3D = False
        myFastLine.FillSampleValues(1800)
        Dim vAxis As Steema.TeeChart.Axis

        Dim myFastLine2 As New Steema.TeeChart.Styles.FastLine
        vAxis = New Steema.TeeChart.Axis(myChart.Chart)
        For i As Integer = 0 To 5
            myFastLine2 = New Steema.TeeChart.Styles.FastLine(myChart.Chart)
            myFastLine2.FillSampleValues(900)
            myFastLine2.CustomVertAxis = vAxis
            myChart.Chart.Axes.Custom.Add(vAxis)
        Next

        myChart.Chart.Axes.Custom(0).Title.Text = ""
        myChart.Chart.Axes.Left.Title.Text = ""

        myChart.Draw()

        Dim maxValue As Integer = myChart.Axes.Right.Maximum
        Dim minValue As Integer = myChart.Axes.Right.Minimum
        vAxis.Labels.Items.Clear()

        Dim j As Integer = minValue

        Do While j < maxValue
            vAxis.Labels.Items.Add(j)
            vAxis.OtherSide = True
            j = j + 50

        Loop
        vAxis.Title.Angle = 90
        vAxis.MaximumOffset = 20
        vAxis.MinimumOffset = 10
        vAxis.RelativePosition = -12
        myChart.Panel.MarginLeft = 20

        For k As Integer = 0 To myChart.Series.Count - 1
            myChart.Series(k).GetVertAxis.Title.Text = myChart.Series(k).GetVertAxis.Title.Text + " " + myChart.Series(k).Title
        Next

    End Sub
Also, if you want sophisticated solution you could find more information in this thread, where there are more examples that solve the problem of overlapping labels in the axes.

Thanks,

Re: Custom Y Axes Positions to Clearly Show Labels

Posted: Tue Jun 23, 2009 5:49 am
by 13051032
Thanks for the hints. I got few ideas from your hints and resolved my issue.

Is there a way I can set the color of this custom axis title as the same color as the series? Also, is there a way to draw the axis itself in the same color as the series? Its becoming hard to associate axes as my displays may have upto five custom axes and all of them drawn in black with their titles in black color will cause confusion.

I tried the following, but it didn't change any colors; both the title and ticks continue to be in black color.

Code: Select all

myYAxis.Title.Color = myFastLine(i).Color
         myYAxis.Ticks.Color = myFastLine(i).Color

Re: Custom Y Axes Positions to Clearly Show Labels

Posted: Tue Jun 23, 2009 8:03 am
by 10050769
Hello asupriya,

Please check that next code works fine in your application.

Code: Select all

 myYAxis.Title.Font.Color = myFastLine.Color
myYAxis.AxisPen.Color = myFastLine.Color
Thanks,