Discrete moving crosshairs (ChartCrosshairBehavior)

2 posts, 1 answers
  1. Гоша
    Гоша avatar
    11 posts
    Member since:
    Aug 2010

    Posted 23 Dec 2016 Link to this post

    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>
  2. Answer
    Martin Ivanov
    Admin
    Martin Ivanov avatar
    1444 posts

    Posted 26 Dec 2016 Link to this post

    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.
Back to Top