tooltips on xaxis label (Search result doesn't work)

3 posts, 0 answers
  1. Lior
    Lior avatar
    28 posts
    Member since:
    Aug 2012

    Posted 24 Jan 2013 Link to this post

    Hi,
    We face an issue that itemsource in chart for X-ASiX label is too long, we want to short the name but provide the whole text  tooltip for user.

    In this link : http://www.telerik.com/community/forums/silverlight/chart/tooltips-on-xaxis-labels.aspx,

    Telerik guy provided a solution which doesn't work since the coverterer only knows the Label and Labelformat,  the label has the linking to the itemsource, that means we could not change the label. Therefore, does it exists a way to provide a toolip on xaxis label.

    Does exist a chance that we can inhert the tickpoint and a more info to it or exists a way to provide a toolip on xaxis label.




    code shot:
    <chart:RadChart  x:Name="radChart"    Grid.Row="1"  Style="{StaticResource RadChartStyle}"      >
                <chart:RadChart.SeriesMappings >
                  <charting:SeriesMapping LegendLabel="On Shore" CollectionIndex="0">
                    <charting:SeriesMapping.SeriesDefinition>
                      <charting:StackedBar100SeriesDefinition ShowItemToolTips="True" StackGroupName="Sourcing" SeriesName="On Shore"     ItemToolTipFormat="#STPERCENT{#0.#%}"  />
                    </charting:SeriesMapping.SeriesDefinition>
                    <charting:ItemMapping DataPointMember="YValue" FieldName="Count" />
                    <charting:ItemMapping DataPointMember="XCategory"  FieldName="Type"/>
                     
                  </charting:SeriesMapping>
                  <charting:SeriesMapping LegendLabel="Off Shore" CollectionIndex="1">
                    <charting:SeriesMapping.SeriesDefinition>
                      <charting:StackedBar100SeriesDefinition ShowItemToolTips="True"  StackGroupName="Sourcing" SeriesName="Off Shore" ItemToolTipFormat="#STPERCENT{#0.#%}"/>
                    </charting:SeriesMapping.SeriesDefinition>
                    <charting:ItemMapping DataPointMember="YValue" FieldName="Count"/>
                    <charting:ItemMapping DataPointMember="XCategory" FieldName="Type"/>
                  </charting:SeriesMapping>
                  <charting:SeriesMapping LegendLabel="Others" CollectionIndex="2">
                    <charting:SeriesMapping.SeriesDefinition>
                      <charting:StackedBar100SeriesDefinition StackGroupName="Sourcing" ShowItemToolTips="True" SeriesName="Third Party Resources" ItemToolTipFormat="#STPERCENT{#0.#%}"/>
                    </charting:SeriesMapping.SeriesDefinition>
                    <charting:ItemMapping DataPointMember="YValue" FieldName="Count"/>
                    <charting:ItemMapping DataPointMember="XCategory" FieldName="Type"/>
                  </charting:SeriesMapping>
                </chart:RadChart.SeriesMappings>
               
              </chart:RadChart>


    <telerikCharting:LabelFormatConverter x:Name="labelFormatConverter"></telerikCharting:LabelFormatConverter>
            <local:MyConverter x:Key="myConverter"></local:MyConverter>
     
            <Style TargetType="telerik:AxisLabel2D">
                <Setter Property="HorizontalAlignment" Value="Stretch"/>
                <Setter Property="VerticalAlignment" Value="Top"/>
                <Setter Property="ItemLabelStyle">
                    <Setter.Value>
                        <Style TargetType="TextBlock">
                            <Setter Property="TextAlignment" Value="Center"/>
                        </Style>
                    </Setter.Value>
                </Setter>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="telerik: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>
    public class StackedBarToolTipConverter : IValueConverter
     {
         /// <summary>
         /// Convert
         /// </summary>
         /// <param name="value"></param>
         /// <param name="targetType"></param>
         /// <param name="parameter"></param>
         /// <param name="culture"></param>
         /// <returns></returns>
         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
         {
             TickPoint p = value as TickPoint;
             return p.LabelFormat;
         }
     
         /// <summary>
         /// Convert Back
         /// </summary>
         /// <param name="value"></param>
         /// <param name="targetType"></param>
         /// <param name="parameter"></param>
         /// <param name="culture"></param>
         /// <returns></returns>
         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
         {
             throw new NotImplementedException();
         }
     }
  2. Missing user
    Missing user avatar

    Posted 29 Jan 2013 Link to this post

    Hi Lior,

    You should use a custom ValueConverter for the XAxis labels instead of the LabelFormatConverter in the Telerik.Windows.Controls.Charting namespace. For example, implementing a converter with the following Convert method:
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        TickPoint t = value as TickPoint;
        return t.Label != null ? t.Label[0].ToString() : t.Label;  
    }

    and using that converter in the TextBlock within AxisLabel2D's control template:
    <TextBlock   Style="{TemplateBinding ItemLabelStyle}"
            Text="{Binding Converter={StaticResource axisLabelConverter}}"
            ToolTipService.ToolTip="{Binding Converter={StaticResource myConverter}}"/>

    will cause only the first character of the category to be displayed as an axis label, but the tooltip itself will show the full name.

    All the best,
    Ivan N.
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Lior
    Lior avatar
    28 posts
    Member since:
    Aug 2012

    Posted 01 Feb 2013 Link to this post

    Thank you for your quick response, I will try.
Back to Top