Drag series between axis

TeeChart for ActiveX, COM and ASP
Post Reply
JuanLu
Newbie
Newbie
Posts: 5
Joined: Fri Nov 23, 2007 12:00 am

Drag series between axis

Post by JuanLu » Wed Oct 21, 2009 2:46 pm

How could I drag&drop a serie from a custom axis to another?

Regards,

Juan Luis

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

Re: Drag series between axis

Post by Yeray » Thu Oct 22, 2009 11:25 am

Hi Jaun Luis,

Here is an example we made for another customer some time ago. Note that this is an example for TeeCahrt for NET but I think it should work also for the ActiveX version.
If you find any problem translating it, please don't hesitate to let us know.

Code: Select all

        private void InitializeChart()
        {
            chartController1.Chart = tChart1;
            tChart1.Aspect.View3D = false;
            tChart1.Panel.MarginLeft = 15;
            tChart1.Zoom.Allow = false;

            Steema.TeeChart.Axis axis1 = new Steema.TeeChart.Axis();
            Steema.TeeChart.Axis axis2 = new Steema.TeeChart.Axis();

            tChart1.Axes.Custom.Add(axis1);
            tChart1.Axes.Custom.Add(axis2);

            axis1.StartPosition = 0;
            axis1.EndPosition = 49;
            axis2.StartPosition = 50;
            axis2.EndPosition = 100;

            for (int i = 0; i < 3; i++)
            {
                tChart1.Series.Add(new Steema.TeeChart.Styles.Line());
                tChart1[i].FillSampleValues();
                tChart1[i].CustomVertAxis = (i > 0) ? axis1 : axis2;
            }

            tChart1.MouseDown += new MouseEventHandler(tChart1_MouseDown);
            tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
            tChart1.MouseUp += new MouseEventHandler(tChart1_MouseUp);
        }

        private int seriesIndex = -1;

        void tChart1_MouseUp(object sender, MouseEventArgs e)
        {
            seriesIndex = -1;
        }

        void tChart1_MouseMove(object sender, MouseEventArgs e)
        {
            if (seriesIndex != -1)
            {
                for (int i = 0; i < tChart1.Axes.Custom.Count; i++)
                {
                    if ((tChart1.Axes.Custom[i].IStartPos <= e.Y) && (tChart1.Axes.Custom[i].IEndPos >= e.Y))
                    {
                        tChart1[seriesIndex].CustomVertAxis = tChart1.Axes.Custom[i];
                        break;
                    }
                }
            }
        }

        void tChart1_MouseDown(object sender, MouseEventArgs e)
        {
            for (int i = 0; i < tChart1.Series.Count; i++)
            {
                if (tChart1[i].Clicked(e.X, e.Y) != -1)
                {
                    seriesIndex = i;
                    break;
                }
            }
        }
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

Post Reply