This is a migrated thread and some comments may be shown as answers.

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

2 Answers 67 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Lior
Top achievements
Rank 1
Lior asked on 24 Jan 2013, 01:25 PM
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 Answers, 1 is accepted

Sort by
0
Missing User
answered on 29 Jan 2013, 11:07 AM
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.

0
Lior
Top achievements
Rank 1
answered on 01 Feb 2013, 06:16 AM
Thank you for your quick response, I will try.
Tags
Chart
Asked by
Lior
Top achievements
Rank 1
Answers by
Missing User
Lior
Top achievements
Rank 1
Share this question
or