Tooltip for xcategory in chart

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

    Posted 19 Oct 2016 Link to this post



    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
    Peshito avatar
    524 posts

    Posted 19 Oct 2016 Link to this post


    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}" />
    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.

    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top