This is a migrated thread and some comments may be shown as answers.

Horizontal Bar AxisX Label Background Color

1 Answer 31 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Arun Kumar
Top achievements
Rank 2
Arun Kumar asked on 17 Jul 2011, 01:58 PM
Hi all,

I want to change the background color of AxisX label. I had seen some forums to change the text alignment. But I want to change background color (something like telerik PITS dashboard - Activity). How do I achieve that?

1 Answer, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 20 Jul 2011, 03:04 PM
Hello Arun Kumar,

Thanks for contacting us.

Changing the labels background is not supported out of the box. In order to achieve that, additional retemplating needs to be done.

I've attached a sample project that you could refer to and see how I did it.

If you simply want to change the labels' foreground only, it can be done easily by creating a new style like this:
</UserControl.Resources>
<Style x:Key="LabelForeground" TargetType="TextBlock">
            <Setter Property="Foreground" Value="Red" />
</Style>
</UserControl.Resources>


and then show in your code behind what style should be used:
lineChart.DefaultView.ChartArea.AxisX.AxisStyles.ItemLabelStyle = this.Resources["ItemLabelStyle"] as Style;

In case you haven't visited our Styes and Templates help topics, they can be found here.

Best wishes,
Peshito
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Chart
Asked by
Arun Kumar
Top achievements
Rank 2
Answers by
Peshito
Telerik team
Share this question
or