Dynamically update design

Hello,

I’m using Xamarin Forms and building MVVM based application. I want dynamically redrow chart. For example:

this



on this



And how i can set title on top ?


1 Reply

DV Divya Venkatesan Syncfusion Team June 20, 2018 11:56 AM UTC

Hi Timofey, 
 
Thanks for using Syncfusion products. 
 
Query 1: I’m using Xamarin Forms and building MVVM based application. I want dynamically redrow chart. 
 
We have prepared a sample similar to provided screenshot to update the chart by changing the data in button click. Please download the sample from the following link. 
 
 
Query 2: And how i can set title on top ? 
Your requirement can be achieved by setting chart title and align it to start as shown in the below code snippets. 
 
Code snippet[Xaml]: 
<chart:SfChart.Title> 
    <chart:ChartTitle Text="MIN" TextAlignment="Start" Margin="0, 8, 0, 12"/> 
</chart:SfChart.Title> 
 
Code snippet[C#]: 
Chart.Title.Text = "MIN"; 
Chart.Title.TextAlignment = TextAlignment.Start; 
Chart.Title.Margin = new Thickness(0,8,0,12); 
 
Note: For UWP, please set the title alignment as shown below code snippets (Please refer CustomChartRenderer.cs file in UWP project). 
 
Code snippet[C#]: 
    public class CustomChartRenderer : SfChartRenderer 
    { 
        protected override void OnElementChanged(ElementChangedEventArgs<SfChart> e) 
        { 
            base.OnElementChanged(e); 
 
            Native.SfChart chart = this.Control as Native.SfChart; 
 
            chart.HorizontalHeaderAlignment = Windows.UI.Xaml.HorizontalAlignment.Left; 
        } 
    } 
 
Please refer the following user guide link to know more about chart title. 
 
Please let us know if you need any further assistance. 
 
Regards, 
Divya Venkatesan 
 


Loader.
Up arrow icon