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

sfchart not rendering. following sfchart getting started and when run chart is not showing up. I am not getting the right output as on gettingstarted section.

step1: 

Adding SfChart reference

You can add SfChart reference using one of the following methods:

Method 1: Adding SfChart reference from nuget.org =done

step 2: adding a line in appdelegate.cs =done

public override bool FinishedLaunching(UIApplication app, NSDictionary options)

{ 
     
    global::Xamarin.Forms.Forms.Init();

    Syncfusion.SfChart.XForms.iOS.Renderers.SfChartRenderer.Init();

    LoadApplication(new App()); 
    
}
step 3: importing sfchart namespace in xaml file = done
 xmlns:chart="clr-namespace:Syncfusion.SfChart.XForms;assembly=Syncfusion.SfChart.XForms" 
step 4: Then initialize an empty chart with PrimaryAxis and SecondaryAxis as shown below,

<?xml version="1.0" encoding="utf-8"?>

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"

             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"

             xmlns:d="http://xamarin.com/schemas/2014/forms/design"

             xmlns:chart="clr-namespace:Syncfusion.SfChart.XForms;assembly=Syncfusion.SfChart.XForms"

             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="Chartsample.MainPage">

    <StackLayout>

        <!-- Place new controls here -->

        <Label Text="Welcome to Xamarin.Forms!" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" />

        <chart:SfChart>

    <chart:SfChart.PrimaryAxis>

        <chart:CategoryAxis>

        </chart:CategoryAxis>

    </chart:SfChart.PrimaryAxis>

    <chart:SfChart.SecondaryAxis>

        <chart:NumericalAxis>

        </chart:NumericalAxis>

    </chart:SfChart.SecondaryAxis>   

</chart:SfChart>

    </StackLayout>

</ContentPage>

Step 4: Run the project and check if you get following output to make sure you have configured your project properly to add SfChart. = It doesn't look like the one on your website when i run it.  = https://help.syncfusion.com/xamarin/charts/getting-started?cs-save-lang=1&cs-lang=xaml



1 Reply

LA Lavanya Anaimuthu Syncfusion Team December 9, 2019 04:56 AM UTC

Hi hypnocool, 
 
Greetings from Syncfusion. 
 
We have validated the reported issue and we would like to let you know that the chart has a parent layout of StackLayout. You can resolve this issue by setting HorizontalOptions and VerticalOptions as FillAndExpand to the chart as per the below code snippet.  Because the desired size support only works for the Accumulation series. Hence for the Cartesian series, you must set Layout options as FillAndExpand or else set the size (Height and Width) for the chart.  
   
Code Snippet [XAML]:  
 
<StackLayout > 
        <!-- Place new controls here --> 
        <Label Text="Welcome to Xamarin.Forms!" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" /> 
        <chart:SfChart x:Name="Chart" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"> 
            <chart:SfChart.PrimaryAxis> 
                <chart:CategoryAxis /> 
            </chart:SfChart.PrimaryAxis> 
            <chart:SfChart.SecondaryAxis> 
                <chart:NumericalAxis /> 
            </chart:SfChart.SecondaryAxis> 
        </chart:SfChart> 
    </StackLayout> 
 
 
 And we have prepared a sample based on your requirement and you can download the sample from the below link.  
   
 
Please let us know if any further assistance on this. 
 
Thanks, 
Lavanya A. 


Loader.
Up arrow icon