0

I have a list of Series and each series has different number of datapoints. In my application the user can check a series in a listview and see the plotted points at a chart. I want to add a vertical annotation in order to see the Y value of each signal a the user moves the annotation position. Here is what I have tried so far

 private void chart1_AnnotationPositionChanging(object sender, AnnotationPositionChangingEventArgs e)
    {
             
       var pt1 = (int)VA.X;
        int i = 0;

            foreach (var signal in Signals)
            {
                valtot = signal.Points[pt1].YValues[0];
                listView1.Items[i].SubItems[1].Text = valtot.ToString();                     
                i++;
            }

The problem is that I do not get all points with this solution. I want to move across all datapoints as the user drags the annotation.

nickolas
  • 121
  • 7
  • I find this somewhat unclear. You can move the VA anywhere you want, no? So it will go across all points, no? How is the VA anchored? _relative chart coordinates or .. axes coordinates?_ See [here](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.datavisualization.charting.annotation.x?view=netframework-4.8#system-windows-forms-datavisualization-charting-annotation-x) – TaW Jul 06 '21 at 14:37
  • yes,, but since each series has a different number of datapoints, I got an out of range error. VA is anchored on the first datapoint of the first series. – nickolas Jul 06 '21 at 14:47
  • All chart data are doubles. Your X position is in axis values as you have bound the VA to a point; which is fine. However, when you move it it can land anywhere between points. You need some function to find the next or the last or the nearest point to the current X position. [Here](https://stackoverflow.com/questions/58215195/how-to-display-nearest-data-point-information-of-a-line-chart-by-moving-the-mous/58217135#58217135) is an example.. [Another one](https://stackoverflow.com/questions/46092227/get-chart-value-in-point/46093416#46093416) – TaW Jul 06 '21 at 15:50
  • As the user drags the VA, pt1 gets values like 1,2...10 etc, so valtot shows the 1st, 2nd... 10th datapoint etc. But between the 1st and 2nd second I may have 300 data points which are ignored .Another issue is that each signal in Signals list, has different number of points. – nickolas Jul 07 '21 at 07:57

0 Answers0