Page 1 of 1

Vertical line

Posted: Fri Jun 02, 2023 1:23 am
by 20095116
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

Re: Vertical line

Posted: Mon Jun 05, 2023 12:18 am
by 20095116

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

Re: Vertical line

Posted: Mon Jun 05, 2023 9:03 am
by Christopher
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 5952 times