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

Tooltip DataTemplate

3 Answers 325 Views
Chart
This is a migrated thread and some comments may be shown as answers.
David White
Top achievements
Rank 1
David White asked on 25 Jun 2009, 10:50 AM
Hi, Is it possible to modify the content of the tooltip?
When hovering a chart bar, we would like to handle the OnTooltipOpening Event and insert an ItemsControl or other (grid, ListBox...) to show details of the data.

So far, I have been able to get the datapoint (related data) but the child element of the tooltip is not showing.

Is there a TooltipTemplate somewhere and I haven't seen it? Or is it called something else?
It would be better to define this template in XAML and the databinding/context on the TooltipOpening event for me.

Any suggestion?

Thanks

3 Answers, 1 is accepted

Sort by
0
Dwight
Telerik team
answered on 30 Jun 2009, 07:59 AM
Hello David,

It is possible to add whatever content you require in the tooltip. Please, refer to the Chart > Data Drill Down example in our QSF ( XBAP version of the QSF can be found online at http://demos.telerik.com/wpf/ )

More over, instead of creating each and every element in code (as demonstrated in the example), you can create a static resource and use it.
Here is the XAML code added to the example:
<QuickStart:Example.Resources> 
    <ListBox x:Key="listBoxForTooltip" x:Shared="false" /> 
</QuickStart:Example.Resources> 
Note the x:Shared property set to false. It guarantees that the resource can be used at multiple places.

Here is the Code-behind:
private void ChartItemToolTipOpening(ItemToolTip2D tooltip, ItemToolTipEventArgs args) 
    ListBox list = (ListBox)this.FindResource("listBoxForTooltip"); 
    list.ItemsSource = args.DataSeries; 
    tooltip.Content = list; 

Let me know if you need further assistance.

Best wishes,
Evtim
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
Rakhi
Top achievements
Rank 1
answered on 13 Oct 2010, 08:43 AM
Hello, I jst want my axis value on tooltip with default format (if any) applied on axis label format.

For example,

radChart1.SeriesMappings.Clear();
radChart1.DefaultView.ChartTitle.Content = "Top 10 Countries by GDP 2008 (nominal)";
radChart1.DefaultView.ChartArea.AxisY.Title = "Amount";
radChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "#VAL{dd-MM-yyyy}";
radChart1.DefaultView.ChartArea.AxisY.DefaultLabelFormat = "#VAL{#,###0.0000}";
            
SeriesMapping sm = new SeriesMapping();
sm.SeriesDefinition = new BarSeriesDefinition();
sm.SeriesDefinition.ShowItemToolTips = true;
sm.SeriesDefinition.ItemToolTipFormat = "Date: #DATAITEM.VOUCH_DATE" +
                                                    Environment.NewLine + 
                                                    "Amount: #DATAITEM.TOTAL_QTY";

sm.ItemMappings.Add(new ItemMapping("TOTAL_QTY", DataPointMember.YValue));
sm.ItemMappings.Add(new ItemMapping("VOUCH_DATE", DataPointMember.XCategory));
radChart1.SeriesMappings.Add(sm);

var dt1 = (from dRow in LoadData().AsEnumerable()
                       select new
                       {
                           VOUCH_DATE = dRow["VOUCH_DATE"],
                           TOTAL_QTY = dRow["TOTAL_QTY"]
                       }
                      );
radChart1.ItemsSource = dt1;

Now, i want whatever format is set my tooltip value should be set according to that and the case may be no format is set then tooltip should show default value as in database.


Please help.
0
Vladimir Milev
Telerik team
answered on 19 Oct 2010, 08:31 AM
Hello Rakhi,

You can override the tooltip formatting by setting the ToolTip property directly. You can do this by adding a new ItemMapping which maps a field from the data table to the DataPointMember.ItemToolTip.

Greetings,
Vladimir Milev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
David White
Top achievements
Rank 1
Answers by
Dwight
Telerik team
Rakhi
Top achievements
Rank 1
Vladimir Milev
Telerik team
Share this question
or