Setting Point Label Style FontFamily

4 posts, 0 answers
  1. Brian
    Brian avatar
    58 posts
    Member since:
    Jul 2011

    Posted 22 Jul 2011 Link to this post

    I am trying to set the FontFamily for the point label on my chart.  I have copied the default style for the SeriesItemLabel using ExpressionBlend and have named it DefaultSeriesItemLabelStyle.  I created two styles based on this style, RairSeriesItemLabelStyle and RairDarkTextSeriesItemLabelStyle:

    <Style x:Key="RairSeriesItemLabelStyle" TargetType="telerik:SeriesItemLabel" BasedOn="{StaticResource DefaultSeriesItemLabelStyle}">
                <Setter Property="FontFamily" Value="Tacoma,Arial"/>
            </Style>
            <Style x:Key="RairDarkTextSeriesItemLabelStyle" TargetType="telerik:SeriesItemLabel" BasedOn="{StaticResource RairSeriesItemLabelStyle}">
                <Setter Property="Foreground" Value="#333"/>
            </Style>

    I have set them on two LineSeriesDefinitions on my chart, but while the text color changes to match the foreground color, the font family does not change.  How can I change the font family for the point labels?
  2. Sia
    Admin
    Sia avatar
    756 posts

    Posted 25 Jul 2011 Link to this post

    Hi Brian,

    I have tested this and it works as expected on my end. I think that you have a typo:
    <Style x:Key="RairSeriesItemLabelStyle" TargetType="telerik:SeriesItemLabel" BasedOn="{StaticResource SeriesItemLabelStyle}">
        <Setter Property="FontFamily" Value="Tahoma,Arial"/>
    </Style>

    Please let me know whether this is true.

    Kind regards,
    Sia
    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!

  3. Brian
    Brian avatar
    58 posts
    Member since:
    Jul 2011

    Posted 25 Jul 2011 Link to this post

    Sia,
    I think that is probably a typo in the original stylesheet that I am basing these styles on, however, correcting the typo still doesn't fix the issue for me, and I am using the same font family value for the axis labels and it is falling back to Arial as it should.  I have attached a screenshot of part of my chart that shows the problem (chart fonts.png).  You can see that the font color for the yellow series is dark, so the Foreground property in RairDarkTextSeriesitemLabelStyle appears to be applied.  As you can see by the difference in the bottom of the 1 on the point label and the the axis, the font family is not being applied.

    Edit: The issue seems to be related to style inheritance.  If I put the font family setter directly on the RairDarkTextSeriesItemLabelStyle, then the font family is applied.  If I rely on the inheritance from RairSeriesItemLabelStyle, it doesn't work.  This works:

    <Style x:Key="RairSeriesItemLabelStyle" TargetType="telerik:SeriesItemLabel" BasedOn="{StaticResource DefaultSeriesItemLabelStyle}">
                <Setter Property="FontFamily" Value="Tacoma,Arial"/>
            </Style>
            <Style x:Key="RairDarkTextSeriesItemLabelStyle" TargetType="telerik:SeriesItemLabel" BasedOn="{StaticResource RairSeriesItemLabelStyle}">
                <Setter Property="FontFamily" Value="Tacoma,Arial"/>
                <Setter Property="Foreground" Value="#333"/>
            </Style>
     (see chart fonts 2.png)
  4. Sia
    Admin
    Sia avatar
    756 posts

    Posted 26 Jul 2011 Link to this post

    Hello Brian,

    I confirm that there is a problem with the SeriesItemLabel when you use a style based on another one and setting the font family in the first one. Please use the suggested workaround.

    All the best,
    Sia
    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!

Back to Top