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

SeriesLegendSettings with tooltip

3 Answers 103 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Vinc3nt
Top achievements
Rank 1
Vinc3nt asked on 15 Jul 2013, 04:56 PM
Hi,

Is there a way to add tooltip to LegendItem (in code behind) ?
I do not have a problem to display the legend of each serie but I want to know if it's possible to add a tooltip to legend.

Thank you,
Vincent

3 Answers, 1 is accepted

Sort by
0
Petar Kirov
Telerik team
answered on 18 Jul 2013, 03:18 PM
Hi Vincent,

You can attach a tooltip to the LegendItem by simply modifying the RadLegend.ItemTemplate. In the following example, I have taken the default LegendItemTemplate and I attached a tooltip. The highlighted code is the new one:
<telerik:RadLegend Items="{Binding LegendItems, ElementName=chart}">
  <telerik:RadLegend.ItemTemplate>
    <DataTemplate>
      <StackPanel Orientation="Horizontal"
               ToolTipService.ToolTip="{Binding Title}">
        <Path Fill="{Binding MarkerFill}"
             Width="12"
             Height="12">
          <Path.Data>
            <Binding Path="ActualMarkerGeometry"
   RelativeSource="{RelativeSource AncestorType=telerik:LegendItemControl}">
              <Binding.Converter>
                <telerik:GeometryCloneConverter />
              </Binding.Converter>
            </Binding>
          </Path.Data>
        </Path>
        <TextBlock Margin="2" Text="{Binding Title}" />
      </StackPanel>
    </DataTemplate>
  </telerik:RadLegend.ItemTemplate>
</telerik:RadLegend>

That way if you hover the legend item with mouse a tooltip will appear displaying the Title of the legend item. The DataContext is of type LegendItem, so you have a reference to the underlying DataPoint via the LegendItem.Presenter property. This means that you can bind the tooltip to any of the exposes properties.

I hope this helps.

Regards,
Petar Kirov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Vinc3nt
Top achievements
Rank 1
answered on 13 Dec 2013, 12:25 PM
I have a problem with definition of the Path. It works with Spline Series but not with Bar Series. The color of the scare is not the color of my serie. I change the color of the serie using the Background property.

<Path Fill="{Binding MarkerFill}"
             Width="12"
             Height="12">
          <Path.Data>
            <Binding Path="ActualMarkerGeometry"
   RelativeSource="{RelativeSource AncestorType=telerik:LegendItemControl}">
              <Binding.Converter>
                <telerik:GeometryCloneConverter />
              </Binding.Converter>
            </Binding>
          </Path.Data>
        </Path>

var serieDefintionBar = new BarSeries
                    {
                        CategoryBinding =
                            new PropertyNameDataPointBinding
                            ("XValue"),
                        ValueBinding =
                            new PropertyNameDataPointBinding
                            ("YValue"),
                        Background = mySolidColorBrush,
                        PointTemplate = (DataTemplate)Resources["BarSeriesTemplate"],
                        AllowSelect = true,
                        LegendSettings =
                            legendSetting,
                        ItemsSource = results,
                        ZIndex = 5
0
Pavel R. Pavlov
Telerik team
answered on 18 Dec 2013, 09:18 AM
Hi Lamarque,

Thank you for getting back to us. The reason behind the reported issue is the fact that the BarSeries uses Border component to visualize the different bar, rather than a Path component. In order to change the background of the BarSeries you can use its DefaultVisualStyle property.

Furthermore, you can define a Style targeting the native Border component. You can use similar to this code:

<telerik:BarSeries>
    <telerik:BarSeries.DefaultVisualStyle>
        <Style TargetType="Border">
            <Setter Property="Background">
                <Setter.Value>
                    <SolidColorBrush Color="Red" />
                </Setter.Value>
            </Setter>
        </Style>
    </telerik:BarSeries.DefaultVisualStyle>
</telrik:BarSeries>
I hope this will help you out.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ChartView
Asked by
Vinc3nt
Top achievements
Rank 1
Answers by
Petar Kirov
Telerik team
Vinc3nt
Top achievements
Rank 1
Pavel R. Pavlov
Telerik team
Share this question
or