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

Adding SfChart to a LinearLayout has size problems

Hi,
  I am using the SfChart control but I have problem adding it to a LinearLayout: the size of the SfChart seem wrong.
  Here my code:

      m_oChart = new SfChart (oView.Context);

      //Initializing Primary Axis
      CategoryAxis primaryAxis = new CategoryAxis ();
      primaryAxis.Title.Text = "Month";

      m_oChart.PrimaryAxis = primaryAxis;

      //Initializing Secondary Axis
      NumericalAxis secondaryAxis = new NumericalAxis ();
      secondaryAxis.Title.Text = "Temperature";

      m_oChart.SecondaryAxis = secondaryAxis;

      m_oLinearLayoutChart.AddView(m_oChart);

  Seem I am missing something to say chart should "match_parent" control. Of course I don't want the chart to take all the size of my fragment.

  Thanks in advance,
  Manuel



1 Reply

MK Magesh Kumar Krishnan Syncfusion Team September 24, 2015 09:39 AM UTC

Hi Manuel,

Thanks for using Syncfusion products.

We can achieve your requirement by setting layout parameters for chart with weight using the below code example.
Code Example:

[C#]


chart.LayoutParameters = new TableLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent, 1f);


Note: We have used table layout parameters for chart, since weight property is available only in TableLayout. Please refer the link below.

Link: http://forums.xamarin.com/discussion/3290/how-do-i-change-the-property-layout-weight-by-code  

Thanks,
Magesh Kumar K

Loader.
Up arrow icon