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

[Solved] TooltipBehavior not functioning

4 Answers 128 Views
Chart for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jason
Top achievements
Rank 1
Jason asked on 20 Mar 2014, 03:34 PM
I have a chart made up of 3 series (2 Area and 1 Point).  I want a Tooltip when the user taps/clicks on one of the Points.  I built this several months ago and it kinda worked, but now it doesn't work at all for some reason.  I tap/click on a data point and nothing happens -- the ContextNeeded event doesn't even fire.  I've tried putting the ChartTooltipBehavior in the chart's Behaviors collection.  I've tried putting the behavior's ContentTemplate in the PointSeries definition.  I've tried setting the ContentTemplate of the behavior to nothing but a 300x300 white rectangle to ensure there wasn't an issue with the ContentTemplate itself.  I'm at a loss.
Here's the chart's definition:

​
<Chart:RadCartesianChart x:Name="SalesChart" HorizontalAlignment="Stretch" Margin="10" VerticalAlignment="Stretch">
    <Chart:RadCartesianChart.Behaviors>
        <Chart:ChartPanAndZoomBehavior ZoomMode="Horizontal" PanMode="Horizontal" />
    </Chart:RadCartesianChart.Behaviors>
    <Chart:RadCartesianChart.HorizontalAxis>
        <Chart:DateTimeContinuousAxis LabelFormat="{}{0:MM/yyyy}" MajorStep="6" MajorStepUnit="Month" />
    </Chart:RadCartesianChart.HorizontalAxis>
    <Chart:RadCartesianChart.VerticalAxis>
        <Chart:LinearAxis />
    </Chart:RadCartesianChart.VerticalAxis>
    <Chart:AreaSeries DisplayName="Value" ItemsSource="{Binding ValuesSeries}" Stroke="Green" Fill="Green">
        <Chart:AreaSeries.CategoryBinding>
            <Chart:PropertyNameDataPointBinding PropertyName="Category" />
        </Chart:AreaSeries.CategoryBinding>
        <Chart:AreaSeries.ValueBinding>
            <Chart:PropertyNameDataPointBinding PropertyName="Value"/>
        </Chart:AreaSeries.ValueBinding>
    </Chart:AreaSeries>
    <Chart:AreaSeries DisplayName="Regression" ItemsSource="{Binding RegressionSeries}" Stroke="Red" Fill="#77FF0000">
        <Chart:AreaSeries.CategoryBinding>
            <Chart:PropertyNameDataPointBinding PropertyName="Category" />
        </Chart:AreaSeries.CategoryBinding>
        <Chart:AreaSeries.ValueBinding>
            <Chart:PropertyNameDataPointBinding PropertyName="Value"/>
        </Chart:AreaSeries.ValueBinding>
    </Chart:AreaSeries>
    <Chart:PointSeries ItemsSource="{Binding SalesSeries}">
        <Chart:ChartTooltipBehavior.ContentTemplate>
            <DataTemplate>
                <Border Background="White" BorderBrush="White" BorderThickness="2" Height="300" Width="300">
                    <Border Background="White" BorderBrush="Black" BorderThickness="2">
                        <Grid Margin="5">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="10" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <TextBlock FontWeight="Bold" HorizontalAlignment="Right" Margin="3" Text="Source: " />
                            <TextBlock Grid.Column="1" Margin="3" Text="{Binding DataPoint.DataItem.AuctionHouse}" />
                            <TextBlock FontWeight="Bold" Grid.Row="1" HorizontalAlignment="Right" Margin="3" Text="Date: " />
                            <TextBlock Grid.Column="1" Grid.Row="1" Margin="3" Text="{Binding DataPoint.DataItem.Date, Converter={StaticResource SaleDateConverter}}" />
                            <TextBlock FontWeight="Bold" Grid.Row="2" Margin="3" HorizontalAlignment="Right" Text="Amount: " />
                            <TextBlock Grid.Column="1" Grid.Row="2" Margin="3" Text="{Binding DataPoint.DataItem.Amount, Converter={StaticResource CurrencyConverterWithUnits}}" />
                            <TextBlock FontWeight="Bold" Grid.Row="4" HorizontalAlignment="Right" Margin="3" Text="Grader: " />
                            <TextBlock Grid.Column="1" Grid.Row="4" Margin="3" Text="{Binding DataPoint.DataItem.Grader}" />
                            <TextBlock FontWeight="Bold" Grid.Row="5" HorizontalAlignment="Right" Margin="3" Text="Cert #: " />
                            <TextBlock Grid.Column="1" Grid.Row="5" Margin="3" Text="{Binding DataPoint.DataItem.CertificateNbr}" />
                            <TextBlock FontWeight="Bold" Grid.Row="6" HorizontalAlignment="Right" Margin="3" Text="Holder: " />
                            <TextBlock Grid.Column="1" Grid.Row="6" Margin="3" Text="{Binding DataPoint.DataItem.GradeType}" />
                            <TextBlock FontWeight="Bold" Grid.Row="7" HorizontalAlignment="Right" Margin="3" Text="Pages: " />
                            <TextBlock Grid.Column="1" Grid.Row="7" Margin="3" Text="{Binding DataPoint.DataItem.PageQuality}" />
                            <TextBlock Grid.ColumnSpan="2" Grid.Row="8" Margin="3" Text="{Binding DataPoint.DataItem.Notes}" TextWrapping="Wrap" />
                        </Grid>
                    </Border>
                </Border>
            </DataTemplate>
        </Chart:ChartTooltipBehavior.ContentTemplate>
        <Chart:PointSeries.PointTemplate>
            <DataTemplate>
                <Ellipse Width="20" Height="20" Fill="White" IsHitTestVisible="True" Stroke="White" />
            </DataTemplate>
        </Chart:PointSeries.PointTemplate>
        <Chart:PointSeries.ValueBinding>
            <Chart:PropertyNameDataPointBinding PropertyName="Amount" />
        </Chart:PointSeries.ValueBinding>
        <Chart:PointSeries.CategoryBinding>
            <Chart:PropertyNameDataPointBinding PropertyName="Date" />
        </Chart:PointSeries.CategoryBinding>
    </Chart:PointSeries>

4 Answers, 1 is accepted

Sort by
0
Accepted
Ivaylo Gergov
Telerik team
answered on 21 Mar 2014, 10:46 AM
Hi,

I checked this scenario using the provided code snippet and everything works as expected on our side. The tooltip shows on hover and the ContextNeeded event fires. Could you please check the attached project and see if it works on your side too? If yes, could you please elaborate on what are the differences with your scenario?

I am looking forward to your reply.

Regards,
Ivaylo Gergov
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
Jason
Top achievements
Rank 1
answered on 21 Mar 2014, 12:49 PM
Thank you Ivaylo for your quick response.
2 things:
1.  I missed that I needed to include the ChartTooltipBehavior in the list of Behaviors for the chart.  I thought that, since I made the tooltip specific to the Series, that wasn't necessary.
2.  How should someone using a touchscreen, which doesn't support "hover", make use of this functionality?  I assumed tapping the data point would cause the tooltip to display, but that's not happening on either project for me using the emulator.
0
Accepted
Ivaylo Gergov
Telerik team
answered on 21 Mar 2014, 02:22 PM
Hello,

On touch devices the tooltip shows after a click and hold. You can control how fast the tooltip shows through the ChartTooltipBehavior.ShowDelay property which is of type TimeSpan.

Let me know if this works for you.

Regards,
Ivaylo Gergov
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
Jason
Top achievements
Rank 1
answered on 21 Mar 2014, 05:16 PM
That did it Ivaylo!  Thank you very much.
Tags
Chart for XAML
Asked by
Jason
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
Jason
Top achievements
Rank 1
Share this question
or