Pre loader

Tag: DataPointSelectionModifier

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0 votes
886 views

Hello,

I am trying to select a single X value on my chart and get the data values from the X value that I selected. I am still pretty new to SciChart but I was looking around and saw that there is a DataPointSelectionModifier. My goal is to create a VerticalLineAnnotation for the user to use and once that annotation is created, to pull the data values from that X value. Could this be done? Any advice or help is greatly appreciated!

Thanks,

Preston

1 vote
5k views

Hello.

I have a XYRenderableDataSeries with point markers with a fill color.

I also have a DataPointSelectionModifier which allows me to select clusters up to 5 from the series.

I want that when I select a cluster from the series, the points selected from the series should be colored for that specific cluster. i.e. all the cluster colors should be different. Also, when I select another cluster, the colors in the points selected from 1st cluster or other clusters should be preserved.

Here’s the XAML code :

<s:XyScatterRenderableSeries DataSeries="{Binding ScatterData}">
                    <s:XyScatterRenderableSeries.PointMarker>
                        <s:EllipsePointMarker  Width="3" Height="3" Fill="#AAFFFFFF" Stroke="SteelBlue" StrokeThickness="2"/>
                    </s:XyScatterRenderableSeries.PointMarker>
                    <s:XyScatterRenderableSeries.SelectedPointMarker>
                        <s:EllipsePointMarker Fill="{Binding ClusterColor, Mode=TwoWay}"
                                              Width="12"
                                              Height="12" />
                    </s:XyScatterRenderableSeries.SelectedPointMarker>
                </s:XyScatterRenderableSeries>

<s:SciChartSurface.ChartModifier>
                <s:ModifierGroup>
                    <s:DataPointSelectionModifier Name="PointMarkersSelectionModifier"
                                                  IsEnabled="{Binding IsManualClustering}"
                                                  SelectionChanged="PointMarkersSelectionModifier_SelectionChanged"
                                                  SelectionFill="#B1B5B2B2" 
                                                  SelectionStroke="#009E9C9C" />
                    <s:MouseWheelZoomModifier IsEnabled="True" />
                    <s:RubberBandXyZoomModifier IsEnabled="False" />
                </s:ModifierGroup>
            </s:SciChartSurface.ChartModifier>

I tried to find examples but could not find any. Please let me know if we can reach a solution to this in some way.

Thank you.

  • Ammar Khan asked 7 months ago
  • last active 7 months ago
1 vote
4k views

https://www.scichart.com/questions/wpf/i-want-to-bind-selectedpointmarkers-of-datapointselectionmodifier

Hello.
Referring to the link above, we have modified the ViewModel side to maintain the selection state of chart points.

It works fine for a single chart, but when I have multiple charts, the selection points are interlocked between charts. I would like them to be independent of each other.

I wasn’t sure if there was a problem with my code or with the DataPointSelectionModifier, so does anyone know?

I have attached a code sample and a GIF of a working image.

※To reproduce this, click the three points in order from the top while holding down the control key on “Chart1” to make the three points selected. The color of the points will change from blue to red.
Next, while holding down the control key in “Chart2,” click on the bottom point. Then, in “Chart2,” four points are selected, even though only one point is pressed in total.

That is all. Best regards.

0 votes
6k views

Hi,

I am developing an MVVM WPF application and need to access the SelectedPointMarkers property of DataPointSelectionModifier from the ViewModel.

From looking at the DataPointSelectionModifier documentation (https://www.scichart.com/documentation/win/current/webframe.html#DataPoint%20Selection.html) I can see how you can get the X and Y coordinate values of a selected point in a view, by binding the PointMarkersSelectionModifier to a listbox.

However this doesn’t really help me, I need to get the coordinates of the SelectedPointMarker into a property inside the ViewModel that can be accessed, rather than just binding to a listbox in the view itself.

I’ve also looked at this similar post: (https://www.scichart.com/questions/wpf/i-want-to-bind-selectedpointmarkers-of-datapointselectionmodifier), but I had no luck getting Kenishis solution to work in my case.

How can i do this?

Thanks.

0 votes
7k views

Referring to the stacked column side by side example in the android examples collection, if someone clicks on a column/series in that chart, how could i identify which the of columns has been selected (usa, china, india, etc).

0 votes
8k views

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 4 years ago
  • last active 4 years ago
0 votes
10k views

Hi, i’m developing an app in WPF and i found that it crashes when i’m dereferencing the user control where my chart lives in and have 1 or more points selected by code in one chart when the other one is not visible.

i would be very apreciated if someone could tell me a hint of where i have to look for the solution or what do this methods do or touch.

more data about the chart:

  • I have 2 fastlinerenderable series each with 2 Yaxis for itselves and 2 shared XAxis.
  • I also have a modified listbox which is have it’s sincronization synced to the chart.
  • have a modifiergroup to pan,zoom and select.

this is my Selectionmodifier:

<scicharts:DataPointSelectionModifier
                        Name="ChartSelection"
                        SelectionFill="#B1B5B2B2" 
                        XAxisId="{Binding XAxisType, NotifyOnTargetUpdated=True}"
                        TargetUpdated="ChartSelection_TargetUpdated"
                        SelectionStroke="#009E9C9C"
                        IsEnabled="{Binding SelectionMode}" >

I think that this is the axis that breaks my program but it needs it to not crash when i select.

this is my stacktrace:

An unhandled exception of type ‘System.NullReferenceException’ occurred in SciChart.Charting.dll

en SciChart.Charting.ChartModifiers.DataPointSelectionModifier.DeselectAllPointMarkers()
en SciChart.Charting.ChartModifiers.DataPointSelectionModifier.OnXAxisIdDependencyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)

I tried to make a program that could replicate the error but i couldn’t.

thanks in advance.

0 votes
4k views

Hello,

I had previously commented on an existing issue, but wanted to bump here since it’s impeding development.

When adding a DataPointSelectionModifier to a chart surface containing a FastUniformHeatmapRenderableSeries with a UniformHeatmapDataSeries, an exception is thrown on a mouse drag.

The modifier is added simply with:

<s:SciChartSurface.ChartModifier>
    <s:ModifierGroup>
        <s:DataPointSelectionModifier/>
    </s:ModifierGroup>
</s:SciChartSurface.ChartModifier>

After adding this modifier and using my mouse to select a part of the heatmap, I get the following System.InvalidOperationException (stack trace below):

"Metadata for his type cannot be returned as an one-dimentional array. Please use the IPointMetadata[,] Metadata property"

I’m assuming this is happening because DataPointSelectionModifier was by default not meant for data series with 2D arrays, but I’m not sure how to follow the exception message “Please use the IPointMetadata[,] Metadata property”.

Ultimately I am trying to run a calculation on the selected subset of the heatmap. Any help would be appreciated and thanks in advance!

Stack trace:

  at SciChart.Charting.Model.DataSeries.Heatmap2DArrayDataSeries.BaseHeatmapDataSeries`3.SciChart.Charting.Model.DataSeries.IDataSeries.get_Metadata()
   at SciChart.Charting.ChartModifiers.DataPointSelectionModifier.UpdateState()
   at SciChart.Charting.ChartModifiers.DataPointSelectionModifier.KUB()
   at A.MEB.D[D](D D, Boolean I, Func`1 J)
   at SciChart.Charting.ChartModifiers.DataPointSelectionModifier.get_SelectedPointMarkers()
   at SciChart.Charting.ChartModifiers.DataPointSelectionModifier.DeselectAllPointMarkers()
   at SciChart.Charting.ChartModifiers.DataPointSelectionModifier.SelectManyPoints(Point startPoint, Point endPoint, SelectionMode selectionMode)
   at SciChart.Charting.ChartModifiers.DataPointSelectionModifier.OnModifierMouseUp(ModifierMouseArgs e)
   at SciChart.Charting.ChartModifiers.ModifierGroup.FTB(Action`2 D, ModifierEventArgsBase I)
   at SciChart.Core.Extensions.EnumerableExtensions.ForEachDo[T](IEnumerable`1 enumerable, Action`1 operation)
   at SciChart.Core.Utility.Mouse.MouseManager.GB(IPublishMouseEvents D, IReceiveMouseEvents I, MouseEventArgs J, MouseButtons M, Action`3 O)
   at SciChart.Core.Utility.Mouse.MouseManager.AEB.S(Object D, MouseButtonEventArgs I)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at Main.main(String[] _arg1) in ...\App.fs:line 13
  • jsacks asked 5 years ago
  • last active 5 years ago
2 votes
11k views

Hi guys,

I’ve been trying to select data points in my heat map for the whole without success. I’ve read, re-read and re-re-read the documentation, but I can’t figure out what I’m doing wrong.

Here’s the XAML.

...

<s:SciChartSurface.RenderableSeries>
    <s:FastUniformHeatmapRenderableSeriesForMvvm
        x:Name="heatmapSeries" 
        Opacity="0.9" 
        DataSeries="{Binding UniformHeatmapDataSeries}"
        s:DataPointSelectionModifier.IncludeSeries="True" >

        <s:FastUniformHeatmapRenderableSeriesForMvvm.ColorMap>
            <s:HeatmapColorPalette Maximum="60" Minimum="6">
                <s:HeatmapColorPalette.GradientStops>
                    <GradientStop Offset="0" Color="Transparent"/>
                    <GradientStop Offset="0.1" Color="DarkBlue"/>
                    <GradientStop Offset="0.2" Color="CornflowerBlue"/>
                    <GradientStop Offset="0.4" Color="DarkGreen"/>
                    <GradientStop Offset="0.6" Color="Chartreuse"/>
                    <GradientStop Offset="0.8" Color="Yellow"/>
                    <GradientStop Offset="1" Color="Red"/>
                </s:HeatmapColorPalette.GradientStops>
            </s:HeatmapColorPalette>
        </s:FastUniformHeatmapRenderableSeriesForMvvm.ColorMap>

        <s:FastUniformHeatmapRenderableSeriesForMvvm.PointMarker>
            <s:XPointMarker Fill="Pink" Width="5" Height="5"/>
        </s:FastUniformHeatmapRenderableSeriesForMvvm.PointMarker>

        <s:FastUniformHeatmapRenderableSeriesForMvvm.SelectedPointMarker>
            <s:TrianglePointMarker Fill="White" Width="12" Height="12"/>
        </s:FastUniformHeatmapRenderableSeriesForMvvm.SelectedPointMarker>

    </s:FastUniformHeatmapRenderableSeriesForMvvm>

    ...

</s:SciChartSurface.RenderableSeries>
...

Here’s the MVVM code.

...
class SelectedPointMetadata : IPointMetadata
{
    public bool IsSelected { get; set; }

    public event PropertyChangedEventHandler PropertyChanged;
}
...

double[,] heatMap = new double[heatMapHeight + glowRadius * 2, heatMapWidth + glowRadius * 2];
double[,] glowMatrix = this.getGlowEffectMatrix(glowRadius);

SelectedPointMetadata[,] selectablePoints = new SelectedPointMetadata[heatMapHeight + glowRadius * 2, heatMapWidth + glowRadius * 2];

for (int i = 0; i < spectrogram.SpectrogramAtoms.Count; i++) {
    var atom = spectrogram.SpectrogramAtoms[i];
    int x = Math.Min((int)(atom.Frequency.Hertz / frequencyStep) + glowRadius, heatMapHeight - 1);
    int y = Math.Min((int)(atom.Time.Seconds / xStep) + glowRadius, heatMapWidth - 1);
    this.applyEffectMatrix(x, y, atom.SNR, ref heatMap, ref glowMatrix, glowRadius);

}

var xBound = heatMap.GetLength(0);
var yBound = heatMap.GetLength(1);

Random rnd = new Random();

for (var i = 0; i < xBound; i++)
{
    for (var j = 0; j < yBound; j++)
    {
        var x = rnd.Next(1, 10);

        selectablePoints[i, j] = new SelectedPointMetadata() { IsSelected = false };

        if (x == 5)
        {
            selectablePoints[i, j].IsSelected = true;
        }

    }
}

this.UniformHeatmapDataSeries = new UniformHeatmapDataSeries<double, double, double>(
    heatMap,
    (-xStep * glowRadius),
    xStep,
    (-frequencyStep * glowRadius),
    frequencyStep,
    selectablePoints
    );

...

What am I missing?

0 votes
10k views

Hi All,

I’ve got a class that derives from the DataPointSelectionModifier in order to access the OnValueChanged() functionality and everything is fine (Thank you Andrew).

However – When I have 2 series on the chart (scatter series) and 2 points are quite close together, a single selection of a point can result in the selection of two points. On playing around with it a bit I notice that a point can be selected when the mouse pointer is slightly outside the limits of the pointmarker (in this case a 10×10 EllipsePointMarker) so if you get 2 points only a few pixels apart it is possible to place the mouse between the two and get both points selected. You can also see the behaviour in the SciChart examples 2DCharts|Toltips and Hit Test| Pointmarkers Selection example if you play with the points in the top left corner.

The Question: Is there a way to reduce the area around the mouse pointer that a hit test is detected in? (e.g. 20 pixel radius down to say 5 pixel radius)

I’ve had a look at overriding GeometryHitTestResult HitTestCore but I don’t really know if this is even the right way to go. If somebody can confirm this is where I should be looking then I’ll find some time to persevere with it.

Thanks in advance
/Stuart

2 votes
6k views

Hi, I am currently working with the DataPointSelectionModifier with StackedColumnRenderableSeriesViewModel series. I currently am able to get the data point with the correct values whenever I click on a column but it seems that I am not able to change the selection fill of the column.

All I can seem able to do is changing the color of the whole series, but that is not what I am looking for.

Best Regards.

2 votes
6k views

Hi ,

I am currently using the DataPointSelectionModifier for StackedColumnRenderableSeriesViewModel and I am having an issue trying to have a single selection that is togglable.

I am currently not AllowingMultiSelection so the default value is SelectionMode.Replace, which, in case you click on the same column, it will deselect that column and then select it again. Is there a way around this?

Best Regards.

1 vote
0 answers
6k views

Hi All,
I’m using the RubberBandXyZoomModifier and DataPointSelectionModifier together from the left mouse button; enabling and disabling them based on the left CTRL key being pressed (CTRL key down = select).

I’m seeing what I assume to be a focus issue on first mousing over off the chart area in that the chart area doesn’t attract focus, and thus recognise the ctrl key press, until there’s been a mouse button click. I’ve created an app to demonstrate and attached the XAML and code behind for it.

To see the behaviour, run the code and press the “does nothing” button to set focus to it. Mouse over the chart and press the CTRL key – the key press is not recognised. Click the left mouse button and the key press is now recognised. So far so good.
Now if you repeat the process but click and drag – the logic is caught between the two modifiers being enabled/disabled and the zoom selection is shown even though the CTRL key is down. There are other issues e.g. CTRL down and drag outside the chart can leave the selection modifier drag area marked on the chart while the zoom mode is in operation

I was thinking of something like setting focus or forcing a mouse click in response to the mouse over event but so far my attempts have failed – probably from doing the wrong thing in the wrong place – so, as usual, any and all suggestions are most welcome!

/Stuart

0 votes
9k views

I’m playing with the DatPointSelectionModifier which seems mostly what i need but I have two problems as follows:

1/ I have started a selection operation by dragging over an area containing some points and I decide that I don’t want that area after all and want to cancel the operation (much like file explorer file dragging – hitting escape cancels the operation) – How do I do that?

2/ I have a set of selected points and drag to select another set which overlaps the first set. I would like the any points in the overlap to invert from selected to unselected and vice versa. How would I know which points are encompassed by the drag operation so i can work out the overlap?

Thanks for any suggestions
/Stuart

0 votes
7k views

Here’s the situation:
Our app has a viewmodel with an XyDataSeries Property bound to the plot. We’ve overridden DataPointSelectionModifer to allow us to trigger calculations when the selected points are changed. This overridden modifier is not instantiated by nor is it directly aware of the viewmodel; it is referenced only in the view xaml.

When changing between datasets we replace the contents of the XyDataSeries Property. Afterwards we are experiencing NullReferenceExceptions in DataPointSelectionModifier.SelectManyPoints(). This occurs whether we replace the contents of the data series or we set a completely new XyDataSeries object into the property.

It appears that the DataPointSelectionModifier.SelectedPointMarkers collection is no longer properly synced to the plot’s XyDataSeries. The size of the the collections are different and with the original DataSeries being garbage-collected the DataPointInfo.DataPointMetadata references are null. So we attempt to dial in a new selection and the deselection of this orphaned null metadata raises exceptions.

Is there some secret-sauce to keeping these collections in line?
Any and all suggestions are greatly appreciated.

Showing 15 results

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies