How get height of AxisY.Max

Posted by: toynnus on 4 June 2020, 6:43 am EST

    • Post Options:
    • Link

    Posted 4 June 2020, 6:43 am EST

    draw histogram by flex chart.

    I want to draw a line and text on top of Line.

    but, axisY value is variable.

       annotationLayer.Annotations.Clear()
        Dim clLine As New C1.Win.Chart.Annotation.Line()
        clLine.Start = New PointF(75, 0)
        clLine.End = New PointF(75, ---- AxisY.Max-----)
        clLine.Content = "MAX"
        clLine.Style.StrokeWidth = 2
        clLine.Style.StrokeColor = Color.FromArgb(100, Color.Red)
        clLine.Attachment = 
       C1.Chart.Annotation.AnnotationAttachment.DataCoordinate
        clLine.Position = C1.Chart.Annotation.AnnotationPosition.Bottom
        annotationLayer.Annotations.Add(clLine)
    
  • Posted 4 June 2020, 6:46 am EST

    Chart2.AxisY.Max is previous value.

  • Posted 5 June 2020, 2:44 am EST

    Hi,

    AxisY.Max is for explicitly setting max value for axis. For getting the max value which is automatically decided by FlexChart (when no explicit Axis.Max is set), you may use IAxis.GetMax() method as follows:

    LineAnnotation.End = New PointF(75, DirectCast(flexChart1.AxisY, IAxis).GetMax())
    

    Also, You should access the max value when chart has finished updates, For e.g. inside FlexChart.Rendered event handler.

    Regards,

    Basant

  • Posted 6 June 2020, 10:41 am EST

    IAxis.GetMax () method is does not exist in vb.net

    and I have binding only the X value.

    because Y value is set automatically in histogram.

    so I want get the maximum value of the automatically set y-axis by histogram.( = maximum value of the histogram frequency.)

    Dim data As List(Of Object) = New List(Of [Object])()

    For i As Integer = 0 To chart2_histogram.Count - 1

            data.Add(New With {
                 .X = chart2_histogram(i)
            })
        Next
    
    
        Chart2.DataSource = data
        Chart2.BindingX = "X"
    

    If annotationLayer Is Nothing Then

    annotationLayer = New C1.Win.Chart.Annotation.AnnotationLayer(Chart2)

    End If

        annotationLayer.Annotations.Clear()
        Dim clLine As New C1.Win.Chart.Annotation.Line()
        clLine.Start = New PointF(cl, 0)
        clLine.End = New PointF(cl, ???????????????????? )
        clLine.Style.StrokeWidth = 2
        clLine.Style.StrokeColor = Color.FromArgb(100, Color.Red)
        clLine.Attachment = C1.Chart.Annotation.AnnotationAttachment.DataCoordinate
        clLine.Position = C1.Chart.Annotation.AnnotationPosition.Bottom
        annotationLayer.Annotations.Add(clLine)
    

    chart2_histogram array–>

    78.8

    78.9

    78.6

    78.8

    78.7

    78.7

    78.6

    79.1

    78.6

    79.0

    78.5

    78.5

  • Posted 8 June 2020, 1:27 am EST

    Hi,

    Thanks for sharing the code snippet, I understand your requirement. However, IAxis.GetMax() should be there and meet your requirement. I have attached a sample, could you please verify it at your end? I tested it with the latest version (4.*.20201.416). In case you are using a 4.0 version you would require to replace the corresponding dlls with those of the installed on your local machine. In case it’s still not there, please let us know the version you are using?

    The IAxis.GetMax() should be working fine however there is one more approach to get the axis max in data coordinates. You may use the Axis.ConvertBack() method as follows:

    clLine.End = New PointF(75, FlexChart1.AxisY.ConvertBack(FlexChart1.PlotRect.Top))
    

    Regards,

    Basant

    HistoWithAnno.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels