I have a chart with a CategoryDateTimeAxis x-axis, some of the data points that have the same date can’t be selected, and I noticed if I add points that have a different date, the selection works as expected.
It seems that the DataPointSelectionModifier.SelectionChanged even is fired but the DataPointSelectionModifier.SelectedPointMarkers collection is empty
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
// Create the X and Y Axis
var xAxis = new CategoryDateTimeAxis() { AxisTitle = "Date", TextFormatting = "dd/MM/yyyy" };
var yAxis = new NumericAxis() { AxisTitle = "Value" };
var selectionModifier = new DataPointSelectionModifier()
{
ReceiveHandledEvents = true,
AllowsMultiSelection = false,
ExecuteOn = ExecuteOn.MouseLeftButton,
UseLayoutRounding = true
};
selectionModifier.SelectionChanged += SelectionModifier_SelectionChanged;
SciChartSurface.XAxis = xAxis;
SciChartSurface.YAxis = yAxis;
SciChartSurface.ChartModifier = new ModifierGroup(
new RubberBandXyZoomModifier(),
new ZoomExtentsModifier(),
selectionModifier);
var series = new XyDataSeries<DateTime, double>();
for (int i = 0; i < 20; i++)
{
var date = i < 10 ? DateTime.Now.AddDays(i) : DateTime.Now.AddDays(10);
series.Append(date, i, new SelectedPointMetadata());
}
var renderableSeries = new FastLineRenderableSeries()
{
DataSeries = series,
XAxis = xAxis,
YAxis = yAxis,
PointMarker = new EllipsePointMarker() { Width = 10, Height = 10, Fill = Colors.Red },
SelectedPointMarker = new EllipsePointMarker() { Width = 10, Height = 10, Fill = Colors.Green },
};
SciChartSurface.RenderableSeries.Add(renderableSeries);
}
private void SelectionModifier_SelectionChanged(object? sender, EventArgs e)
{
if (sender is not DataPointSelectionModifier dataPointSelectionModifier)
{
return;
}
var dataPointInfo = dataPointSelectionModifier.SelectedPointMarkers.FirstOrDefault();
if (dataPointInfo is null)
{
return;
}
var metaData = dataPointInfo.DataPointMetadata as SelectedPointMetadata;
}
}
public class SelectedPointMetadata : IPointMetadata
{
public event PropertyChangedEventHandler PropertyChanged;
public bool IsSelected { get; set; }
}
- Mohamed Ben Amar asked 2 years ago
- last edited 2 years ago
Hi Mohamed, Thank you for reporting this. I’m going to discuss this with our team and will get back to you with an update. Kind regards, Lex, SciChart Technical Support Engineer
- You must login to post comments
Please login first to submit.

