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

Pie's tooltip won't show...

2 Answers 102 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Michele
Top achievements
Rank 2
Michele asked on 07 Jul 2009, 01:15 PM
Hello,
I've some thoubles showing up the itemtooltip on a pie chart (I've also problem with other chart type), here's my code :

 public AccountPositionPie(ObservableCollection<IFSforamenti.AccountPositionDetail> sforamentoDetail) 
        { 
            m_SforamentoDetail = sforamentoDetail
            InitializeComponent(); 
 
            //This is for the tooltip on the pie 
 
            LoadPie(); 
            chartAccountPosition.DefaultSeriesDefinition.ShowItemToolTips = true
            chartAccountPosition.DefaultSeriesDefinition.SeriesItemTooltipStyle = CustomTooltipStyle
            chartAccountPosition.DefaultView.ChartArea.ItemToolTipDelay = 500
            chartAccountPosition.DefaultView.ChartArea.ItemToolTipOpening += new ItemToolTipEventHandler(ChartArea_ItemToolTipOpening); 
            //ChartArea1.ItemToolTipOpening += new ItemToolTipEventHandler(ChartArea_ItemToolTipOpening); 
 
        } 

Here's how I bind the datas :

    private void LoadPie() 
        { 
            DataSeries dataSeries = new DataSeries(); 
            dataSeries.LegendLabel = "First Series"
            dataSeries.Definition = new PieSeriesDefinition(); 
            //dataSeries.Definition = new LineSeriesDefinition(); 
            //dataSeries.Definition = new DoughnutSeriesDefinition(); 
 
            var res = m_SforamentoDetail.GroupBy(o1 => o1.ClassMifid); 
 
            resres = res.OrderBy(o1 => o1.Key); 
            foreach (IGrouping<int, IFSforamenti.AccountPositionDetail> group in res) 
            { 
                DataPoint dp = new DataPoint(); 
                dp.YValue = group.Sum(o1 => o1.PercOnCTV); 
                dp.LegendLabel = string.Format("{0}: {1}", LabelPrefix, group.Key.ToString()); 
 
                dataSeries.Add(dp); 
            } 
            chartAccountPosition.DefaultView.ChartArea.DataSeries.Add(dataSeries); 
            //  chartAccountPosition.DefaultView.ChartArea = ChartArea1
 
        } 

And here's the XAML portion :

<UserControl xmlns:my="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting"  x:Class="IFWebLight.Sforamenti.AccountPositionPie" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    xmlns:telerikCharting="clr-namespace:Telerik.Windows.Controls.Charting;assembly=Telerik.Windows.Controls.Charting" 
    Width="1100" Height="300"
    <Grid x:Name="LayoutRoot" Background="White"
        <Grid.Resources> 
 
            <Style x:Name="CustomTooltipStyle" TargetType="telerikCharting:ItemToolTip2D" > 
                <Setter Property="OuterBorderBrush" Value="#FF767676" /> 
                <Setter Property="InnerBorderBrush" Value="#FFFFFFFF" /> 
                <Setter Property="Foreground" Value="#FF666666" /> 
                <Setter Property="Background"
                    <Setter.Value> 
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"
                            <GradientStop Color="#FFFFFFFF" Offset="0"/> 
                            <GradientStop Color="#FFE4E5F0" Offset="1"/> 
                        </LinearGradientBrush> 
                    </Setter.Value> 
                </Setter> 
                <Setter Property="BorderOpacity" Value="0" /> 
                <Setter Property="Template"
                    <Setter.Value> 
                        <ControlTemplate TargetType="telerikCharting:ItemToolTip2D"
                            <Border x:Name="ToolTipBorder"  
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                CornerRadius="3" 
                                BorderBrush="{TemplateBinding OuterBorderBrush}" 
                                Opacity="{TemplateBinding BorderOpacity}"
                                <telerikCharting:ClipPanel> 
                                    <Border 
                                        BorderThickness="{TemplateBinding BorderThickness}" 
                                        CornerRadius="2" 
                                        BorderBrush="{TemplateBinding InnerBorderBrush}" 
                                        Background="{TemplateBinding Background}"
                                        <ContentControl Padding="10" Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" /> 
                                    </Border> 
                                </telerikCharting:ClipPanel> 
                                <Border.Triggers> 
                                    <EventTrigger RoutedEvent="Border.Loaded"
                                        <EventTrigger.Actions> 
                                            <BeginStoryboard> 
                                                <Storyboard > 
                                                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.6" Storyboard.TargetName="ToolTipBorder" Storyboard.TargetProperty="(UIElement.Opacity)"
                                                        <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/> 
                                                        <SplineDoubleKeyFrame KeyTime="00:00:00.6" Value="1"/> 
                                                    </DoubleAnimationUsingKeyFrames> 
                                                </Storyboard> 
                                            </BeginStoryboard> 
                                        </EventTrigger.Actions> 
                                    </EventTrigger> 
                                </Border.Triggers> 
                            </Border> 
                        </ControlTemplate> 
                    </Setter.Value> 
                </Setter> 
            </Style> 
        </Grid.Resources> 
        <my:RadChart x:Name="chartAccountPosition"
 
            <!--<telerikCharting:ChartArea x:Name="ChartArea1"  
                                       LegendName="ChartLegend1" 
                                       ItemToolTipOpening="ChartArea_ItemToolTipOpening" 
                                       Margin="0,0,0,10"/>--> 
 
        </my:RadChart> 
    </Grid> 
</UserControl> 

Where am I wrong?

In the ItemToolTipOpening event for now I do

 void ChartArea_ItemToolTipOpening(ItemToolTip2D tooltip, ItemToolTipEventArgs e) 
        { 
            tooltip.Content = "5"
        } 

but nothing happens...
Thanks in advance

Paolo





2 Answers, 1 is accepted

Sort by
0
Accepted
Giuseppe
Telerik team
answered on 07 Jul 2009, 02:24 PM
Hi Paolo,

The SeriesDefinition specified by RadChart.DefaultSeriesDefinition property is used only in databinding scenarios (in case you have not specified specific definition). When you are building the DataSeries manually, you need to set the SeriesDefinition.ShowItemToolTips property on your specific SeriesDefinition like this:

DataSeries series = new DataSeries(); 
 
series.Definition = new PieSeriesDefinition() 
                        { 
                            ShowItemToolTips = true, 
                            SeriesItemTooltipStyle = CustomTooltipStyle 
                        }; 
series.Add(new DataPoint() { YValue = 20 }); 
series.Add(new DataPoint() { YValue = 35 }); 
 
chartAccountPosition.DefaultView.ChartArea.DataSeries.Add(series); 
 

Hope this helps.


Sincerely yours,
Manuel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Michele
Top achievements
Rank 2
answered on 07 Jul 2009, 02:51 PM
Hello Manuel,
yes it helped me... I was pointing it to the DefaultSeriesDefinition :(

Thanks again
Tags
Chart
Asked by
Michele
Top achievements
Rank 2
Answers by
Giuseppe
Telerik team
Michele
Top achievements
Rank 2
Share this question
or