ChartTitle and SubTitle

Thread is closed for posting
8 posts, 0 answers
  1. Paulo
    Paulo avatar
    56 posts
    Member since:
    Apr 2012

    Posted 27 Apr 2012 Link to this post

    How can I do a subtitle with different font and size? Is possible?
  2. Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 01 May 2012 Link to this post

    Hi Paulo,

    You may use new line to separate the text , i.e. have a subtitle. For example:

    <TextBlock Text="This is first line.
    This is on another line">

     
    instead of this:

    <TextBlock Text="This will appear as a single line.">

    You can achieve this in code behind too:

    this.radChart1.ChartTitle.TextBlock.Text += "first line here" + System.Environment.NewLine + "second line here";

    To be able to have different styles applied to each line you can try something like this.

    this.radChart1.ChartTitle.TextBlock.Text = "Main Title";
    var titleStyleClone = (Telerik.Charting.Styles.StyleTextBlock)(this.radChart1.ChartTitle.TextBlock.Appearance.Clone());
    TextBlock textBlockChartTitleSub = new TextBlock(titleStyleClone);
    textBlockChartTitleSub.Parent = this.radChart1.ChartTitle;
    textBlockChartTitleSub.Text = "another chart title";
    textBlockChartTitleSub.Appearance.TextProperties.Color = System.Drawing.Color.Blue;
    textBlockChartTitleSub.Appearance.TextProperties.Font = new System.Drawing.Font("Verdana", 10);
    textBlockChartTitleSub.Appearance.Position.Y += 30;
    this.radChart1.ChartTitle.Add(textBlockChartTitleSub);

    Greetings,
    Evgenia
    the Telerik team

    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Steven
    Steven avatar
    7 posts
    Member since:
    Dec 2011

    Posted 08 May 2012 Link to this post

    Hi Evgenia,

    I tried your code above to have different styles applied for the 2nd line of the chart title but got an issue. The chart title is not big enough to hold both lines & thus, only the top half of 2nd line show up. Plz see my attached picture.

    I tried many ways but cannot change the height of the chart title.

    Can you advise me a solution for this? Many thanks.
  5. Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 08 May 2012 Link to this post

    Hello Paulo,

    You can control the size of the Title by turning off the AutoSize property and providing your own Height and Width properties. You will also need to provide bigger top Margin for the PlotArea so that the chart title won't be overlapped by the plot area:

    this.RadChart1.ChartTitle.Appearance.Dimensions.AutoSize = false;
    this.RadChart1.ChartTitle.Appearance.Dimensions.Height = 50;
    this.RadChart1.ChartTitle.Appearance.Dimensions.Width = 170;
    this.RadChart1.PlotArea.Appearance.Dimensions.Margins.Top = 70;

    Regards,
    Evgenia
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. Ken Cox
    Ken Cox avatar
    100 posts
    Member since:
    Oct 2002

    Posted 11 Dec 2012 Link to this post

    Is the sample code for different styles applied to each Chart Title line actually working code?

    I'd really like this functionality. Is there a sample project somewhere?

    Ken
  7. Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 13 Dec 2012 Link to this post

    Hello Ken,

     Modifying the Appearance properties of the second TextBlock won't affect the original one, i.e. you can have different styles for them as shown in the code snippet of the previous post.

    Regards,
    Evgenia
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  8. Ken Cox
    Ken Cox avatar
    100 posts
    Member since:
    Oct 2002

    Posted 13 Dec 2012 Link to this post

    Hi Evgenia

    Thanks for the reply.

    I couldn't get that code to work. Could you put it into a sample project for download?

    Thanks,

    Ken
  9. Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 18 Dec 2012 Link to this post

    Hello Ken,

     You may find a sample attached where this is demonstrated.

    Kind regards,
    Evgenia
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017