This is a migrated thread and some comments may be shown as answers.
How to change legend text color
1 Answer 15 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Matías asked on 10 Feb 2017, 02:08 PM


I'm developing a Xamarin application targeting Android and iOS and I'm having some issues when trying to change chart's legend text color.

My hunch is that is something related to the palette, but I couldn't figure out where the problem might be.

Here is part of my code:

//Create the Chart View
RadCartesianChartView chart = new RadCartesianChartView(this.Activity);
chart.Background = new global::Android.Graphics.Drawables.ColorDrawable(Color.White);
/* Add some behavior here */
/* Axes and so on */
var customPalette = new ChartPalette(chart.Palette);
PaletteEntry linesPalette = customPalette.GetEntry(ChartPalette.LineFamily, 0);
/* Apply my colors here */
chart.Palette = customPalette;
// As there are many series, I iterate through them in order to show them together
foreach (ScatterPointSeries chartSeries in series)
    chartSeries.XValueBinding = hvb;
    chartSeries.YValueBinding = vvb;               
    chartSeries.CanApplyPalette = false;
    chartSeries.StrokeThickness = 5.0f;
    chartSeries.VerticalAxis = verticalAxis;
    chartSeries.HorizontalAxis = horizontalAxis;
// Legengs
var legendView = new RadLegendView(this.Activity);
legendView.LegendProvider = chart;
var layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent, GetLegendsHeight(series.Length));
layoutParams.SetMargins(5, 5, 5, 5);
legendView.LayoutParameters = layoutParams;
// And finally I add both views to the layout


As you can see in the attached screenshot, legend text is grayed out. I'm expecting to see the text color black.

Am I missing something?

Many thanks in advance!


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 15 Feb 2017, 01:54 PM

You can use the RadLegendView.setItemViewLayout(int layoutId) method to override the default layout resource used for visualizing legend items. You simply need to provide the needed elements within the new layout for the items to be visualized by specifying the same IDs. Here's the default layout:

<com.telerik.widget.primitives.legend.RadLegendItemView xmlns:android=""
        android:minHeight="15dp" />
        android:layout_height="wrap_content" />

I hope this helps.

Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question