Protected Overrides Sub GenerateVisibleLabels()
If IntervalType = DateTimeIntervalType.Days Then
Dim area = CType(Me.GetType().GetProperty("Area", BindingFlags.GetProperty Or BindingFlags.NonPublic Or BindingFlags.Instance).GetValue(Me), SfChart)
area.Annotations.Clear()
..
Else 'ADD NEW HOUR LABEL
If xDateTime >= nextHour Then
If Not xDateTime.Hour = 16 Then 'do not add last hour of the day label to prevent intersection with the next date label
Dim labelString As String = xDateTime.ToString("HH", Globalization.CultureInfo.CurrentCulture)
Dim annotation As TextAnnotation = New TextAnnotation
annotation.X1 = position
annotation.Y1 = 100
annotation.HorizontalAlignment = HorizontalAlignment.Center
annotation.VerticalAlignment = VerticalAlignment.Center
annotation.Foreground = New SolidColorBrush(Colors.White)
annotation.Text = labelString
area.Annotations.Add(annotation)
End If
nextHour = nextHour.AddHours(1)
End If
End If
position += 1
Loop
End If
Else
MyBase.GenerateVisibleLabels()
End If
End Sub |
<chart:SfChart LayoutUpdated="Chart_LayoutUpdated" >
…
</chart:SfChart>
|
Private Sub Chart_LayoutUpdated(sender As Object, e As EventArgs)
Dim chart = CType(sender, SfChart)
Dispatcher.BeginInvoke(DispatcherPriority.Normal, New Action(AddressOf UpdateAnnotation))
End Sub
Private Sub UpdateAnnotation()
If chart.Annotations IsNot Nothing Then
For Each item As Annotation In chart.Annotations
item.Y1 = chart.PointToValue(YAxisPrice, New Point(0, 14))
Next
End If
End Sub
|