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
Different coloured label OR datapoint in LineChart
posted

I would like to colour one label X or the datapoint clicked on Line Chart. How can I do that?

I´m using vb.net.

Parents
No Data
Reply
  • 28496
    Verified Answer
    Offline posted

    it requires some coding, but this should give you the result you're looking for:

    Public Class Form1
        Private _currentDataPointSymbol As Symbol
        Private Property CurrentDataPointSymbol() As Symbol
            Get
                Return Me._currentDataPointSymbol
            End Get
            Set(ByVal value As Symbol)
                Me._currentDataPointSymbol = value
            End Set
        End Property
        Private _currentLabel As String
        Private Property CurrentLabel() As String
            Get
                Return Me._currentLabel
            End Get
            Set(ByVal value As String)
                Me._currentLabel = value
            End Set
        End Property
        Private Sub UltraChart1_ChartDataClicked(ByVal sender As Object, ByVal e As ChartDataEventArgs) Handles UltraChart1.ChartDataClicked
            If TypeOf e.Primitive Is DataPoint Then
                Dim dP As DataPoint = CType(e.Primitive, DataPoint)
                Me.CurrentDataPointSymbol = New Symbol(dP.point, SymbolIcon.Circle, SymbolIconSize.Large)
                Me.CurrentDataPointSymbol.PE = New PaintElement(Color.Red)
                Me.CurrentLabel = dP.DataPoint.Label
                Me.UltraChart1.InvalidateLayers()
            End If
        End Sub

        Private Sub UltraChart1_FillSceneGraph(ByVal sender As System.Object, ByVal e As FillSceneGraphEventArgs) Handles UltraChart1.FillSceneGraph
            For Each p As Primitive In e.SceneGraph
                If TypeOf p Is Text Then
                    Dim t As Text = CType(p, Text)
                    If t.GetTextString() = Me.CurrentLabel Then
                        t.labelStyle.FontColor = Color.Red
                    End If
                End If
            Next
            If Not Me.CurrentDataPointSymbol Is Nothing Then
                e.SceneGraph.Add(Me.CurrentDataPointSymbol)
            End If
        End Sub
    End Class

Children
No Data