Page 1 of 1

TeeChart Pro Cursor

Posted: Thu Apr 18, 2019 12:41 pm
by 15686059
Hi Team,

I've got a question regarding the cursor Tool:
Is it possible to snap between x-values and get the y-value of every series in the chart?

For example:
- there are 3 line-series in the Chart and you add 1 cursor
- these 3 line-series got the same X-values but different Y-values
- now you want to jump along the X-values and mark the assigned Y-value of each line-series
- so with 3 line-series we would have 1 cursor and 3 marks on it

Thank you in advance!

Best regards,
Florian

Re: TeeChart Pro Cursor

Posted: Tue Apr 23, 2019 7:26 am
by Christopher
Hello,

first, many apologies for the lateness of this reply.

To answer your question: yes, I think this should be possible, and I attach a code example which does most of what you ask.

Code: Select all

        Line _line1 = new Line(), _line2 = new Line(), _line3 = new Line();
        CursorTool _cursorTool = new CursorTool();

        private void InitializeChart()
        {
            void _cursorTool_SnapChange(object sender, CursorChangeEventArgs e)
            {
              if(e.SnapPoint > -1)
              {
                    var values = "Line1 YValue: " + _line1.YValues[e.SnapPoint] + Environment.NewLine;
                    values += "Line2 YValue: " + _line2.YValues[e.SnapPoint] + Environment.NewLine;
                    values += "Line3 YValue: " + _line3.YValues[e.SnapPoint] + Environment.NewLine;

                    tChart1.Header.Text = values;
                }
            }

            tChart1.Series.Add(_line1).FillSampleValues();
            tChart1.Series.Add(_line2).FillSampleValues();
            tChart1.Series.Add(_line3).FillSampleValues();

            tChart1.Tools.Add(_cursorTool);

            _cursorTool.Series = _line1;
            _cursorTool.Style = CursorToolStyles.Vertical;
            _cursorTool.Snap = true;
            _cursorTool.SnapChange += _cursorTool_SnapChange;
            _cursorTool.FollowMouse = true;
        }

Re: TeeChart Pro Cursor

Posted: Wed Apr 24, 2019 2:07 pm
by 15686059
Hi Christopher,

thank you for your help, but is it maybe possible to post the code in VB.NET again?

Thanks a lot!

Re: TeeChart Pro Cursor

Posted: Thu Apr 25, 2019 6:40 am
by Christopher
Hello,
LebbingUser wrote:
Wed Apr 24, 2019 2:07 pm
thank you for your help, but is it maybe possible to post the code in VB.NET again?
Of course, here you are:

Code: Select all

    Private _line1 As Line = New Line(), _line2 As Line = New Line(), _line3 As Line = New Line()
    Private _cursorTool As CursorTool = New CursorTool()

    Private Sub InitializeChart()
        TChart1.Series.Add(_line1).FillSampleValues()
        TChart1.Series.Add(_line2).FillSampleValues()
        TChart1.Series.Add(_line3).FillSampleValues()
        TChart1.Tools.Add(_cursorTool)
        _cursorTool.Series = _line1
        _cursorTool.Style = CursorToolStyles.Vertical
        _cursorTool.Snap = True
        AddHandler _cursorTool.SnapChange, AddressOf _cursorTool_SnapChange
        _cursorTool.FollowMouse = True
    End Sub

    Private Sub _cursorTool_SnapChange(ByVal sender As Object, ByVal e As CursorChangeEventArgs)
        If e.SnapPoint > -1 Then
            Dim values = "Line1 YValue: " & _line1.YValues(e.SnapPoint).ToString() + Environment.NewLine
            values += "Line2 YValue: " & _line2.YValues(e.SnapPoint).ToString() + Environment.NewLine
            values += "Line3 YValue: " & _line3.YValues(e.SnapPoint).ToString() + Environment.NewLine
            TChart1.Header.Text = values
        End If
    End Sub

Re: TeeChart Pro Cursor

Posted: Thu Apr 25, 2019 7:36 am
by 15686059
Hi Christopher,

that works fine!
Perfect, thank you very much for your quick help!

Best regards!