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

'Need to show chart strip lines as dotted lines' - F 118447

Hello Syncfusion Team,


I tried achieving the same functionality in xamarin forms in XAML as follows:


                        <xForms:NumericalAxis.StripLines>

                            <xForms:NumericalStripLine

                                Width="0.0001"

                                FillColor="Blue"

                                Start="100"

                                StrokeWidth="3"

                                Text="100" />

                        </xForms:NumericalAxis.StripLines>


In our case, this stripline is not the primary or secondary axis. This piece of code didn't work. Can you please look into it?


Thanks,

Satya K.


1 Reply

RR Raja Ramalingam Syncfusion Team January 26, 2023 10:28 AM UTC

Hi Satya,


We suggest using HorizontalLineAnnotation in chart and utilizing the StrokeDashArray property to achieve your requirement for dotted lines. Please see the code snippet below as an example.


<xForms:SfChart.ChartAnnotations>

           

    <xForms:HorizontalLineAnnotation Text="High" x:Name="annotation1" StrokeWidth="3" StrokeColor="Green" Y1="40" CoordinateUnit="Axis">

        <xForms:HorizontalLineAnnotation.StrokeDashArray>

            <x:Array Type="{x:Type x:Double}">

                <x:Double>2</x:Double>

                <x:Double>3</x:Double>

            </x:Array>

        </xForms:HorizontalLineAnnotation.StrokeDashArray>

    </xForms:HorizontalLineAnnotation>

 

    <xForms:HorizontalLineAnnotation Text="Low" x:Name="annotation2" StrokeWidth="3" StrokeColor="Red" Y1="10" CoordinateUnit="Axis">

        <xForms:HorizontalLineAnnotation.StrokeDashArray>

            <x:Array Type="{x:Type x:Double}">

                <x:Double>2</x:Double>

                <x:Double>3</x:Double>

            </x:Array>

        </xForms:HorizontalLineAnnotation.StrokeDashArray>

    </xForms:HorizontalLineAnnotation>

           

</xForms:SfChart.ChartAnnotations>


Note: You may face errors while setting values for StrokeDashArray property like above. Those errors are XAML syntax level only.


You can also set stroke dash array value from code behind like below.


annotation1.StrokeDashArray = new double[] { 2,3};

 

annotation2.StrokeDashArray = new double[] { 2,3};


Output:




Please visit the UG documentation of annotations in chart.


https://help.syncfusion.com/xamarin/charts/chartannotation


Best Regards,

Raja.


Attachment: DottedLinesChartSample_20105495.zip

Loader.
Live Chat Icon For mobile
Up arrow icon