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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Adding a titles to seriesCollection

Thread ID:

Created:

Updated:

Platform:

Replies:

145170 Jun 11,2019 07:45 AM UTC Jun 13,2019 09:30 AM UTC Xamarin.Forms 7
loading
Tags: SfChart
Teodor Nikolaev
Asked On June 11, 2019 07:45 AM UTC

Hello,

I have the following code that is initializing a chart and i would like to know if it's possible to add a title for this specific chart in this part of the code (i have uploaded the pictures). If there is any other way to do it i must specify that i want titles only in specific charts.

Attachment: something_1332417a.zip

Bharathiraja K [Syncfusion]
Replied On June 11, 2019 11:22 AM UTC

Hi Teodor, 
 
Greetings from Syncfusion. We already have options to add Title with Chart. Please find the below help document for more details. 
 
 
If your requirement is different from the above scenario, please share more details with screenshot of the expected output in Chart. This will be helpful for us to investigate further and provide you a better solution at the earliest. 
 
Regards, 
Bharathi. 


Teodor Nikolaev
Replied On June 12, 2019 05:38 AM UTC

The problems is i can't figure out how to add a title during the creation of the chart, is it possible to add a title in the code that i have sent earlier?

The chart its self is a collection of different chats in a list view and for some of them i just need to add titles.

Bharathiraja K [Syncfusion]
Replied On June 12, 2019 02:11 PM UTC

Hi Teodor,   
 
We have prepared a sample based on your application scenario. Please download the sample from below location. 
 
 
[XXAML]: 
<chart:SfChart.Title> 
                                <chart:ChartTitle Text="{Binding Title}" BackgroundColor="{Binding ChartColor}" FontSize="12"/> 
                            </chart:SfChart.Title> 
 
In Model 
public string Title { get; set; } 
        public ChartModel(ChartSeriesCollection seriesCollection, Color chartColor, string title) 
        { 
            SeriesCollection = seriesCollection; 
            ChartColor = chartColor; 
            Title = title; 
        } 
 
In Collection 
ChartData = new ObservableCollection<ChartModel>() 
            { 
                new ChartModel( 
                    new ChartSeriesCollection() 
                    { 
                        new LineSeries() 
                        { 
                            //or else bind your data model. 
                            ItemsSource = new ObservableCollection<Model>(){new Model("Information Technology", 32), new Model("India",53),new Model("Saudi",26), new Model("USA",82), new Model("Japan",43), 
                            }, 
                            XBindingPath = "Countries", 
                            YBindingPath = "Count", 
                            XAxis = new CategoryAxis(), 
                            YAxis = new NumericalAxis(), 
                        }, 
                    }, Color.LightCoral, "Line Series" 
 
                ), 
 
 
 
If the above requirement is different from your application scenario, then please modify the given sample with replication steps. This will be helpful for us to investigate further and provide you a better solution at the earliest. 
 
Regards, 
Bharathi. 


Teodor Nikolaev
Replied On June 12, 2019 02:24 PM UTC

The problem is that i want titles only on the PieCharts is there a way to do that?


Bharathiraja K [Syncfusion]
Replied On June 13, 2019 06:00 AM UTC

Hi Teodor, 
 
By the same way you can bind the ChartTitle property instead of sting value. Please refer the below code snippet and change your Model and ViewModel accordingly 
 
[At Model] 
public ChartTitle Title { get; set; } 
 
[At ViewModel] – Initiate title only for pie series.  
ChartData = new ObservableCollection<ChartModel>() 
            { 
                new ChartModel( 
                    new ChartSeriesCollection() 
                    { 
                        new LineSeries() 
                        { 
                            //or else bind your data model. 
                            ItemsSource = new ObservableCollection<Model>(){new Model("Information Technology", 32), new Model("India",53),new Model("Saudi",26), new Model("USA",82), new Model("Japan",43), 
                            }, 
                            XBindingPath = "Countries", 
                            YBindingPath = "Count", 
                            XAxis = new CategoryAxis(), 
                            YAxis = new NumericalAxis(), 
                        }, 
                    }, Color.LightCoral, null //Set null for other than pie series. 
 
                ), 
 
                new ChartModel( 
                    new ChartSeriesCollection() 
                    { 
                        new PieSeries() 
                        { 
                            //or else bind your data model. 
                            ItemsSource = new ObservableCollection<Model>(){new Model("Information Technology", 32), new Model("India",43),new Model("Saudi",23), new Model("USA",54), new Model("Japan",63)}, 
                            XBindingPath = "Countries", 
                            YBindingPath = "Count", 
                        }, 
                    }, Color.LightGray, new ChartTitle(){Text="Pie Series", FontSize= 12, BackgroundColor = Color.LightGray} 
                ), 
} 
 
Please find the modified sample from below link. 
 
 
 
 
Regards, 
Bharathi. 


Teodor Nikolaev
Replied On June 13, 2019 08:42 AM UTC

Thank you that solution fits perfectly! I have another question would annotations work the same exact way in terms of binding? 

Bharathiraja K [Syncfusion]
Replied On June 13, 2019 09:30 AM UTC

Hi Teodor,  
 
Yes. All chart properties support binding. Please refer the annotation help document below here. You can bind your ViewModel value to annotation properties.  
 
 
Regards, 
Bharathi. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon