Styling a Silverlight Chart.. need help

3 posts, 0 answers
  1. Jeff Kershner
    Jeff Kershner avatar
    62 posts
    Member since:
    Aug 2009

    Posted 20 Jul 2010 Link to this post

    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. Sia
    Admin
    Sia avatar
    745 posts

    Posted 21 Jul 2010 Link to this post

    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
  3. Jeff Kershner
    Jeff Kershner avatar
    62 posts
    Member since:
    Aug 2009

    Posted 21 Jul 2010 Link to this post

    Thanks for a very detailed response.  All questions were answered!  Thanks!
Back to Top