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

add marker to nearest value on mouseclick

5 Answers 87 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Monika Kogler
Top achievements
Rank 1
Monika Kogler asked on 05 May 2010, 04:05 PM
hi,
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:
XAML:
<Grid x:Name="LayoutRoot">
      <my:RadChart x:Name="chart" Width="800" Height="500" MouseLeftButtonDown="MouseClicked"></my:RadChart>
  </Grid>

CS:
public ChartControl()
        {
            InitializeComponent();
            ConfigureChart();
            FillSampleChartData();
        }

 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};
            temperatureMapping.ItemMappings.Add(yItemMapping);           
            chart.SeriesMappings.Add(temperatureMapping);
        }

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



5 Answers, 1 is accepted

Sort by
0
Velin
Telerik team
answered on 10 May 2010, 04:35 PM
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

Regards,
Velin
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.
0
Andrew
Top achievements
Rank 1
answered on 27 Jun 2012, 03:55 PM

Hello, guys.

Is there any update on this feature?

I need exactly the same behavior for RadCartesianChart in particular.

Thanks.

0
Bartholomeo Rocca
Top achievements
Rank 1
answered on 02 Jul 2012, 07:20 AM
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).


Greetings,
Bart.
0
Andrew
Top achievements
Rank 1
answered on 02 Jul 2012, 08:16 AM

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.

Regards,

Andrew.

0
Giuseppe
Telerik team
answered on 04 Jul 2012, 12:45 PM
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,
Giuseppe
the Telerik team

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

Tags
Chart
Asked by
Monika Kogler
Top achievements
Rank 1
Answers by
Velin
Telerik team
Andrew
Top achievements
Rank 1
Bartholomeo Rocca
Top achievements
Rank 1
Giuseppe
Telerik team
Share this question
or