Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Adding Control limits to a line chart
posted

Hello,

Does anyone have any VB.net examples of how to add control limits to a line chart?  I have a line chart with data aligned to dates and I want to add a red dashed line as a lower control limit and upper control limit (both perpendicular to the Y axis).

I tried using StripLines but can't get it to work.

 

 

 

 

Me.UltraChart2.Axis.Y.StripLines.Interval.MinValue = 0

 

 

Me.UltraChart2.Axis.Y.StripLines.Interval.MaxValue = 0.3

Thanks!

 

 

 

Parents
No Data
Reply
  • 28496
    Offline posted

        Private Sub UltraChart1_FillSceneGraph(ByVal sender As Object, ByVal e As FillSceneGraphEventArgs) Handles UltraChart1.FillSceneGraph
            ' we want to insert the control limit box before any of the axis gridlines, so let's start by getting the index of the first gridline
            Dim indexOfFirstGridline = -1
            For current As Integer = 0 To e.SceneGraph.Count - 1
                Dim currentPrimitive As Primitive = e.SceneGraph(current)
                If TypeOf currentPrimitive Is Line Then
                    ' we have found an axis gridline.
                    indexOfFirstGridline = current
                    Exit For
                End If
            Next
            If indexOfFirstGridline = -1 Then Return ' failed

            ' get references to the axis objects
            Dim yAxis As IAdvanceAxis = CType(e.Grid("Y"), IAdvanceAxis)
            Dim xAxis As IAdvanceAxis = CType(e.Grid("X"), IAdvanceAxis)

            Dim startX As Integer = xAxis.MapMinimum
            Dim endX As Integer = xAxis.MapMaximum
            Dim startY As Integer = yAxis.Map(0.0)
            Dim endY As Integer = yAxis.Map(0.3)

            Dim controlLimitBox As New Box(New Rectangle(startX, endY, endX - startX, startY - endY))
            controlLimitBox.PE = New PaintElement(Color.Pink)
            e.SceneGraph.Insert(indexOfFirstGridline, controlLimitBox)
        End Sub

Children
No Data