Series selection by mouse

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
kDanil
Posts: 7
Joined: Tue Sep 23, 2014 2:09 pm

Series selection by mouse

Post by kDanil » Wed Sep 24, 2014 12:54 pm

Hello,

I know that I can use MouseClick event on PointLineSeries to achieve selection or changing the color of series. This event fires only if I click very close to line or above the line.
But what if I want to do it more user friendly meaning that I want to set some radius there click will be processed as click on the closest serie.
Do your chart have some built-in options for this case?

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Series selection by mouse

Post by ArctionPasi » Wed Sep 24, 2014 7:06 pm

There's no direct way to control the tolerance for mouse detecting in the PointLineSeries.

Two workarounds come to my mind:

A) Create auxiliary line series with same data. Set its LineStyle.Color = Transparent, and LineStyle.Width larger than the original. Also set MouseHighlight = None.

When the auxiliary series' MouseClick fires, do the thing you do with the normal series. :geek:


B) Call series.IsMouseOver(xCoord,yCoord) method to check if mouse is over a series. Call that several times, with (xCoord-1, yCoord-1), (xCoord+1, yCoord+1), etc. so you get a little bit tolerance. :freak:
LightningChart Support Team, PT

kDanil
Posts: 7
Joined: Tue Sep 23, 2014 2:09 pm

Re: Series selection by mouse

Post by kDanil » Thu Sep 25, 2014 12:43 pm

Thank you for your ideas.

We have chart with 15000 series with approximately 10 points in each serie.

I'm aware of performance issue in case that we have to add another 15000 series.

Because we use only PointLineSeries I think it is much more simple and faster to catch MouseClick on chart and calculate which serie is the closest with some tolerance.
What do you think?

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Series selection by mouse

Post by ArctionPasi » Thu Sep 25, 2014 1:20 pm

Yes, use chart.MouseClick + approach B.
LightningChart Support Team, PT

SESruss
Posts: 22
Joined: Wed Mar 12, 2014 6:36 pm

Re: Series selection by mouse

Post by SESruss » Tue Dec 16, 2014 7:42 pm

I am trying to more or less do the same thing using a PointLineSeries3D. I'm not sure what I am doing wrong but when I click on the line I always get :

OverLine=false
OverPoint=false
index =-1

Code: Select all

                Point mouseScreen = e.GetPosition(_chart);
                int tolerance = 50;
                bool OverLine = false;
                bool OverPoint = false;
                int index = int.MinValue;

                for (int x = (int)mouseScreen.X  - tolerance; x < (int)mouseScreen.X + tolerance; x++)
                {
                    for (int y = (int)mouseScreen.Y - tolerance; y < (int)mouseScreen.Y + tolerance; y++)
                    {
                        _chart.View3D.PointLineSeries3D[0].IsMouseOver(x, y, out index, out OverLine, out OverPoint);
                    }
                }
Any thoughts on what I am missing?

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Series selection by mouse

Post by ArctionPasi » Tue Dec 16, 2014 8:59 pm

Set pointLineSeries3D.MouseInteraction = true, otherwise mouse hit testing can't be done.

If you don't want the series to highlight when mouse is over, set pointLineSeries3D.MouseHightlight = None.
LightningChart Support Team, PT

SESruss
Posts: 22
Joined: Wed Mar 12, 2014 6:36 pm

Re: Series selection by mouse

Post by SESruss » Wed Dec 17, 2014 12:24 pm

Still getting the same result making the change you mentioned. Something really weird is going on.

I was using the LightningChart.MouseUp event handler with the code above. When I tried to use the PointLineSeries3D.MouseClick event it never gets raised when I click on the series. For a sanity check I subscribed to the same event handler using the 2D PointLineSeries.MouseClick event and that worked fine.

This is what my series code looks like:

Code: Select all

              PointLineSeries3D pls = new PointLineSeries3D(_chart.View3D, Axis3DBinding.Primary, Axis3DBinding.Primary, Axis3DBinding.Primary);
                    pls.PointStyle.Shape = (PointShape3D)(item.PointStyle.Shape);
                    pls.PointStyle.Size.SetValues(item.PointStyle.Size.Width,item.PointStyle.Size.Height,item.PointStyle.Size.Depth );
                    pls.Material.DiffuseColor = item.Material.DiffuseColor;
                    pls.Material.SpecularColor = item.Material.SpecularColor;
                    pls.Material.SpecularPower = item.Material.SpecularPower;
                    pls.LineVisible = item.LineVisible;
                    pls.PointsVisible = item.PointsVisible;
                    pls.PointStyle.Size.Width = item.PointStyle.Size.Width;
                    pls.LineStyle.AntiAliasing = (LineAntialias)(item.LineStyle.AntiAliasing);
                    pls.LineStyle.Color = item.LineStyle.Color;
                    pls.LineStyle.Width = item.LineStyle.Width;
                    pls.LineStyle.Pattern = (LinePattern)(item.LineStyle.Pattern);
                    pls.MouseInteraction = true;
                    pls.MouseClick += new MouseEventHandler(marker_MouseClick);
_chart.View3D.PointLineSeries3D.Add(pls);
I didn't see anything that looked suspicious in that.

I am adding a point to the chart by clicking on the series which works fine. What I am trying to do is narrow the tolerance down on how far the user can click and add a point (right now the user can click a point far away from the series and it will find the closest point in the series and set a marker there). I'm sure your ideas A & B are good solutions but I have no idea what I'm doing wrong. It seems that everything works fine on the 2d PointLine series but that the 3d is cursed.

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Series selection by mouse

Post by ArctionPasi » Wed Dec 17, 2014 12:40 pm

PointLineSeries3D uses a "bounding box" testing for mouse. Every line segment is a 3D box for the mouse routines. That makes the big tolerance, and is cursed solution when there's a demand for precision.

We will develop a more accurate testing routine soon. In 6.3.3-6.3.5 version during next weeks.
LightningChart Support Team, PT

Post Reply