Custom tooltip for chart, returns tooltip's DataPoints.DataItem as null

2 posts, 0 answers
  1. Edward
    Edward avatar
    3 posts
    Member since:
    Nov 2010

    Posted 30 Nov 2011 Link to this post

        When using the event which allows you to custom the tooltips for a bar\line chart. The DataItem that is passed to the event is returned as null. This only happens when you have alot of points to display in a small area. But if you have less pionts to display, the dataitem object contents the data for the piont that was rollover, allowing you to custom the tooltip. 

    So, is there is property which I can be set that allows you to custom the tooltip, even when their is alot of pionts in a small area.

    One thing interesting is, when Dataitem is null the tooltip is just the default one that the points was bind too.

    Any help would be appreciated.

    Best Regards,
    Jeramie
  2. Petar Marchev
    Admin
    Petar Marchev avatar
    1029 posts

    Posted 05 Dec 2011 Link to this post

    Hello Edward,

    When working with a huge number of data items (in the ItemsSource) the RadChart offers a feature called Sampling. To avoid unclear visual representation, and to improve performance, the chart combines several data items into a single data point.

    For instance - if you have 1000 items in your items source - only 200 data points will be visualized (that is 200 bars, if you use bar series). That means that each data point contains information for 5 data items.

    This is why the DataItem that is passed is null. 

    You can set how many data points to be visualized by setting the SamplingThreshold property (by default it is 200).

    In your case you might need to fully disable Sampling by setting SamplingThreshold  to "0".
    <telerik:RadChart x:Name="radChart">
     <telerik:RadChart.SamplingSettings>
      <telerik:SamplingSettings SamplingThreshold="0" />

    You can read about Sampling here where you can also get information about Custom Sampling Functions which are very helpful to use in some scenarios where disabling Sampling will have a negative impact on the performance.

    I hope this helps. 

    Kind regards,
    Petar Marchev
    the Telerik team

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

Back to Top