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

Styling a Silverlight Chart.. need help

2 Answers 63 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jeff Kershner
Top achievements
Rank 1
Jeff Kershner asked on 21 Jul 2010, 12:44 AM
I have a Telerik Silverlight chart that is rendered on a dynamic canvas and databound by a webservice to produce the attached chart.

How can I accomplish the following (must be in code behind):
1. Add a second smaller title under the large orange title
2. Alternate the colors of each bar to cycle through a palette or specific colors
3. Remove all the borders around the title and the chart area
4. Make the chart area and title transparent

I tried things like this to set the Title's background to transparent but it didn't work:

SolidColorBrush

 

 

transparentBrush = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));

 

chart.DefaultView.ChartTitle.Background = transparentBrush;


Any suggestions?

2 Answers, 1 is accepted

Sort by
0
Sia
Telerik team
answered on 21 Jul 2010, 03:30 PM
Hi Jeff Kershner,

Straight onto your questions:

1. Add a second smaller title under the large orange title
The title is a content control and you can achieve two titles - one big and one small by setting:
TextBlock title = new TextBlock();
              
Run runMaintitle = new Run();
runMaintitle.FontSize = 30; 
runMaintitle.Text = "Website Traffic";
 
LineBreak lb = new LineBreak();
Run runSubtitle = new Run();
runSubtitle.FontSize = 10; 
runSubtitle.Text = "sub title";
 
title.Inlines.Add(runMaintitle);
title.Inlines.Add(lb);
title.Inlines.Add(runSubtitle);
 
RadChart1.DefaultView.ChartTitle.Content = title;
RadChart1.DefaultView.ChartTitle.Foreground = new SolidColorBrush(Colors.Orange);

2. Alternate the colors of each bar to cycle through a palette or specific colors
Please look at the following help topic, review the approach described there and give it a try. If you need additional help, just let me know.

3. Remove all the borders around the title and the chart area
Set the following: 
RadChart1.BorderThickness = new Thickness(0);
RadChart1.DefaultView.ChartTitle.OuterBorderThickness = new Thickness(0);
RadChart1.DefaultView.ChartTitle.BorderThickness = new Thickness(0);

4. Make the chart area and title transparent
Just add the following lines in your code-behind:
Brush transparentBrush = new SolidColorBrush(Colors.Transparent);
        
RadChart1.Background = transparentBrush;
RadChart1.DefaultView.ChartTitle.Background = transparentBrush;

Hope this  helps.

Greetings,
Sia
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Jeff Kershner
Top achievements
Rank 1
answered on 21 Jul 2010, 09:18 PM
Thanks for a very detailed response.  All questions were answered!  Thanks!
Tags
General Discussions
Asked by
Jeff Kershner
Top achievements
Rank 1
Answers by
Sia
Telerik team
Jeff Kershner
Top achievements
Rank 1
Share this question
or