none
Drawing ArrowAnnotation in Chart with ChartType SeriesChartType.Line and AxisY.IsLogarithmic = True RRS feed

  • Pergunta

  • Hi,

       I have a Line Chart with horizontal lines and I have to connect two point of two lines horizontal distincts with a arrowannotation vertical.

       I tried using the post "Drawing line on Candlestick chart" but the property Height does not work because of property AxisY.IsLogarithmic = True.

       Follow my code:

    Imports System.Windows.Forms.DataVisualization.Charting Private valoresXConstante() As Double = {1, 5} Private valoresY1Hor() As Double = {0.025, 0.025} Private valoresY2Hor() As Double = {0.000035, 0.000035}

    Private serie1 As New Series Private serie2 As New Series Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load With Chart1 serie1.IsVisibleInLegend = True serie2.IsVisibleInLegend = True serie1.ChartType = DataVisualization.Charting.SeriesChartType.Line serie2.ChartType = DataVisualization.Charting.SeriesChartType.Line serie1.Points.DataBindXY(valoresXConstante, valoresY1Hor) serie1.BorderWidth = 3 serie1.Color = Color.Red .Series.Add(serie1) serie2.Points.DataBindXY(valoresXConstante, valoresY2Hor) serie2.BorderWidth = 3 serie2.Color = Color.Orange .Series.Add(serie2) .ChartAreas(0).Area3DStyle.LightStyle = LightStyle.Simplistic .ChartAreas(0).AxisY.IsLogarithmic = True .ChartAreas(0).AxisY.Maximum = 10 .ChartAreas(0).AxisY.Minimum = 0.000000001 .ChartAreas(0).AxisY.Interval = 1 .ChartAreas(0).AxisX.Maximum = 6 .ChartAreas(0).AxisX.Minimum = 0 Dim line As New ArrowAnnotation() line.AxisX = .ChartAreas(0).AxisX line.AxisY = .ChartAreas(0).AxisY line.IsSizeAlwaysRelative = False line.Y = serie1.Points(0).YValues(0) line.X = serie1.Points(0).XValue line.Height = serie2.Points(0).YValues(0) - serie1.Points(0).YValues(0) line.Width = serie2.Points(0).XValue - serie1.Points(0).XValue End With

    End Sub

       What do you suggest?

       Thank you for your help,

    Andrei

    quarta-feira, 14 de novembro de 2012 16:15

Respostas

  • Hi,

    after several attempts, I solved my problem as follow

    Dim line As New ArrowAnnotation()
    line.AxisX = .ChartAreas(0).AxisX
    line.AxisY = .ChartAreas(0).AxisY
    line.IsSizeAlwaysRelative = False
    
    line.Y = serie1.Points(0).YValues(0)
    line.X = serie1.Points(0).XValue
    
    line.Height = Math.Log10(1 / serie1.Points(0).YValues(0)) + serie2.Points(0).YValues(0)'Height = [LOG10(1/serie1.Points(0).YValues(0)) + serie2.Points(0).YValues(0)]
    line.Width = 0 'Vertical lines have zero width

    Hope to help other people who had the same doubt,

    Andrei

    • Marcado como Resposta Andrei Firmino sexta-feira, 14 de dezembro de 2012 11:11
    sexta-feira, 14 de dezembro de 2012 11:11