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

Crosshair label definition template with chart values

2 Answers 167 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Flemming
Top achievements
Rank 1
Flemming asked on 07 Sep 2016, 11:09 AM

I have a RadCartesianChart with a DateTimeContinuousAxis and a ChartCrosshairBehavior.

When the vertical line label shows – it displays the date/time. I want to display other data from the chart too – but even when I use a template for the label definition – the only DataContext I can access is the datetime. 

Is there a way to customize the label definition - to include data from other sources? 

/Flemming Rosenbrandt

 

2 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 09 Sep 2016, 08:36 AM
Hi Flemming,

Indeed, the labels of the crosshair know only about the value on the axis that corresponds to the mouse position. In order to get other data from the view model of the chart itself you can use RelativeSource or ElementName binding.
<telerik:ChartCrosshairBehavior.VerticalLineLabelDefinition>
    <telerik:ChartAnnotationLabelDefinition>
        <telerik:ChartAnnotationLabelDefinition.Template>
            <DataTemplate>
                <TextBlock Text="{Binding ElementName=chart, Path=DataContext.MyAdditionalInformation}" />
            </DataTemplate>
        </telerik:ChartAnnotationLabelDefinition.Template>
    </telerik:ChartAnnotationLabelDefinition>
</telerik:ChartCrosshairBehavior.VerticalLineLabelDefinition>

Regards,
Martin
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Flemming
Top achievements
Rank 1
answered on 12 Sep 2016, 12:08 PM
Thanks - I will give it a try.
Tags
ChartView
Asked by
Flemming
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Flemming
Top achievements
Rank 1
Share this question
or