I am trying to make a simple WindowsFormAplication with data displayed in charts with type column.
Now, the idea is for the user to select a part of the chart, and for the program to find the same numbers from the same dataset and select all of them on the SAME chart. My program does just that, up to the point where it needs to display multiple selections on that chart.
I only found one way of selecting data, and that is via Cursor.SetSelectionPosition(double, double); but there doesn't seem to be an option for multiple selection.
Is this even possible on a standard chart? Any suggestions on how to accomplish this in C# will be much appreciated.
There can only be one range selected at any time.
So you need to ..
DataPoints
.An simple way to display several selections, very similar to the cursor selection is adding
Striplines
..:Here is the code for the above result; note that it assumes that your values will fit in a
float
and abuses theSizeF
structure to store the start and end values of the selections. If you want to be more precise you can replace it with aTuple<double, double>
..:First three class level variables to hold the data, the ongoing selection, the list of ranges and a list of
DataPoint
indices:This event holds the new selections in the param
e
, so we can store them:Now the selection process is done; the selection data is lost by now, but we have stored them. So we can add the new range, collect the newly selected
DataPoint
indices and finally create and display a newStripLine
:This little routine should collect all
DataPoint
indices in a range:To clear the selection you clear the two lists, the
StripLines
collection, and thecurRange
structure.