Page 1 of 1

BarSeries.Clicked() is not working correctly when stacking in 3D (.NET Framework 4.8 WinForms)

Posted: Fri Oct 16, 2020 6:57 am
by 15687415
Hello.
I have .NET Framework 4.8 WinForms application and a chart with 4 stacking 3D bars.
I use the following code to show a tooltip then cursor is above any bar point:

Code: Select all

private void tChart1_MouseMove(object sender, MouseEventArgs e)
        {
            Int32 clickedPointIndex = -1, clickedSeriesIndex = -1;
            var chart = sender as TChart;

            //search for cursor hitting point of any bar
            for (int i = 0; i < chart.Series.Count; i++)
            {
                if ((chart.Series[i] is CustomBar) && ((chart.Series[i] as CustomBar).Clicked(e.X, e.Y) != -1))
                {
                    clickedSeriesIndex = i;
                    clickedPointIndex = (chart.Series[i] as CustomBar).Clicked(e.X, e.Y);
                    break;
                }
            }

            if (clickedPointIndex != -1)
            {
                //when cursor was moved from one point to another on the same bar - tooltip must be changed
                if ((clickedSeriesIndex != prevClickedSeriesIndex) || (clickedPointIndex != prevClickedPointIndex))
                {
                    toolTip1.Active = false;
                    toolTip1.SetToolTip(sender as TChart, $"{chart.Series[clickedSeriesIndex].Title} - {chart.Series[clickedSeriesIndex][clickedPointIndex].Y}");
                    toolTip1.Active = true;
                    prevClickedSeriesIndex = clickedSeriesIndex;
                    prevClickedPointIndex = clickedPointIndex;
                }
                else
                if (!toolTip1.Active)
                {
                    toolTip1.SetToolTip(chart, $"{chart.Series[clickedSeriesIndex].Title} - {chart.Series[clickedSeriesIndex][clickedPointIndex].Y}");
                    toolTip1.Active = true;
                }
            }
            else
                toolTip1.Active = false;
        }
As I can see BarSeries.Clicked() checkes whether cursor is above front, right or top face of 3D bar. But it is not respecting situation when stacking bar point overlaps top face. It still return that cursor is above first bar point decpite of that fact that user actually don't see it's top face. User is seeing second bar front and right face on that position.
Image
My test project
Fix that please ASAP, this bug completely stops my work for now.

Re: BarSeries.Clicked() is not working correctly when stacking in 3D (.NET Framework 4.8 WinForms)

Posted: Fri Oct 16, 2020 7:25 am
by 15687415
BTW. Side stacking of 3D bars has the same problems (with right face):
Image

Re: BarSeries.Clicked() is not working correctly when stacking in 3D (.NET Framework 4.8 WinForms)

Posted: Fri Oct 16, 2020 11:21 am
by Christopher
Hello,

the following code works as expected here:

Code: Select all

        private void InitializeChart(TChart chart)
        {
            void Chart_MouseMove(object sender, MouseEventArgs e)
            {
                for (var i = 0; i < chart.Series.Count; i++)
                {
                    var index = chart.Series[i].Clicked(e.Location);
                    if(index > -1)
                    {
                        chart.Header.Text = $"bar{i}, value:{index}";
                        break;
                    }
                }
            }

            chart.Aspect.View3D = true;
            chart.MouseMove += Chart_MouseMove;


            for (var i = 0; i < 4; i++)
            {
                chart.Series.Add(typeof(Bar)).FillSampleValues();
            }

            ((Bar)chart.Series[0]).MultiBar = MultiBars.Stacked;
        }
2020-10-16_13-19-25.gif
2020-10-16_13-19-25.gif (60.99 KiB) Viewed 13215 times
Could you please modify the above code so I can reproduce your problem here?

Re: BarSeries.Clicked() is not working correctly when stacking in 3D (.NET Framework 4.8 WinForms)

Posted: Fri Oct 16, 2020 11:32 am
by 15685014
Your sample don't need any modification - at also have the same bug:
Image
It still showing bar2, value:5 when cursor is already above bar3 (cyan). I need to move cursor higher to change it to bar3, value:5.
That is because component thinks that cursor is above top face of bar2 (orange) and ignores the fact that bar3 (cyan) hides that top face.

Re: BarSeries.Clicked() is not working correctly when stacking in 3D (.NET Framework 4.8 WinForms)

Posted: Fri Oct 16, 2020 11:45 am
by Christopher
bairog wrote:
Fri Oct 16, 2020 11:32 am
It still showing bar2, value:5 when cursor is already above bar3 (cyan). I need to move cursor higher to change it to bar3, value:5.
That is because component thinks that cursor is above top face of bar2 (orange) and ignores the fact that bar3 (cyan) hides that top face.
Okay, thank you, I can see what you mean now: I have added this issue to our issue tracker with id=2379, although I think we may have covered this issue before and concluded that this won't be able to be fixed while emulating 3D graphics using a 2D Canvas (such as GDI+). I'll check and get back to you.

Re: BarSeries.Clicked() is not working correctly when stacking in 3D (.NET Framework 4.8 WinForms)

Posted: Tue Oct 20, 2020 9:50 am
by Christopher
Hello,
Christopher wrote:
Fri Oct 16, 2020 11:45 am
I'll check and get back to you.
One of my colleages has a suggestion which seems to resolve the issue; if you reverse the order of the series when searching for the click, the problem doesn't seem to occur, e.g.

Code: Select all

        private void InitializeChart(TChart chart)
        {
            void Chart_MouseMove(object sender, MouseEventArgs e)
            {
                for (var i = chart.Series.Count - 1; i >= 0; i--) //<-- reverse order here
                {
                    var index = chart.Series[i].Clicked(e.Location);
                    if(index > -1)
                    {
                        chart.Header.Text = $"bar{i}, value:{index}";
                        break;
                    }
                }
            }

            chart.Aspect.View3D = true;
            chart.MouseMove += Chart_MouseMove;


            for (var i = 0; i < 4; i++)
            {
                chart.Series.Add(typeof(Bar)).FillSampleValues();
            }

            ((Bar)chart.Series[0]).MultiBar = MultiBars.Stacked;
        }

Re: BarSeries.Clicked() is not working correctly when stacking in 3D (.NET Framework 4.8 WinForms)

Posted: Tue Oct 20, 2020 3:22 pm
by 15685014
Christopher wrote:
Tue Oct 20, 2020 9:50 am
One of my colleages has a suggestion which seems to resolve the issue; if you reverse the order of the series when searching for the click, the problem doesn't seem to occur, e.g.
Looks more like a "hack", but it's working :)
Thank you.