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

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
bairog
Newbie
Newbie
Posts: 7
Joined: Thu Nov 21, 2019 12:00 am

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

Post by bairog » Fri Oct 16, 2020 6:57 am

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.

bairog
Newbie
Newbie
Posts: 7
Joined: Thu Nov 21, 2019 12:00 am

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

Post by bairog » Fri Oct 16, 2020 7:25 am

BTW. Side stacking of 3D bars has the same problems (with right face):
Image

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

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

Post by Christopher » Fri Oct 16, 2020 11:21 am

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 12878 times
Could you please modify the above code so I can reproduce your problem here?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

bairog
Advanced
Posts: 128
Joined: Fri Dec 07, 2018 12:00 am

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

Post by bairog » Fri Oct 16, 2020 11:32 am

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.

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

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

Post by Christopher » Fri Oct 16, 2020 11:45 am

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.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

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

Post by Christopher » Tue Oct 20, 2020 9:50 am

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;
        }
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

bairog
Advanced
Posts: 128
Joined: Fri Dec 07, 2018 12:00 am

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

Post by bairog » Tue Oct 20, 2020 3:22 pm

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.

Post Reply