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

Change color of legend text

How can I change the text color of a legend?

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="tryfsharpforms.CompareTwoStocksChartPage" 
xmlns:chart="clr-namespace:Syncfusion.SfChart.XForms;assembly=Syncfusion.SfChart.XForms" >
<chart:SfChart x:Name="Chart">
<!-- Primary Axis-->
<chart:CategoryAxis LabelRotationAngle="-45">
<chart:ChartAxisTitle Text="Date" TextColor="White" />
<!-- Secondary Axis-->
<chart:ChartAxisTitle Text="Price" TextColor="White" />
<!-- Line Graph-->
<chart:LineSeries StrokeWidth="2" ItemsSource="{Binding StockData1}" XBindingPath="Date" YBindingPath="Close" x:Name="series1" />
<chart:LineSeries StrokeWidth="2" ItemsSource="{Binding StockData2}" XBindingPath="Date" YBindingPath="Close" x:Name="series2"/>
<!--      End Line Graph-->
<chart:ChartLegend ToggleSeriesVisibility="true" />

public partial class CompareTwoStocksChartPage : ContentPage
public CompareTwoStocksChartPage (IEnumerable<Tuple<DateTime, decimal>> priceList1, IEnumerable<Tuple<DateTime, decimal>> priceList2, string ticker1, string ticker2)
InitializeComponent ();

Title = ticker1.ToUpper() + " vs " + ticker2.ToUpper();

BackgroundColor = MyColors.MidnightBlue;
series1.Color = MyColors.Turqoise;
series2.Color = MyColors.Carrot;

series1.Label = ticker1.ToUpper ();

series2.Label = ticker2.ToUpper ();

var svm = new StocksViewModel (priceList1, priceList2);
BindingContext = svm;

Screenshot. Pardon the size :-)

3 Replies

ME Manivannan Elangovan Syncfusion Team December 16, 2015 12:14 PM UTC

Hi Lan,

Thanks for using Syncfusion products.

We have analyzed your requirement and we are able to achieve your requirement by using LabelStyle. To achieve this, we need to set TextColor of LabelStyle. Please refer the following code example for changing the legend text color.

Code Example:


     <chart:ChartLegend ToggleSeriesVisibility="true" >


                   <chart:ChartLegendLabelStyle TextColor="Red" />




We have prepared a sample based on requirement and please download the sample from the below location.

Sample: LegendTextColor


IL Ian Leatherbury December 17, 2015 06:28 PM UTC

That was it, thank you!

ME Manivannan Elangovan Syncfusion Team December 18, 2015 06:10 AM UTC

Hi Lan,

Thanks for the update. Please let us know if you have any query.


Live Chat Icon For mobile
Up arrow icon