Series is not clipped on a multi Y axis chart
Hello, on a chart with multiple Y axes, the series is not clipped to its chart row, i.e. it bleeds over onto the other chart rows.
Attachment: sfChartClipSeries_364347f6.rar
Attached is an image explaining the issue and a sample.
Run the sample, click the "Zoom 3 days" button and scroll along the X axis. You will see the green series bleeding over onto the "Volume 1" Y axis.
How can the green series be clipped to the "Price" Y axis?
Thank you.
Attachment: sfChartClipSeries_364347f6.rar
SIGN IN To post a reply.
7 Replies
MK
Muneesh Kumar G
Syncfusion Team
February 5, 2019 12:05 PM UTC
Hi Tom,
Greetings, we have analyzed your sample and we found the problem occurs due to the incorrect range set for custom log axis. We have fixed the problem by setting exact range for log axis as per the below code snippet.
Code snippet
|
Public Class CustomLogarithmicYAxis
Inherits LogarithmicAxis
..
Public Sub ZoomY(visibleXRange As DoubleRange, area As SfChart)
Dim MinLogY, MaxLogY As Double
Dim Ymax, Ymin As Double
'GetExtremes(visibleXRange.Start, visibleXRange.End, Ymax, Ymin, area, Me)
Dim visibleXRangeMiddle As Integer = Math.Round(visibleXRange.Start + visibleXRange.Delta / 2)
Dim MiddleXRangePrice = MainWindow.BaseTicker.Minutes(visibleXRangeMiddle).Price
Dim YpercentRange As Integer = 50
Ymax = MiddleXRangePrice * (1 + (YpercentRange / 2) / 100)
Ymin = MiddleXRangePrice * (1 - (YpercentRange / 2) / 100)
MinLogY = Math.Floor(Math.Log(Ymin, LogBase))
MaxLogY = Math.Ceiling(Math.Log(Ymax, LogBase))
Me.VisibleRange = New DoubleRange(MinLogY, MaxLogY)
prevVisibleRange = Me.VisibleRange
' Console.WriteLine("CustomLogarithmicYAxis " & Me.Name & " ZoomY VisibleRange.Start " & Me.VisibleRange.Start & " VisibleRange.End " & Me.VisibleRange.End)
End Sub
End Class |
Hope this helps you.
Thanks,
Muneesh Kumar G.
TO
Tom
February 5, 2019 12:35 PM UTC
Hi Muneesh, this does not solve the problem. If you run the sample with your fix, zoom to 3 days, and scroll from beginning to end you will see many places where the green series dips below the top chart row and into the the Volume 1 chart row. And besides, the MinLogY and MaxLogY values should not be rounded to integer values, that messes up the Y axis range.
MK
Muneesh Kumar G
Syncfusion Team
February 7, 2019 10:31 AM UTC
Hi Tom,
We have analyzed your requirement and we would like to inform you that currently we have rendered bitmap series by checking the x-axis range only, not considered y-axis range.
However, you can achieve your requirement by using separate chart with upper series as like below code snippet.
Code snippet
|
<chart:SfChart
x:Name="chart1"
Header="Days"
AreaBorderBrush="Blue" Foreground="White" AreaBackground="#FF5B5343" AreaBorderThickness="0"
Padding="0" Margin="0,15,0,0"
>
..
</chart:SfChart>
<chart:SfChart Grid.Row="1"
x:Name="chart"
AreaBorderBrush="Blue" Foreground="White" AreaBackground="#FF5B5343"
AreaBorderThickness="0" Padding="0" Margin="0,0,0,15"
>
..
</chart:SfChart> |
|
With SeriesPrice
.Name = NameOf(SeriesPrice)
.XBindingPath = NameOf(Minute.DateTime)
.YBindingPath = NameOf(Minute.Price)
.Interior = New SolidColorBrush(Color.FromArgb(255, 0, 255, 0))
.StrokeThickness = 1
.YAxis = YAxisPrice
.ItemsSource = TestColl.Tickers(0).Minutes
End With
chart1.Series.Add(SeriesPrice)
..
Private Sub ActualRangeChanged(sender As Object, e As ActualRangeChangedEventArgs) Handles customDateTimeCategoryXAxis.ActualRangeChanged
customDateTimeCategoryXAxis1.ZoomFactor = customDateTimeCategoryXAxis.ZoomFactor
customDateTimeCategoryXAxis1.ZoomPosition = customDateTimeCategoryXAxis.ZoomPosition
End Sub
Private Sub ActualRangeChanged1(sender As Object, e As ActualRangeChangedEventArgs) Handles customDateTimeCategoryXAxis1.ActualRangeChanged
customDateTimeCategoryXAxis.ZoomPosition = customDateTimeCategoryXAxis1.ZoomPosition
End Sub |
We have merged two chart’s action by setting ZoomFactor and ZoomPosition for those two charts as same.
We have modified your sample based on this, please find the sample from the following location.
Thanks,
Muneesh Kumar G.
TO
Tom
February 7, 2019 11:58 AM UTC
Hi Muneesh, thanks for looking into this. Unfortunately, although this solution solves the clipping issue, it has too many problems to be viable:
- The scrolling is not smooth
- The two charts are not synchronized properly
- Difficult to implement the annotation chartrow axis which handles vertical annotations that need to overlap all chart rows on both charts
- Greatly increased complexity having to manage two charts and the synchronization
- Performance issues which are sure to arise for large data
Could you please improve the SfChart functionality to be able to handle the clipping issue for the Y axis range (for multiple Y axes as in this situation)?
SR
Samuel Rajadurai Edwin Rajamanickam
Syncfusion Team
February 8, 2019 12:36 PM UTC
Hi Tom,
We have analyzed your requirements and satisfied them by rendering the series in the partitioned chart area. This rendering can be achieved by extending the FastStepLineBitmapSegment.
The following code snippet and sample demonstrates the process.
Code Snippet:
Extending FastStepLineBitmapSeries
|
Public Class FastSteplineBitmapSeriesExt
Inherits FastStepLineBitmapSeries
Private customSegment As CustomFastStepLineBitmapSegment
…
Public Overrides Sub CreateSegments()
…
If customSegment Is Nothing And Segments.Count = 0 Then
customSegment = New CustomFastStepLineBitmapSegment(ActualXValues, YValues, Me)
Segments.Add(customSegment)
ElseIf (ActualXValues IsNot Nothing) Then
customSegment.SetData(xValues, YValues)
customSegment.Item = ActualData
GetType(FastStepLineBitmapSegment).GetMethod("SetRange", BindingFlags.InvokeMethod OrElse BindingFlags.Instance OrElse BindingFlags.NonPublic).Invoke(customSegment, Nothing)
End If
End Sub
End Class
|
Extending FastStepLineBitmapSegment
|
Public Class CustomFastStepLineBitmapSegment
Inherits FastStepLineBitmapSegment
…
Public Overrides Sub Update(transformer As IChartTransformer)
…
UpdateVisual()
End Sub
Private Sub UpdateVisual()
…
' Checking the rendering pixel for its bounds.
Dim isInsideBound = series.Clip.Bounds.Contains(New Point(xStart, yStart)) And series.Clip.Bounds.Contains(New Point(xEnd, yEnd))
If isInsideBound Then
' Render the series.
Endif
End Sub
|
Output Screenshot:
Regards,
Samuel
Samuel
TO
Tom
February 9, 2019 11:09 AM UTC
Thank you, Samuel, this code is very useful. I've modified it to include accurate clipping, handle regenerating source data and improve performance. Actually, the scrolling performance is now better than it was originally, so the issue has been fully resolved. I've attached the updated sample for those who are interested.
Caveat: this only works for a single pixel wide series thickness.
Attachment: sfChartClipSeries2_94af26fd.rar
Attachment: sfChartClipSeries2_94af26fd.rar
MK
Muneesh Kumar G
Syncfusion Team
February 11, 2019 04:41 AM UTC
Hi Tom,
Glad that the issue has been resolved and please get back to us if you need any other assistance.
Thanks,
Muneesh Kumar G.
SIGN IN To post a reply.
- 7 Replies
- 3 Participants
-
TO Tom
- Feb 5, 2019 09:21 AM UTC
- Feb 11, 2019 04:41 AM UTC