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

Why my tooltip is not showing?

1 Answer 592 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
ardmore
Top achievements
Rank 1
ardmore asked on 07 Nov 2017, 05:11 PM

I used MVVM to create a data source(property), then I use RadCartesianChart to plot it. It works but I can not see the tooltip when hover mouse to the bars.

<telerik:ChartDataSource x:Name="ChartDataSource1" Items="{Binding Sales}" />
 
<telerik:RadCartesianChart x:Name="barSeries">
   <telerik:RadCartesianChart.Behaviors>
      <telerik:ChartTooltipBehavior="Top" VerticalOffset="20" />
   </telerik:RadCartesianChart.Behaviors>
   <telerik:RadCartesianChart.TooltipTemplate>
        <DataTemplate>
           <Grid>
            <Path Data="M-1236,-441 L-1180,-441 -1180,-424 -1228,-424 -1230.5,-420 -1233,-424 -1236,-424 z"
                      Stretch="Fill" Fill="Beige" Stroke="Gray" StrokeThickness="2"/>
                <StackPanel Margin="5,5,5,18">
                    <StackPanel Orientation="Horizontal">
                        
                        <TextBlock Text="{Binding Path=DataItem.Quarter}" FontWeight="Bold" FontSize="11"/>
                       </StackPanel>
           </Grid>
        </DataTemplate>
        <telerik:RadCartesianChart.Grid>
             <telerik:CartesianChartGrid MajorLinesVisibility="XY"
                                         MajorYLineDashArray="10,5"
                                         MajorXLinesRenderMode="All"
            </telerik:CartesianChartGrid>
        </telerik:RadCartesianChart.Grid>  
    <telerik:RadCartesianChart.HorizontalAxis>
        <telerik:CategoricalAxis/>
    </telerik:RadCartesianChart.HorizontalAxis>
    <telerik:RadCartesianChart.VerticalAxis>
        <telerik:LinearAxis/>
    </telerik:RadCartesianChart.VerticalAxis>
    <telerik:BarSeries CategoryBinding="Quarter" ValueBinding="Profit" Items="{Binding Element=ChartDataSource1}"/>
</telerik:RadCartesianChart>

Thanks

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 10 Nov 2017, 09:30 AM
Hi Hui Zhao,

Thank you for your interest in RadChartView control.

This behavior is expected when you have used ChartDataSource. Basically, the DataItem property no longer points to a view model from your collection. The sampling combines several data items into a single data point. In this case, the DataItem property of the DataPoint holds a reference to an object of type DataPointSamplingInfo which holds information about the sampled data and the aggregate used to sample it. You can read more about this behavior in the DataPointSamplingInfo section in our documentation. 

In your case, you can remove the DataItem from the binding. Attached to this reply you can find sample project based on the provided code snippet which demonstrates this approach. Hope this information is helpful.

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
ChartView
Asked by
ardmore
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or