add marker to nearest value on mouseclick

6 posts, 0 answers
  1. Monika Kogler
    Monika Kogler avatar
    30 posts
    Member since:
    Aug 2009

    Posted 05 May 2010 Link to this post

    here is my scenario: i have a line-chart with a lots of data (30.000 points), x-axis is datetime, y-axis are double values. what i want to do is, if i click somewhere in the chart a marker (vertical and horizontal line on the whole chart area like a cross) should appear on the next datapoint and the values are supposed to be writen in a textblock.
    further, it should be possible to add several markers to one chartarea and select each of them by clicking on a label or something similar.
    how can i implement this feature? and how can i receive the mouse-click-coordinates?
    thx in advance

    my code:
    <Grid x:Name="LayoutRoot">
          <my:RadChart x:Name="chart" Width="800" Height="500" MouseLeftButtonDown="MouseClicked"></my:RadChart>

    public ChartControl()

     private void ConfigureChart()
                chart.DefaultView.ChartArea.EnableAnimations = false;          
                chart.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom;   
                chart.DefaultView.ChartArea.AxisX.MajorGridLinesVisibility = Visibility.Visible;
                chart.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "MMMM yyyy";         
                SeriesMapping temperatureMapping = new SeriesMapping();
                LineSeriesDefinition lineDefinition = new LineSeriesDefinition
                                                      {ShowItemLabels = false, ShowPointMarks = false};
                temperatureMapping.SeriesDefinition = lineDefinition;
                temperatureMapping.ItemMappings.Add(new ItemMapping("Date", DataPointMember.XValue));
                ItemMapping yItemMapping = new ItemMapping("Value", DataPointMember.YValue)
                                           {SamplingFunction = ChartSamplingFunction.Average};

    private void FillSampleChartData()
              chart.ItemsSource = LoadTemperaturesFromDB(); //loads approx. 30.000 points from db

  2. Velin
    Velin avatar
    391 posts

    Posted 10 May 2010 Link to this post

    Hi Monika Kogler,

    Unfortunately, this functionality is not supported by RadChart at present. Our development team has plans implement custom grid lines as well as current value indicator(features that should cover your requirements in general) but due to the tight schedule we can not confirm that these will be available in the upcoming Q2 release.

    Please, accept our apologies for this inconvenience

    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft R3 2016 release webinar banner
  4. Andrew
    Andrew avatar
    2 posts
    Member since:
    Jun 2012

    Posted 27 Jun 2012 Link to this post

    Hello, guys.

    Is there any update on this feature?

    I need exactly the same behavior for RadCartesianChart in particular.


  5. Bartholomeo Rocca
    Bartholomeo Rocca avatar
    247 posts
    Member since:
    May 2006

    Posted 02 Jul 2012 Link to this post

    Hello Andrew,

    RadCartesianChart supports similar behavior out-of-the-box -- it is called ChartTrackBallBehavior and you can see it in action in this online example here (hover the mouse over the lower left chart).

  6. Andrew
    Andrew avatar
    2 posts
    Member since:
    Jun 2012

    Posted 02 Jul 2012 Link to this post

    Hello, Bartholomeo, thank you for the reply.

    I know about ChartTrackBallBehavior, but it only works on mouse hover, while I wanted the same for mouse click. 

    So that after user clicks somewhere on chart, hairpin stays at that point and does not move after the mouse. Some event is fired and we can get X value on server side. When data is added to chart, hairpin stays at the same X point.

    Maybe it is possible to add such kind of property to ChartTrackBallBehavior in future releases.



  7. Giuseppe
    Giuseppe avatar
    2363 posts

    Posted 04 Jul 2012 Link to this post

    Hello Andrew,

    Currently such functionality is not supported on mouse click, however, we are planning to introduce support for chart annotations for Q3 2012 that will enable such customization scenarios as well.

    Hope this helps.

    All the best,
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
DevCraft R3 2016 release webinar banner