Single RangeColumnSeries covers all available space

I'm using the SfCartesianChart and I get the following result using a single RangeColumnSeries:

Image_2503_1702493658046

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


5 Replies 1 reply marked as answer

SA Saiyath Ali Fathima Bee Moidhin Abdhul Kathar Syncfusion Team December 14, 2023 11:11 AM UTC

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



SA Saiyath Ali Fathima Bee Moidhin Abdhul Kathar Syncfusion Team December 18, 2023 12:44 PM UTC

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



SA Saiyath Ali Fathima Bee Moidhin Abdhul Kathar Syncfusion Team December 20, 2023 11:36 AM UTC

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

Marked as answer

JS Junior Saravia December 20, 2023 04:25 PM UTC

Hi Saiyath Ali Fathima M,


Thanks for the support here, the workaround worked as we expected.



PR Preethi Rajakandham Syncfusion Team December 22, 2023 05:16 AM UTC

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


Loader.
Up arrow icon