Vertical line

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
isetUser
Newbie
Newbie
Posts: 8
Joined: Thu Jan 19, 2023 12:00 am

Vertical line

Post by isetUser » Fri Jun 02, 2023 1:23 am

now I want to create vertical lines ,i used CursorTool . this line is Control line

Code: Select all

	   var cuTool =new Steema.TeeChart.Tools.CursorTool(tChart.Chart)
            {
                Style = CursorToolStyles.Vertical,
                FollowMouse = false,
            };
            cuTool.Pen.Color = Color.Red;
            cuTool.Pen.Visible = true;
chart.xaxis is datetime .
i want cuTool.xvalue binding datatime For example cuTool.xvalue = datetime.now;
but cuTool.xvalue need double
can i use CursorTool to create vertical lines ?
If not, what can I do
Attachments
uTools_1685668154622.png
uTools_1685668154622.png (39.37 KiB) Viewed 5987 times

isetUser
Newbie
Newbie
Posts: 8
Joined: Thu Jan 19, 2023 12:00 am

Re: Vertical line

Post by isetUser » Mon Jun 05, 2023 12:18 am

Code: Select all

var cuTool = new Steema.TeeChart.Tools.CursorTool(tChart.Chart)
                    {
                        Style = CursorToolStyles.Vertical,
                        FollowMouse = false,
                    };
                    cuTool.Pen.Color = Color.Red;
                    cuTool.Pen.Visible = true;
                    
                    DateTime dateTime = DateTime.Now.AddDays(-60);
                    cuTool.XValue = dateTime.ToOADate();
(dateTime.ToOADate())this value can not Assign to XValue
The value of xvalue is 0

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

Re: Vertical line

Post by Christopher » Mon Jun 05, 2023 9:03 am

Hello,
isetUser wrote:
Fri Jun 02, 2023 1:23 am
(dateTime.ToOADate())this value can not Assign to XValue
The value of xvalue is 0
Yes, as the Cursor Tool is designed more for user interactivity, to get it to draw statically means having to render the chart first with

Code: Select all

 tChart1.Draw() 
For example:

Code: Select all

        Line _line1;
        public Form1()
        {
            InitializeComponent();
            _line1 = new Line(tChart1.Chart);

            var now = DateTime.UtcNow;
            var rnd = new Random();

            for (int i = 0; i < 30; i++)
            {
                _line1.Add(now.AddMinutes(i), rnd.NextDouble());
            }


            var cuTool = new Steema.TeeChart.Tools.CursorTool(tChart1.Chart)
            {
                Style = CursorToolStyles.Vertical,
                FollowMouse = false,
            };
            cuTool.Pen.Color = Color.Red;
            cuTool.Pen.Visible = true;

            tChart1.Draw();

            var val = _line1.XValues[10];

            tChart1.Text = $"TeeChart, Time: { DateTime.FromOADate(val).ToLongTimeString() }";

            cuTool.XValue = val;
        }
Which gives us:
Screenshot from 2023-06-05 11-02-56.png
Screenshot from 2023-06-05 11-02-56.png (111.33 KiB) Viewed 5921 times
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

Post Reply