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

Discrete moving crosshairs (ChartCrosshairBehavior)

1 Answer 139 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Гоша
Top achievements
Rank 1
Гоша asked on 23 Dec 2016, 10:16 AM

Hello!

Could you tell me how to adjust the crosshairs so that it shifted to a discrete value (for example a multiple of 0.25) for the "Y" axis (for example, 1 minute) on the X axis.

 

<telerik:RadCartesianChart Grid.Row="1" Background="{x:Null}">
 
            <telerik:RadCartesianChart.VerticalAxis>
                <telerik:LinearAxis x:Name="AxisY" HorizontalLocation="Right" LineThickness="1" SmartLabelsMode="SmartStepAndRange" MajorStep="1"   />
            </telerik:RadCartesianChart.VerticalAxis>
 
            <telerik:RadCartesianChart.HorizontalAxis>
                <telerik:DateTimeCategoricalAxis x:Name="AxisX" LabelFormat="HH:mm"
                                                LabelFitMode="Rotate" SmartLabelsMode="SmartStep"
                                                PlotMode="OnTicksPadded" />
            </telerik:RadCartesianChart.HorizontalAxis>
 
            <telerik:RadCartesianChart.Behaviors>               
                <telerik:ChartCrosshairBehavior
                    HorizontalLineLabelDefinition="{DynamicResource ChartAnnotationLabelDefinitionHorizontal}"
                    VerticalLineLabelDefinition="{DynamicResource ChartAnnotationLabelDefinitionVertical}" PositionChanged="ChartCrosshairBehavior_PositionChanged" />               
 
            </telerik:RadCartesianChart.Behaviors>
 
            <telerik:CandlestickSeries x:Name="csPrice" ZIndex="1"
                                       ItemsSource="{Binding Candles}"
                                       CloseBinding="ClosePrice"
                                       CategoryBinding="Date"
                                       HighBinding="HighPrice"
                                       LowBinding="LowPrice"
                                       OpenBinding="OpenPrice"
                                       AllowSelect="True"                                       
                                       DefaultVisualStyle="{DynamicResource CandleStikSeriesDefaultStyle}"
                                       DefaultVisualStyleSelector="{Binding Mode=OneWay, Source={StaticResource CandleStikSeriesSelectStyle}}"
                                        />
 
             
 
        </telerik:RadCartesianChart>

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 26 Dec 2016, 11:54 AM
Hi Gosha,

The chart crosshair is designed to follow the mouse and you can't change this behavior. Instead of the crosshair, you can use the trackball behavior which snaps to data points. If this doesn't work for you, it is possible to implement your requirement using chart annotations, the conversion API and mouse events. You can see the TrackBallLikeAnnotations SDK example which will be helpful in this case because it shows how to create an interactive annotation.

Also, there is feature request about implementing trackball-like crosshair behavior which you can find logged in our feedback portal. There you can track its status and vote for an implementation.

Regards,
Martin
Telerik by Progress
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
Chart
Asked by
Гоша
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or