RadChart tooltip: e.DataPoint.DataItem is always null

3 posts, 0 answers
  1. Jeroen
    Jeroen avatar
    50 posts
    Member since:
    Feb 2012

    Posted 19 Apr 2012 Link to this post

    In the following chart...

    <telerik:RadChart telerik:StyleManager.Theme="Expression_Dark"
                                                       Height="Auto" MinHeight="100"
                                                       Width="Auto" MinWidth="200"
                                              Margin="0" BorderThickness="0"
                                        <telerik:ChartArea EnableAnimations="False" x:Name="MyChartArea"
                                            <telerik:ChartArea.AxisY >
                                                <telerik:AxisY Title="" AutoRange="True"
                                                                   StripLinesVisibility="Visible" MajorGridLinesVisibility="Visible">
                                                <telerik:AxisX IsDateTime="True"
                                                                   MajorGridLinesVisibility="Visible" MinorGridLinesVisibility="Visible"

    ChartJam.DefaultView.ChartArea.AxisX.AxisStyles.ItemLabelStyle = App.Current.Resources["ChartLabel"] as Style;          
                ChartJam.DefaultView.ChartArea.AxisY.AxisStyles.ItemLabelStyle = App.Current.Resources["ChartLabel"] as Style;
                ChartJam.DefaultView.ChartArea.EnableAnimations = false;
                ChartJam.DefaultView.ChartLegend.Visibility = System.Windows.Visibility.Collapsed;
                ChartJam.DefaultSeriesDefinition = new AreaSeriesDefinition()
                    Appearance = new SeriesAppearanceSettings()
                        Stroke = Utilities.StringToSolidColorBrush("93D427"),
                        StrokeThickness = 1.0,
                        Fill = new SolidColorBrush(Colors.Black)
                    ShowPointMarks = false,
                    ShowItemLabels = false,
                    ShowItemToolTips = true
                SeriesMapping seriesMapping = new SeriesMapping();
                seriesMapping.ItemMappings.Add(new ItemMapping("JamLength", DataPointMember.YValue));
                seriesMapping.ItemMappings.Add(new ItemMapping("DtJamLength", DataPointMember.XValue));
                ChartJam.ItemsSource = _chartsJamGuardVM.LineData;

    ... in the ItemToolTipOpening event, the e.DataPoint.DataItem is always null.

    private void ChartArea_ItemToolTipOpening(ItemToolTip2D tooltip, ItemToolTipEventArgs e)
                if (e.DataPoint.DataItem == null)
                    tooltip.Content = null;

    Any ideas why?
  2. Jeroen
    Jeroen avatar
    50 posts
    Member since:
    Feb 2012

    Posted 19 Apr 2012 Link to this post

    The tooltips work fine if I reduce the amount of points in the chart... A chart with 1000 points doesn't work, while 200 points is fine. What am I doing wrong?
  3. Petar Marchev
    Petar Marchev avatar
    996 posts

    Posted 24 Apr 2012 Link to this post

    Hi Jeroen,

    This is the result of the Sampling feature of the chart. Here you can read about it. In short it is a data sampling mechanism that clusters (summarizes) few data items into a single data point. For instance, if you have 4000 data item in the items source, and if the SamplingThreshold is 200 (by default it is 200) - the chart will get populated with 200 data points, each holding information for 20 data items.

    This feature is on by default (with SamplingThreshold=200). It is on by default because of performance considerations. One option you have is to turn off the sampling by setting the threshold to zero.

    I would generally suggest that you keep the sampling on and explore the sampling functions (from the link above). The custom sampling functions should allow you to specify the text in the tooltip while keeping the sampling enabled.

    I have attached a simple app to get you started with the custom sampling functions. Note that this is a wpf project, but all the code should be valid for Silverlight.

    All the best,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top