Page 1 of 1

Horizontal Target Line Drawn on Bar Chart

Posted: Tue Jul 16, 2013 5:51 pm
by 15665996
I would like to draw a horizontal target line stretching from the X axis origin to the end of the X axis. From best I can tell, I need to use the afterdraw event to make this work. I have not been able to successfully get the afterdraw event to fire. Could someone please help me with the following items:

1. How to get the afterdraw event to fire using VB.Net
2. How to draw a horizontal line at a given Y coordinate from the X axis Origin to the X axis termination.

Re: Horizontal Target Line Drawn on Bar Chart

Posted: Wed Jul 17, 2013 11:44 am
by 10050769
Hello phil1995,

I think you can do something as next code:

Code: Select all

  Private ch1 As Steema.TeeChart.TChart
    Private line As Steema.TeeChart.Styles.Line
    Private Sub Initializechart()

        ch1 = New Steema.TeeChart.TChart()
        Me.Controls.Add(ch1)
        ch1.Aspect.View3D = False
        line = New Line(ch1.Chart)
        line.FillSampleValues()
        AddHandler ch1.AfterDraw, AddressOf ch1_AfterDraw

    End Sub
  
    Private Sub ch1_AfterDraw(sender As Object, g As Steema.TeeChart.Drawing.Graphics3D)
        Dim p0, p1 As Point
        Dim depth, depth1 As Integer
        p0 = New Point(ch1.Axes.Bottom.IStartPos, ch1.Axes.Left.CalcYPosValue(ch1(0).YValues(0)))
        p1 = New Point(ch1.Axes.Bottom.IEndPos, ch1.Axes.Left.CalcYPosValue(ch1(0).YValues(0)))
        depth = ch1.Axes.Depth.IStartPos
        depth1 = ch1.Axes.Depth.IEndPos
        g.Line(p0, p1, depth1)
    End Sub
Could you tell us if previous code works in your end?

I hope will helps.

Thanks,