Line movement

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Amol
Advanced
Posts: 176
Joined: Mon May 29, 2006 12:00 am

Re: Line movement

Post by Amol » Thu Jun 23, 2011 7:07 am

Hi Yeray,

The code you provided is working fine except following:

By seeing it we can observe that the slope of the line it slightly changing as soon as we start moving it, from the position it was initially drawn. Means the slope of line at very first time is different from when we first start movement :? .

Here we need same slope (45°) of line during initial state and while movement too.

Please help me to finalize this task.

Thanks in Advance.

Best regards
Ashish Pandey

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

Re: Line movement

Post by Yeray » Thu Jun 23, 2011 11:57 am

Hello Amol,
Amol wrote:The code you provided is working fine except following:

By seeing it we can observe that the slope of the line it slightly changing as soon as we start moving it, from the position it was initially drawn. Means the slope of line at very first time is different from when we first start movement :? .

Here we need same slope (45°) of line during initial state and while movement too.

Please help me to finalize this task.
That's what I meant when I said:
Yeray wrote:The only thing I'm not sure why it isn't working as I'd expect is how the line looks the first time it is drawn. Maybe you can find what I'm missing.
But it seems to work as I'd expect when you drag it, isn't it?
I'm not sure about the reason why the values aren't correct the first time the chart is drawn but Narcís made me note that moving the slope initialization to the form Shown event, it seems to work as expected:

Code: Select all

        private void CreateChart()
        {
            //...
            //List<double> XDATA = new List<double>();
            //List<double> YDATA = new List<double>();
            //CreateDataForHalfSlopeLine(80, 30, ref XDATA, ref YDATA);
            //m_lnHalfSlope.Add(XDATA.ToArray(), YDATA.ToArray());
            //...
            this.Shown += new EventHandler(Form1_Shown);
        }

        void Form1_Shown(object sender, EventArgs e)
        {
            List<double> XDATA = new List<double>();
            List<double> YDATA = new List<double>();
            CreateDataForHalfSlopeLine(80, 30, ref XDATA, ref YDATA);
            m_lnHalfSlope.Add(XDATA.ToArray(), YDATA.ToArray());
        }
Another tip you may be interested in. Note that there is a ClickedPointer function for the Line series as well. So, if you want the slope to be dragged only through the pointer, you can use it:

Code: Select all

        private void tChart1_MouseDown(object sender, MouseEventArgs e)
        {
            //...
            //indexOfHalfSlopeLine = m_lnHalfSlope.Clicked(e.X, e.Y);
            indexOfHalfSlopeLine = m_lnHalfSlope.ClickedPointer(e.X, e.Y);
            //...
        }
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

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

Re: Line movement

Post by Yeray » Thu Jun 23, 2011 1:03 pm

Hello Amol,
Yeray wrote:I'm not sure about the reason why the values aren't correct the first time the chart is drawn but Narcís made me note that moving the slope initialization to the form Shown event, it seems to work as expected:
I've done some tests more and I've seen that the order of the series seems to be relevant for the slope to be correctly drawn. So, instead of creating the slope series at the form Shown event, you can simply add the slope series before adding the other two line series:

Code: Select all

        private void CreateChart()
        {
            //...
            tChart1.Series.Add(m_lnHalfSlope);
            tChart1.Series.Add(Line1);
            tChart1.Series.Add(Line2);
        }
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

Amol
Advanced
Posts: 176
Joined: Mon May 29, 2006 12:00 am

Re: Line movement

Post by Amol » Thu Jun 23, 2011 1:27 pm

Hi Yeray,

Thank you very much for your kind and precious support. It was very great experience with Steema’s support. Also send my regards to Narcís.

Yes, the solution you provided this time is working as desired. You know my immediate manger is really very happy with this. :D
Yeray wrote:
Another tip you may be interested in. Note that there is a “ClickedPointer” function for the Line series as well. So, if you want the slope to be dragged only through the pointer.
Yes I know about this function. It returns the index of clicked pointer. But in our project we are not showing pointer and user have to click anywhere on the line to move it. In this case only “Clicked” function helped me. However thanks for the tip.

I am sure you will be happy to provide me your kind support in future too.

Thanks and regards
Ashish Pandey

Amol
Advanced
Posts: 176
Joined: Mon May 29, 2006 12:00 am

Re: Line movement

Post by Amol » Fri Jun 24, 2011 11:08 am

Hi Yeray,

Sorry I did not see your last post before posting last post of mine. Thanks for the suggestion you provided in your last post.
Yeray wrote:
I've done some tests more and I've seen that the order of the series seems to be relevant for the slope to be correctly drawn. So, instead of creating the slope series at the form Shown event, you can simply add the slope series before adding the other two line series
I have quickly used this code, by seeing it we can observe that the slope of the line it little changing, this time too, as soon as we start moving it, from the position it was initially drawn.

But we found what we are looking for, with the tip (Form Shown event) you provide in your second last post. Anyway thank you very much for your last post.

Expecting your kind support in future too!


Thanks and regards
Ashish Pandey

Amol
Advanced
Posts: 176
Joined: Mon May 29, 2006 12:00 am

Re: Line movement

Post by Amol » Tue Jun 28, 2011 6:03 am

Hi Yeray,

Thanks for your precious support so far.

I am afraid to say I have got one more problem. Our project has a dockable interface so the charts are frequently resized. And I saw that when I resize the chart, and try to move the line it affect slope of the line. This happens each and every time when chart get resized.

To overcome this I add bellow code on Chart’s Resize event. But it doesn't seem to be work.

Code: Select all

void tChart1_Resize(object sender, EventArgs e)
        {
            if (m_bIsFormShown) //Do bellow only when form is shown.
            {
                tChart1.Draw();
                CentralPointPix.X = tChart1.Axes.Bottom.CalcPosValue(m_lnHalfSlope[1].X);
                CentralPointPix.Y = tChart1.Axes.Bottom.CalcPosValue(m_lnHalfSlope[1].Y);
                
              for (int i = 0; i < 3; i++)
                {
                    PointD tmpPoint = FindPointOfGivenIndex(i);
                    m_lnHalfSlope[i].X = tmpPoint.X;
                    m_lnHalfSlope[i].Y = tmpPoint.Y;
                }
                m_lnHalfSlope.Repaint();

            }
        }
Anticipating your kind support soon.

Thanks and regards
Ashish Pandey

Amol
Advanced
Posts: 176
Joined: Mon May 29, 2006 12:00 am

Re: Line movement

Post by Amol » Thu Jun 30, 2011 10:48 am

Hi Yeray

I am still trying to get rid of this issue at my end. I am also very much optimistic with your forthcoming solution.

Thanks in advance.

Thanks and Regards
Ashish Pandey

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

Re: Line movement

Post by Yeray » Thu Jun 30, 2011 2:51 pm

Hi Ashish,

Steema technical support mission is assisting Steema customers with TeeChart usage, not implementing their charting projects. Also note that we always try to reply on a timely fashion to all technical support inquiries in this support forums, if you are looking for priority technical support you might be interested in Steema's Pro-Support plan.

Regarding your technical inquiry, I see you use the Bottom axis CalcPosValue to translate both X and Y values to pixels. Note that you need to use the Bottom axis function to get X coordinates in pixels and the Left axis function to get Y coordinates in pixels. So changing your code for this I think solves the problem:

Code: Select all

            CentralPointPix.X = tChart1.Axes.Bottom.CalcPosValue(m_lnHalfSlope[1].X);
            CentralPointPix.Y = tChart1.Axes.Left.CalcPosValue(m_lnHalfSlope[1].Y);
Or maybe easier:

Code: Select all

            CentralPointPix.X = m_lnHalfSlope.CalcXPos(1);
            CentralPointPix.Y = m_lnHalfSlope.CalcYPos(1);
Can you please check if that solves the problem for you?

Thanks in advance.
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

Amol
Advanced
Posts: 176
Joined: Mon May 29, 2006 12:00 am

Re: Line movement

Post by Amol » Fri Jul 01, 2011 11:12 am

Hi Yeray

Thanks for support and code you provided is working at my end.

It’s sad that you understood me wrongly. I always tried first to explore tee chart help, forums and examples and use our best efforts before posting queries. Generally 70-75 % I got success. I posted only those issues in which I failed. If you observe queries posted, then you will find that I didn’t ask same type of queries again.

Still TeeChart is learning phase for me and i am exploring it as much as possible.

However I am very thankful for Steema support and will try to post fewer queries.

Thanks and Regards
Ashish Pandey

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

Re: Line movement

Post by Yeray » Fri Jul 01, 2011 11:34 am

Hello Amol,

Don't take me wrong. We are pleased to try to help our customers on using TeeChart. But sometimes the line between what one can or can't consider to be TeeChart related isn't clear, or at least it is subjective. In other words, Steema's Support Team purpose is teaching how to fish more than giving fishes. :)
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

Amol
Advanced
Posts: 176
Joined: Mon May 29, 2006 12:00 am

Re: Line movement

Post by Amol » Fri Jul 01, 2011 12:51 pm

Hi Yeray

I am very much pleased with your the quick response and support. I can understand this.
Thank for all your technical support.

Thanks and Regards
Ashish Pandey

Post Reply