Tooltips on Xaxis labels?

13 posts, 1 answers
  1. Danny Scheelings
    Danny Scheelings avatar
    69 posts
    Member since:
    Jan 2006

    Posted 05 Aug 2010 Link to this post

    Hello,

    I have to create a chart where the labels on x-axis are very long. So I will provide a shortened name in the ItemsSource to show as the X-axis labels, but I want to show the long name as a tooltip on the X-axis labels.
    Is this possible?

    Thanks,
    Danny
  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 10 Aug 2010 Link to this post

    Hi Danny,

    One possible option in this case would be to attach to the DataBound event handler of the Chart control, and loop through the labels to set the desired text. This may look like this:

    telerikChart.DefaultView.ChartArea.AxisX.TickPoints[0].Label = "CustomLabel1";

    I hope this gets you started properly.

    Regards,
    Yavor
    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. Danny Scheelings
    Danny Scheelings avatar
    69 posts
    Member since:
    Jan 2006

    Posted 30 Aug 2010 Link to this post

    Hi Yavor,

    Thanks for your reply.
    This way only the text of the tickpoints can be changed. But I want to set a tooltip on a tickpoint. I tried the code below but that does not compile:
    void chart_DataBound(object sender, ChartDataBoundEventArgs e)
    {
        foreach (TickPoint tp in this.chart.DefaultView.ChartArea.AxisX.TickPoints)
        {
            ToolTipService.SetToolTip(tp, tp.Label + "aaa");
        }
    }

    Is there a way to set a tooltip on the tickpoint?

    Thanks,
    Danny
  4. Answer
    Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 02 Sep 2010 Link to this post

    Hello Danny,

    Attached to this message, is a small application, which handles a functionality close to the one which we discussed. I hope it gets you started properly.

    Regards,
    Yavor
    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
  5. Danny Scheelings
    Danny Scheelings avatar
    69 posts
    Member since:
    Jan 2006

    Posted 02 Sep 2010 Link to this post

    Yavor,
    This is great! Thx !!!!
  6. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 02 Sep 2010 Link to this post

    Hello Danny,

    I am glad that the solution is working as per your requirements. Since there is no easy way to set the tooltip for the items from the code-behind via the TooltipService.SetTooltip() method, this is the best alternative. Let me know if further questions arise.

    Best wishes,
    Yavor
    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
  7. Lauren
    Lauren avatar
    37 posts
    Member since:
    Jan 2010

    Posted 10 Sep 2010 Link to this post

    Hi,

    This is exactly what i was looking for. Or almost...

    Is there a way to apply this to the X-axis only ?
    In the ItemLabelStyle, i set the Width property and use TextTrimming. And in the tooltip, i show the full x-axis category.
    But it seems that this width is also applied to the Y-axis.
    How can i apply this to the x-axis only ?

    Thanks for your help.

    -------
    <telerikCharting:LabelFormatConverter x:Name="labelFormatConverter"></telerikCharting:LabelFormatConverter>
    <local:MyConverter x:Key="myConverter"></local:MyConverter>
    <Style TargetType="telerikCharting:AxisLabel2D">
        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <Setter Property="VerticalAlignment" Value="Top"/>
        <Setter Property="ItemLabelStyle">
            <Setter.Value>
                <Style TargetType="TextBlock">
                    <Setter Property="TextAlignment" Value="Right"/>
                    <Setter Property="Width" Value="80"/>
                    <Setter Property="TextTrimming" Value="WordEllipsis"/>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="telerikCharting:AxisLabel2D">
                    <telerik:LayoutTransformControl x:Name="PART_LayoutTransformControl" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
                        <telerik:LayoutTransformControl.LayoutTransform>
                            <RotateTransform x:Name="PART_RotateTransform"/>
                        </telerik:LayoutTransformControl.LayoutTransform>
                        <TextBlock Style="{TemplateBinding ItemLabelStyle}" Text="{Binding Converter={StaticResource labelFormatConverter}}" ToolTipService.ToolTip="{Binding Converter={StaticResource myConverter}}"/>
                    </telerik:LayoutTransformControl>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
  8. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 16 Sep 2010 Link to this post

    Hello Lauren,

    One straightforward solution is to use the converter and determine the value(s):

    public class MyConverter : IValueConverter
       {
           public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
           {            
               return "some Custom Value";
           }
           public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
           {
               throw new NotImplementedException();
           }
       }

    based on the parameter passed.
    Alternatively, you can keep in mind that first the values along the y-axis are populated, and then these along the x axis. Thus, you can use two counters, to determine when to return different values.
    I hope this information helps. Let me knoe how it goes.

    Sincerely yours,
    Yavor
    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
  9. vijay
    vijay avatar
    46 posts
    Member since:
    Jul 2010

    Posted 16 Aug 2011 Link to this post

    Hi Team/Danny ,

    thanks it is working.

    But not working when we applied themeas.

    for ex: I have applied the following theme "ToolTip is not coming"

    StyleManager.SetTheme(Chart1, new Expression_DarkTheme());

    can you please help me...i need the solution very urgent.

    Thanks
    -VIjay



  10. vijay
    vijay avatar
    46 posts
    Member since:
    Jul 2010

    Posted 23 Sep 2011 Link to this post

    Hi Team,

    still i am waiting for the tool tip on axisX lables...

    can you update the solution as soon as possibel..


    thanks in advance
    -Vijay Kommalapati
  11. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 28 Sep 2011 Link to this post

    Hi Vijay,

    If the sample is not working as per your requirements, you can open a formal support ticket, and send us the problematic code, for additional review and testing.

    Greetings,
    Yavor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  12. vijay
    vijay avatar
    46 posts
    Member since:
    Jul 2010

    Posted 05 Oct 2011 Link to this post

    please give me option to send complete solution.
  13. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 10 Oct 2011 Link to this post

    Hi Vijay,

    You cannot send the sample here in the forum - you can attach it in a support ticket.

    Regards,
    Yavor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top