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?
Series selection by mouse
Moderator: Queue Moderators
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: Series selection by mouse
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.
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.
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.
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.
LightningChart Support Team, PT
Re: Series selection by mouse
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?
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?
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: Series selection by mouse
Yes, use chart.MouseClick + approach B.
LightningChart Support Team, PT
Re: Series selection by mouse
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
Any thoughts on what I am missing?
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);
}
}
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: Series selection by mouse
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.
If you don't want the series to highlight when mouse is over, set pointLineSeries3D.MouseHightlight = None.
LightningChart Support Team, PT
Re: Series selection by mouse
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:
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.
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 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.
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: Series selection by mouse
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.
We will develop a more accurate testing routine soon. In 6.3.3-6.3.5 version during next weeks.
LightningChart Support Team, PT