Tooltip for xcategory in chart

2 posts, 0 answers
  1. ajin prasad
    ajin prasad avatar
    19 posts
    Member since:
    May 2010

    Posted 19 Oct Link to this post

    Hi,

     

    I am using Radchart and I use StackedBarSeriesDefinition and SeriesMappingCollection to bind it to Rad chart.

    I have shortened the string to show it in x-axis. ie the Xcategory value. I need to show the full text on hover the label. Do we have any such things to show tooltip on Xaxis value?

     

     

  2. Peshito
    Admin
    Peshito avatar
    497 posts

    Posted 19 Oct Link to this post

    Hello,

    This scenario can be achieved by setting a custom AxisLabel2D style as shown below:
    <Style x:Key="ItemLabelStyle" TargetType="telerik:AxisLabel2D">
                <Setter Property="Foreground" Value="Orange" />
                <Setter Property="FontSize" Value="13.333" />
                <Setter Property="FontStyle" Value="Italic" />
                <Setter Property="ToolTip" Value="{Binding Value}" />
     </Style>
    then attach to ChartArea's Loaded event and set the style for each axis label:
    private void ChartArea_Loaded(object sender, RoutedEventArgs e)
            {
                ChartArea area = sender as ChartArea;
                HorizontalAxisLabels2D axisLabelsContainer = area.FindChildByType<HorizontalAxisLabels2D>();
                var axisLabels = axisLabelsContainer.ChildrenOfType<AxisLabel2D>();
                Style style = this.Resources["ItemLabelStyle"] as Style;
     
                foreach (var item in axisLabels)
                {
                    item.Style = style;
                }
            }
    In order to show your desired tooltip value, use the Tooltip property and  bind its value to a property of your business object.

    I would also recommend using the newer RadChartView control for new development. More about comparing both charts can be found here.

    Hope this helps.

    Regards,
    Peshito
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top