Markstip to show points

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
pw
Newbie
Newbie
Posts: 57
Joined: Fri Nov 15, 2002 12:00 am

Markstip to show points

Post by pw » Wed Aug 05, 2009 7:07 am

Hi,

I'm just wondering if it's possible for the markstip to also show a point (for example, a cross) on the series where the mouse is over the series' point.

I've multiple line and volume series, so it's not possible for me to assign to a particular series only.

Thanks.

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Markstip to show points

Post by Yeray » Wed Aug 05, 2009 2:47 pm

Hi pw,

Here you have an example of how you could do it. I'm afraid that you should calculate the points manually:

Code: Select all

        public Form1()
        {
            InitializeComponent();

            InitializeChart();
        }

        int seriesClicked = -1;
        int valueClicked = -1;

        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;

            for (int i = 0; i < 3; i++)
            {
                new Steema.TeeChart.Styles.Line(tChart1.Chart);
                tChart1[tChart1.SeriesCount - 1].FillSampleValues(50);
                new Steema.TeeChart.Styles.Volume(tChart1.Chart);
                tChart1[tChart1.SeriesCount - 1].FillSampleValues(50);
            }

            Steema.TeeChart.Tools.MarksTip marktip1 = new Steema.TeeChart.Tools.MarksTip(tChart1.Chart);

            tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
            tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
        }

        void tChart1_MouseMove(object sender, MouseEventArgs e)
        {
            seriesClicked = -1;
            valueClicked = -1;

            for (int i = 0; i < tChart1.Series.Count; i++)
            {
                valueClicked = tChart1[i].Clicked(e.X, e.Y);
                if (valueClicked > -1)
                {
                    seriesClicked = i;
                    break;
                }
            }
            tChart1.Refresh();
        }

        void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            if ((valueClicked > -1) && (seriesClicked > -1))
            {
                g.Brush.Visible = true;
                g.Brush.Solid = true;
                g.Brush.Color = tChart1.Series[seriesClicked].Color;
                g.Ellipse(new Rectangle(tChart1[seriesClicked].CalcXPos(valueClicked) - 4, tChart1[seriesClicked].CalcYPos(valueClicked) - 4, 8, 8));
            }
        }
    }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

pw
Newbie
Newbie
Posts: 57
Joined: Fri Nov 15, 2002 12:00 am

Re: Markstip to show points

Post by pw » Wed Aug 05, 2009 10:19 pm

Many thanks, Yeray. This is fantastic... :D

Post Reply