Page 1 of 1

Drawing X and Y axes on chart

Posted: Tue Feb 26, 2019 12:11 pm
by 15685169
Is there any way to ensure TeeChart draws the X and Y axes on a graph. In other words I need to display a vertical and horizontal line through the origin (0,0) of my Fastline chart.

Thanks
Rob

Re: Drawing X and Y axes on chart

Posted: Wed Feb 27, 2019 9:49 am
by Christopher
Hi Rob,

maybe you have in mind something like this:
TeeChartPro_2019-02-27_10-46-07.png
TeeChartPro_2019-02-27_10-46-07.png (15.58 KiB) Viewed 8828 times
This can be achieved with code similar to this:

Code: Select all

        private void InitializeChart()
        { 
            var forvel = new FastLine(tChart1.Chart);

            var lines = File.ReadAllLines(@"D:\tmp\FastLine Data.csv").Skip(1)
              .Select(x => x.Split(','))
              .Select(x => x.Select(y => double.Parse(y)))
              .Select(x => new { Time = x.ToArray()[0], Velocity = x.ToArray()[1], Force = x.ToArray()[2] }).ToArray();

            forvel.Add(lines.Select(x => x.Velocity).ToArray(), lines.Select(y => y.Force).ToArray());

            tChart1.Axes.Left.AxisPen.Visible = true;
            tChart1.Axes.Left.PositionUnits = PositionUnits.Percent;
            tChart1.Axes.Bottom.PositionUnits = PositionUnits.Percent;

            tChart1.Axes.Left.RelativePosition = 50;
            tChart1.Axes.Bottom.RelativePosition = 50;

            tChart1.Axes.Left.SetMinMax(-2300, 2300);
            tChart1.Axes.Bottom.SetMinMax(-3, 3);
        }