VerticalLineAnnotation over multiple Y axes - scrollable chart
Hi, this question is similar to this one:
https://www.syncfusion.com/forums/138759/verticallineannotation-over-multiple-y-axes
with the main difference that this time I need the vertical line annotations to scroll with the chart.
These are the requirements:
- a vertical line annotation at 09:30 am every day (this is only for this sample, in the actual application the annotations will appear in different locations).
- the annotation must expand over all y axes in the chart.
- the annotations must "follow" the chart, so that they scroll on a zoomed in chart.
- good performance.
Complicating factors is that the y axes are custom, and one of them are logarithmic.
Attached is a sample showing how far I got. Everything in the sample works fine, except that the yellow lines only appear on the first y axis. How can I make the lines extend over all y axes?
Thank you.
Attachment: sfChartMultiYaxisAnnotations_7110f08b.rar
SIGN IN To post a reply.
5 Replies
MK
Muneesh Kumar G
Syncfusion Team
November 27, 2018 09:55 AM UTC
Hi Tom,
Greetings, we have analyzed your requirement and you can achieve this by setting separate y-axis for VerticalLineAnnotation with RowSpan as 3. Please find the solution code snippet below.
Code snippet
|
<chart:SfChart.SecondaryAxis>
<chart:NumericalAxis chart:ChartBase.RowSpan="3"
Visibility="Collapsed" Name="secondaryAxis"/>
</chart:SfChart.SecondaryAxis> |
|
YAxisPrice = New CustomLogarithmicYAxis
YAxisPrice.Name = "YAxisPrice"
YAxisPrice.LogarithmicBase = LogBase
YAxisPrice.FontSize = 12
YAxisPrice.ShowGridLines = False
YAxisPrice.Header = "Price"
..
Sub Annotations()
For i = 0 To BaseTicker.Minutes.Count - 1
If BaseTicker.Minutes(i).DateTime.TimeOfDay = TimeSpan.Parse("09:30:00") Then
Dim newVerticalLineAnnotation As New VerticalLineAnnotation
With newVerticalLineAnnotation
.CoordinateUnit = CoordinateUnit.Axis
.XAxisName = XAxis.Name
' .YAxisName = YAxisPrice.Name
.X1 = i
.StrokeThickness = 1
.ShowLine = True
.YAxisName = "secondaryAxis"
.Stroke = New SolidColorBrush(Colors.Yellow)
.ShowAxisLabel = False
.EnableClipping = False
End With
chart.Annotations.Add(newVerticalLineAnnotation)
End If
Next |
We have modified your sample based on this, please find the sample from the following location. Now sample works fine with your all requirements.
Sample : http://www.syncfusion.com/downloads/support/forum/141145/ze/sfChartMultiYaxisAnnotations-2105765893
Hope this helps.
Thanks,
Muneesh Kumar G.
Muneesh Kumar G.
TO
Tom
November 27, 2018 01:32 PM UTC
Almost there, now a new problem has arisen which is when setting the rowspan of the secondary axis to multiple chartrows, the red chartrow border lines between each chartrow have dissappeared. How to prevent this? ShowGridLines on the secondary axis should be set to false. The attached image shows what I mean.
Attachment: SnapShot_415_d55727b5.rar
Attachment: SnapShot_415_d55727b5.rar
MK
Muneesh Kumar G
Syncfusion Team
November 28, 2018 06:11 AM UTC
Hi Tom,
We analyzed the query and we have resolved this problem by adding empty series with separate y-axis with RowSpan then setting that y-axis to annotation YAxisName property as per the below code snippet.
Code snippet
|
'Annotation Series with Axis
YAxisAnnotation = New NumericalAxis
YAxisAnnotation.Name = "YAxisAnnotation"
YAxisAnnotation.ShowGridLines = False
YAxisAnnotation.Visibility = Visibility.Collapsed
SfChart.SetRow(YAxisAnnotation, 0) 'row starts from 0 at the bottom
SfChart.SetRowSpan(YAxisAnnotation, 3) 'row ends to 3rd row at the top
With AnnotationSeries
.YAxis = YAxisAnnotation
End With
chart.Series.Add(AnnotationSeries)
End Sub
Sub Annotations()
For i = 0 To BaseTicker.Minutes.Count - 1
If BaseTicker.Minutes(i).DateTime.TimeOfDay = TimeSpan.Parse("09:30:00") Then
Dim newVerticalLineAnnotation As New VerticalLineAnnotation
With newVerticalLineAnnotation
.CoordinateUnit = CoordinateUnit.Axis
.XAxisName = XAxis.Name
.YAxisName = "YAxisAnnotation"
.X1 = i
.StrokeThickness = 1
.ShowLine = True
.Stroke = New SolidColorBrush(Colors.Yellow)
.ShowAxisLabel = False
.EnableClipping = False
End With
chart.Annotations.Add(newVerticalLineAnnotation)
End If
Next
End Sub
|
Now the VerticalLineAnnotation renders with full chart area with row border as per the below screenshot.
Screnshot:
We have modified our sample based on this, please find the sample from the following location.
Sample: http://www.syncfusion.com/downloads/support/forum/141145/ze/sfChartMultiYaxisAnnotations-2122210135
Please let us know if you have any queries.
Thanks,
Muneesh Kumar G.
TO
Tom
November 28, 2018 09:44 AM UTC
Great, thank you Muneesh.
MK
Muneesh Kumar G
Syncfusion Team
November 28, 2018 09:55 AM UTC
Hi Tom,
Thanks for the update.
We are glad to know that the given solution works. Please let us know if you need any further assistance.
Regards,
Muneesh Kumar G
SIGN IN To post a reply.
- 5 Replies
- 2 Participants
-
TO Tom
- Nov 27, 2018 04:56 AM UTC
- Nov 28, 2018 09:55 AM UTC