We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Different CornerRadius on ColumnSeries

Hello,

I am migrating my application to .net MAUI from Xamarin and therefore from SfChart to SfCartesianChart.

Captura de pantalla 2022-11-05 163716.png

I have seen that ColumnSeries allows to set a CornerRadius, but as you can see in the image, I need to set a different CornerRadius for negative values ("4,4,0,0" for positive values and "0,0,4,4" for negative values).

Is it possible?

And another question, is it possible to show a horizontal line at value=0?

Thanks for your help.

Best regards,
Diego Roses


1 Reply

BP Baranibharathi Pandian Syncfusion Team November 8, 2022 03:58 AM

Hi Diego Roses,

We have validated your query and we would like to let you know we can achieve your requirement by extend the column series and column segment and provide condition in segment draw override method. Please find the example code snippet for your reference.

Code snippet:

MainPage.xaml

 

<local:ColumnSeriesExt Label="Height"

                        ItemsSource="{Binding Data}"

                        XBindingPath="Name"

                        YBindingPath="Height">

</local:ColumnSeriesExt>

 


MainPage.xaml.cs

 

public class ColumnSeriesExt : ColumnSeries

{

    protected override ChartSegment CreateSegment()

    {

        return new ColumnSegmentExt();

    }

}

 

public class ColumnSegmentExt : ColumnSegment

{

    var series = Series as ColumnSeries;

        var origin = series.ActualYAxis.ValueToPoint(0);

        if(Top < origin)

        {

            series.CornerRadius = new CornerRadius(4, 4, 0, 0);

        }

        else

        {

            series.CornerRadius = new CornerRadius(0, 0, 4, 4);

        }

        if(Top == Bottom)

        {

            canvas.DrawRectangle(new Rect() { Left = Left, Top = Top, Right =     Right, Bottom = Bottom });

        }

        else

        {

            base.Draw(canvas);

        }     

}

 


Regards,

Baranibharathi Pandian


Loader.
Live Chat Icon For mobile
Up arrow icon