Cursor with multiple Y axis chart

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
porterbe
Newbie
Newbie
Posts: 18
Joined: Wed Oct 17, 2007 12:00 am

Cursor with multiple Y axis chart

Post by porterbe » Thu Jun 14, 2012 3:53 pm

Hi, I'm wondering if you experts can help here...

I have a TChart, on which I have multiple series, set to be on seperate Y axis. I want to be able to set up a cursor, so that I can measure the values of all series as I scroll in the X direction. I have managed to achieve the measurement bit, following the code in the examples. However I don't seem to be able to get the cursor to display accross all the axes, only the one associated with the series I specify. A simple example screen shot is below - it's missing the value getting bits, but it serves to demonstrate what I'm seeing.
TChart Cursor on Multiple Axis.PNG
TChart Cursor on Multiple Axis.PNG (81.09 KiB) Viewed 8692 times
Now, I've tried setting

Code: Select all

cursorTool1 = new CursorTool(tChart1.Chart);
, rather than the cursor series, but it doesn't help.

The code for this is as follows:

Code: Select all

 public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            cursorTool1.FollowMouse = true;
            cursorTool1.Style = CursorToolStyles.Vertical;
            cursorTool1 = new CursorTool(tChart1.Chart);

            foreach (Series s in tChart1.Series)
            {
                s.FillSampleValues(100);
            }

            Axis A1 = tChart1.Axes.Left;
            Axis A2 = new Axis(tChart1.Chart);
            Axis A3 = new Axis(tChart1.Chart);

            A1.EndPosition = 30;
            A2.StartPosition = 35;
            A2.EndPosition = 65;
            A3.StartPosition = 70;
            A3.EndPosition = 100;

            tChart1.Axes.Custom.Add(A1);
            tChart1.Axes.Custom.Add(A2);
            tChart1.Axes.Custom.Add(A3);

            tChart1.Series[0].CustomVertAxis = A1;
            tChart1.Series[1].CustomVertAxis = A2;
            tChart1.Series[2].CustomVertAxis = A3;

        }
} 

 partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.tChart1 = new Steema.TeeChart.TChart();
            this.fastLine1 = new Steema.TeeChart.Styles.FastLine();
            this.fastLine2 = new Steema.TeeChart.Styles.FastLine();
            this.fastLine3 = new Steema.TeeChart.Styles.FastLine();
            this.cursorTool1 = new Steema.TeeChart.Tools.CursorTool();
            this.cursorTool2 = new Steema.TeeChart.Tools.CursorTool();
            this.cursorTool3 = new Steema.TeeChart.Tools.CursorTool();
            this.SuspendLayout();
            // 
            // tChart1
            // 
            // 
            // 
            // 
            this.tChart1.Aspect.View3D = false;
            this.tChart1.Aspect.ZOffset = 0;
            this.tChart1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tChart1.Location = new System.Drawing.Point(0, 0);
            this.tChart1.Name = "tChart1";
            this.tChart1.Series.Add(this.fastLine1);
            this.tChart1.Series.Add(this.fastLine2);
            this.tChart1.Series.Add(this.fastLine3);
            this.tChart1.Size = new System.Drawing.Size(796, 365);
            this.tChart1.TabIndex = 0;
            this.tChart1.Tools.Add(this.cursorTool1);
            this.tChart1.Tools.Add(this.cursorTool2);
            this.tChart1.Tools.Add(this.cursorTool3);
            // 
            // fastLine1
            // 
            this.fastLine1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(68)))), ((int)(((byte)(102)))), ((int)(((byte)(163)))));
            this.fastLine1.ColorEach = false;
            // 
            // 
            // 
            this.fastLine1.LinePen.Color = System.Drawing.Color.FromArgb(((int)(((byte)(68)))), ((int)(((byte)(102)))), ((int)(((byte)(163)))));
            // 
            // 
            // 
            // 
            // 
            // 
            this.fastLine1.Marks.Callout.ArrowHead = Steema.TeeChart.Styles.ArrowHeadStyles.None;
            this.fastLine1.Marks.Callout.ArrowHeadSize = 8;
            // 
            // 
            // 
            this.fastLine1.Marks.Callout.Brush.Color = System.Drawing.Color.Black;
            this.fastLine1.Marks.Callout.Distance = 0;
            this.fastLine1.Marks.Callout.Draw3D = false;
            this.fastLine1.Marks.Callout.Length = 10;
            this.fastLine1.Marks.Callout.Style = Steema.TeeChart.Styles.PointerStyles.Rectangle;
            this.fastLine1.Marks.Callout.Visible = false;
            this.fastLine1.Title = "fastLine1";
            this.fastLine1.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.Ignore;
            // 
            // 
            // 
            this.fastLine1.XValues.DataMember = "X";
            this.fastLine1.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.Ascending;
            // 
            // 
            // 
            this.fastLine1.YValues.DataMember = "Y";
            // 
            // fastLine2
            // 
            this.fastLine2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(156)))), ((int)(((byte)(53)))));
            this.fastLine2.ColorEach = false;
            // 
            // 
            // 
            this.fastLine2.LinePen.Color = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(156)))), ((int)(((byte)(53)))));
            // 
            // 
            // 
            // 
            // 
            // 
            this.fastLine2.Marks.Callout.ArrowHead = Steema.TeeChart.Styles.ArrowHeadStyles.None;
            this.fastLine2.Marks.Callout.ArrowHeadSize = 8;
            // 
            // 
            // 
            this.fastLine2.Marks.Callout.Brush.Color = System.Drawing.Color.Black;
            this.fastLine2.Marks.Callout.Distance = 0;
            this.fastLine2.Marks.Callout.Draw3D = false;
            this.fastLine2.Marks.Callout.Length = 10;
            this.fastLine2.Marks.Callout.Style = Steema.TeeChart.Styles.PointerStyles.Rectangle;
            this.fastLine2.Marks.Callout.Visible = false;
            this.fastLine2.Title = "fastLine2";
            this.fastLine2.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.Ignore;
            // 
            // 
            // 
            this.fastLine2.XValues.DataMember = "X";
            this.fastLine2.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.Ascending;
            // 
            // 
            // 
            this.fastLine2.YValues.DataMember = "Y";
            // 
            // fastLine3
            // 
            this.fastLine3.Color = System.Drawing.Color.FromArgb(((int)(((byte)(241)))), ((int)(((byte)(76)))), ((int)(((byte)(20)))));
            this.fastLine3.ColorEach = false;
            // 
            // 
            // 
            this.fastLine3.LinePen.Color = System.Drawing.Color.FromArgb(((int)(((byte)(241)))), ((int)(((byte)(76)))), ((int)(((byte)(20)))));
            // 
            // 
            // 
            // 
            // 
            // 
            this.fastLine3.Marks.Callout.ArrowHead = Steema.TeeChart.Styles.ArrowHeadStyles.None;
            this.fastLine3.Marks.Callout.ArrowHeadSize = 8;
            // 
            // 
            // 
            this.fastLine3.Marks.Callout.Brush.Color = System.Drawing.Color.Black;
            this.fastLine3.Marks.Callout.Distance = 0;
            this.fastLine3.Marks.Callout.Draw3D = false;
            this.fastLine3.Marks.Callout.Length = 10;
            this.fastLine3.Marks.Callout.Style = Steema.TeeChart.Styles.PointerStyles.Rectangle;
            this.fastLine3.Marks.Callout.Visible = false;
            this.fastLine3.Title = "fastLine3";
            this.fastLine3.TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.Ignore;
            // 
            // 
            // 
            this.fastLine3.XValues.DataMember = "X";
            this.fastLine3.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.Ascending;
            // 
            // 
            // 
            this.fastLine3.YValues.DataMember = "Y";
            // 
            // cursorTool1
            // 
            this.cursorTool1.FollowMouse = true;
            this.cursorTool1.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical;
            this.cursorTool1.Change += new Steema.TeeChart.Tools.CursorChangeEventHandler(this.cursorToolX_Change);
            // 
            // cursorTool2
            // 
            this.cursorTool2.FollowMouse = true;
            // 
            // 
            // 
            this.cursorTool2.Pen.Color = System.Drawing.Color.Black;
            this.cursorTool2.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical;
            // 
            // cursorTool3
            // 
            this.cursorTool3.FollowMouse = true;
            // 
            // 
            // 
            this.cursorTool3.Pen.Color = System.Drawing.Color.Black;
            this.cursorTool3.Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical;
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(796, 365);
            this.Controls.Add(this.tChart1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.ResumeLayout(false);

        }

        #endregion

        private Steema.TeeChart.TChart tChart1;
        private Steema.TeeChart.Styles.FastLine fastLine1;
        private Steema.TeeChart.Styles.FastLine fastLine2;
        private Steema.TeeChart.Styles.FastLine fastLine3;
        private Steema.TeeChart.Tools.CursorTool cursorTool1;
        private Steema.TeeChart.Tools.CursorTool cursorTool2;
        private Steema.TeeChart.Tools.CursorTool cursorTool3;
    }
}
I can assign cursors to each individual axis, and then write some code to keep all the X positions in sync, but that doesn't create a single continuous line accross all the plots, which is what I wanted to achieve. Any suggestions on how to do this?

As usual, TIA for the help...

Bernie

porterbe
Newbie
Newbie
Posts: 18
Joined: Wed Oct 17, 2007 12:00 am

Re: Cursor with multiple Y axis chart

Post by porterbe » Thu Jun 14, 2012 8:02 pm

I also have another question on the same code - why is the axis text off the screen? How do I get it to display properly, as it does for a single axis?

As always, TIA.... :|

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Cursor with multiple Y axis chart

Post by Narcís » Fri Jun 15, 2012 1:57 pm

Hi porterbe,
I can assign cursors to each individual axis, and then write some code to keep all the X positions in sync, but that doesn't create a single continuous line accross all the plots, which is what I wanted to achieve. Any suggestions on how to do this?
In that case you could try using a ColorLine tool associated to the bottom axis. This tool also has a You'll find examples at All Features\Welcome !\Tools\Color Line in the features demo, available at TeeChart's program group. This tool has Value property but doesn't follow mouse as CursorTool does. In which case you could use both of them and paint the ColorLine over the CursorTool to get that continuous line all over the chart.

For calculating series values at each position you may be interested in the All Features\Welcome !\Chart styles\Standard\Line(Strip)\Interpolating line series example in the demo.
I also have another question on the same code - why is the axis text off the screen? How do I get it to display properly, as it does for a single axis?
You can try adjusting the left margin, for example:

Code: Select all

      tChart1.Panel.MarginLeft = 5;
Hope this helps!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

porterbe
Newbie
Newbie
Posts: 18
Joined: Wed Oct 17, 2007 12:00 am

Re: Cursor with multiple Y axis chart

Post by porterbe » Mon Jun 18, 2012 8:55 pm

Thanks for that. Unfortunately, setting Panel.Margin to a specified % doesn't help when the length of the Axis Title Text is not known until runtime. Is there a way of determining the required offset? If I change the Axis text in the chart editor in development mode, then the axis position automatically moves to accomodate it. The Title.Width property returns 0!

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Cursor with multiple Y axis chart

Post by Sandra » Tue Jun 19, 2012 9:38 am

Hello porterbe,

Can you please send me your project or arrange a simple code where the problem occurs because we can try to solve your problem here?

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

porterbe
Newbie
Newbie
Posts: 18
Joined: Wed Oct 17, 2007 12:00 am

Re: Cursor with multiple Y axis chart

Post by porterbe » Tue Jun 19, 2012 12:32 pm

Ok, solved it.

Due to my UI Design requirements, I held each series and each y axis in arrays. I was then adding series and axis to the relevant collections in the chart at run time, dependant on the user selection. If I assign the cursor to the standard left Axis, but use custom axes for all the series, then I can get the cursor to span the entire screen and the interpolation to give me the Y values for each of the series. That just left me with the issue of the Y axis text display. I've solved that by determining the longest Y Axis title, getting the length of that from the Graphics3D.MeasureString method of the TChart object and setting the Panel.MarginLeft value to that plus a bit.

It seems that the Y axis Auto positioning only functions on the standard axes, not with custom ones...

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Cursor with multiple Y axis chart

Post by Sandra » Wed Jun 20, 2012 8:37 am

Hello porterbe,

Thanks for your information. I am glad you have solded your problem. If you need more help, please let me know.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply