Single RangeColumnSeries covers all available space
I'm using the SfCartesianChart and I get the following result using a single RangeColumnSeries:
Details:
- NET Maui v8.0.100
- Syncfusion.Maui.Charts v23.2.7
It works as expected if there're at least 2 range columns. I attach a sample project
Attachment: MauiSample8_6530f83f.zip
Hello Junior Saravia,
Our development team is currently validating your query and will provide a response within two business days, by December 18, 2023.
Regards,
Saiyath Ali Fathima M
Hi Junior Saravia,
As we validated further, it was the correct behavior applied when having a single segment, and as you have customized min and max, it seems to fill the entire view, so we planned to provide a workaround solution for this case. We will update our status within 2 business days.
Regards,
Saiyath Ali Fathima M
Hi Junior Saravia,
We would like to inform you that we can customize the position and width of a single range column segment using the custom series and segment class. You can customize the segment width according to your requirements for mobile and desktop applications. Below, we have provided the code snippet, demo, and runnable sample for reference.
Xaml
|
public class RangeColumnSeriesExt : RangeColumnSeries { internal bool IsSingleSegment { get; set; } protected override ChartSegment CreateSegment() { return new RangeColumnSegmentExt(); }
protected override void DrawSeries(ICanvas canvas, ReadOnlyObservableCollection<ChartSegment> segments, RectF clipRect) { IsSingleSegment = segments.Count == 1; base.DrawSeries(canvas, segments, clipRect); } }
public class RangeColumnSegmentExt : RangeColumnSegment { protected override void Draw(ICanvas canvas) { if (Series is RangeColumnSeriesExt series) { if (series.IsSingleSegment) { var centerX = (Left + Right) / 2;
//You can customize the segment width based on requirement for mobile and desktop applications var rect = new RectF(centerX, Top, 50, (Bottom - Top));
CornerRadius cornerRadius = series.CornerRadius; canvas.SetFillPaint(base.Fill, rect); canvas.FillRoundedRectangle(rect, cornerRadius.TopLeft, cornerRadius.TopRight, cornerRadius.BottomLeft, cornerRadius.BottomRight); } else { base.Draw(canvas); } }
} } |
C#
|
<local:RangeColumnSeriesExt ItemsSource="{Binding Data}" XBindingPath="TimeStamp" CornerRadius="5" StrokeWidth="0" High="Max" Low="Min" /> |
Regards,
Saiyath Ali Fathima M
Attachment: SingleSegmentRange_f2d7a966.zip
Hi Saiyath Ali Fathima M,
Thanks for the support here, the workaround worked as we expected.
Hi Junior Saravia,
You're welcome.
We are glad that the provided response
meets your requirement. Please let us know if you need further assistance. As
always, we are happy to help you out.
Regards,
Preethi R
- 5 Replies
- 3 Participants
- Marked answer
-
JS Junior Saravia
- Dec 13, 2023 06:57 PM UTC
- Dec 22, 2023 05:16 AM UTC