Hello, I am trying to use the default DataPointSelectionModifier on a line chart with a DataSeries of type XyDataSeries<‘DateTime, double’> as in the example suite HERE . It seems to work fine out of the box if the DataSeries is of type XyDataSeries<‘double, double’>. Am I missing something as to why this modifier is not working with the former data type?
Relevent code is:
CustomChart.xaml:
<sci:SciChartSurface x:Name="customChart"
Grid.Column="0">
<sci:SciChartSurface.RenderableSeries>
<sci:FastLineRenderableSeries Name="lineRenderableSeries"
Stroke="#4AB748"
StrokeThickness="1">
<sci:FastLineRenderableSeries.PointMarker>
<sci:EllipsePointMarker Fill="#138A43" />
</sci:FastLineRenderableSeries.PointMarker>
<sci:FastLineRenderableSeries.SelectedPointMarker>
<sci:EllipsePointMarker Fill="#C4ECA0"
Width="12"
Height="12" />
</sci:FastLineRenderableSeries.SelectedPointMarker>
</sci:FastLineRenderableSeries>
</sci:SciChartSurface.RenderableSeries>
<!-- Create an X Axis with GrowBy -->
<sci:SciChartSurface.XAxes>
<sci:CategoryDateTimeAxis DrawMajorBands="True"
GrowBy="0.1, 0.1"
AxisAlignment="Bottom" />
</sci:SciChartSurface.XAxes>
<!-- Create a Y Axis with GrowBy.-->
<sci:SciChartSurface.YAxis>
<sci:NumericAxis DrawMajorBands="False"
GrowBy="0.5, 0.5"
CursorTextFormatting="$0.00"
TextFormatting="$0.00" />
</sci:SciChartSurface.YAxis>
<!-- Setting IsEnabled enables or disables a modifier in the Toolbar -->
<sci:SciChartSurface.ChartModifier>
<sci:ModifierGroup>
<sci:DataPointSelectionModifier Name="PointMarkersSelectionModifier"
IsEnabled="True"
SelectionFill="#B1B5B2B2"
SelectionStroke="#009E9C9C" />
</sci:ModifierGroup>
</sci:SciChartSurface.ChartModifier>
</sci:SciChartSurface>
CustomChart.xaml.cs:
private void OnDataSeriesChanged(DependencyPropertyChangedEventArgs e)
{
var inputDataSeries = e.NewValue as XyDataSeries<DateTime, double>;
var dataSeries = new XyDataSeries<DateTime, double>();
dataSeries.Append(inputDataSeries.XValues, inputDataSeries.YValues, dataSeries.YValues.Select((x) => new MyMetadata { IsSelected = false }));
lineRenderableSeries.DataSeries = dataSeries;
}
MyMetaData.cs:
public class MyMetadata : IPointMetadata
{
public event PropertyChangedEventHandler PropertyChanged;
public bool IsSelected { get; set; }
}
With this implementation I am able to individually select datapoints and select multiple datapoints with ctrl/shift but am unable to drag select multiple datapoints.
If, as in the example suite, I change the default XAxis to:
<sci:SciChartSurface.XAxis>
<sci:NumericAxis
DrawMajorBands="True"
GrowBy="0.1, 0.1"
CursorTextFormatting="0" />
</sci:SciChartSurface.XAxis>-->
and of course change all the relevant datatypes in CustomChart.xaml.cs from XyDataSeries<‘DateTime, double’> to XyDataSeries<‘double, double’> everything behaves as expected.
Am I missing something to make the DragSelection work out of the box with the former data type without having to make a custom modifier?
Thank you in advance for your help.
- Leland asked 5 years ago
- You must login to post comments
After some more testing it seems that the selection function works if the X Axis of the chart is a “DateTimeAxis” and not a “CatagoryDateTimeAxis”. Just using the DateTimeAxis is sufficient for my purposes as of now. I am unsure if this functionality is meant to work for CatagoryDateTimeAxis as well or not.
- Leland answered 5 years ago
- You must login to post comments
Please login first to submit.