How to set the vertical line spacing

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
sws
Newbie
Newbie
Posts: 6
Joined: Wed Jun 26, 2019 12:00 am

How to set the vertical line spacing

Post by sws » Thu Jun 04, 2020 6:21 am

I'm pretty new to teecharts. I created a chart but for some reason the vertical line spacing is skipping one date. Basically this is what I want it to look like
Capture2.PNG
Capture2.PNG (206.7 KiB) Viewed 17418 times

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

Re: How to set the vertical line spacing

Post by Christopher » Wed Jun 10, 2020 11:15 am

Apologies for the lateness of this reply. In TeeChart we have a Grid and a MinorGrid for each axis - so code such as this:

Code: Select all

        private void InitializeChart()
        {
            var line = new Line(_tChart.Chart);

            line.FillSampleValues();

            var bottom = _tChart.Axes.Bottom;

            bottom.Grid.DrawEvery = 1;
            bottom.Grid.Color = Color.Red;
            bottom.Grid.Visible = true;

            bottom.MinorGrid.Color = Color.Yellow;
            bottom.MinorGrid.Style = System.Drawing.Drawing2D.DashStyle.Dot;
            bottom.MinorTickCount = 1;
            bottom.MinorGrid.Visible = true;
        }
Will give us:
TeeChartPro_2020-06-10_13-13-16.png
TeeChartPro_2020-06-10_13-13-16.png (27.64 KiB) Viewed 17370 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

sws
Newbie
Newbie
Posts: 6
Joined: Wed Jun 26, 2019 12:00 am

Re: How to set the vertical line spacing

Post by sws » Thu Jun 11, 2020 3:39 am

Thank you for responding. I tried to enable the minorgrid

Code: Select all

bottom.MinorGrid.Visible = true;
but this is what I got, if you notice, the vertical line I want is still missing (red arrow)
Capture.PNG
Capture.PNG (196.69 KiB) Viewed 17361 times

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

Re: How to set the vertical line spacing

Post by Christopher » Thu Jun 11, 2020 8:11 am

sws wrote:
Thu Jun 11, 2020 3:39 am
Thank you for responding. I tried to enable the minorgrid
What happens when you add in all the code that refers to Grid and MinorGrid on the bottom axis? DrawEvery is set to 2 by default; maybe it's 1 that you need.
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

sws
Newbie
Newbie
Posts: 6
Joined: Wed Jun 26, 2019 12:00 am

Re: How to set the vertical line spacing

Post by sws » Thu Jun 18, 2020 1:28 am

Thank you Christopher, drawevery = 1 solved my problem! :)

Another thing related to vertical lines. When I zoom in I got this non equal spacing axis lines (see red lines which are bigger), How do I make sure these has the same spacing.
Capture.PNG
Capture.PNG (33.39 KiB) Viewed 17283 times

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

Re: How to set the vertical line spacing

Post by Christopher » Thu Jun 18, 2020 7:52 am

sws wrote:
Thu Jun 18, 2020 1:28 am
Thank you Christopher, drawevery = 1 solved my problem! :)
Great! :)
sws wrote:
Thu Jun 18, 2020 1:28 am
Another thing related to vertical lines. When I zoom in I got this non equal spacing axis lines (see red lines which are bigger), How do I make sure these has the same spacing.
How are you adding values into your series?
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

sws
Newbie
Newbie
Posts: 6
Joined: Wed Jun 26, 2019 12:00 am

Re: How to set the vertical line spacing

Post by sws » Thu Jun 18, 2020 10:16 pm

This is how I add values to my series

Code: Select all

	//Clear the series
            _view.Chart.Series.Clear();

            //add new series
            Steema.TeeChart.Styles.Line chartLine = new Steema.TeeChart.Styles.Line(_view.Chart.Chart);

            _view.Chart.Axes.Custom.Add(new Steema.TeeChart.Axis(_view.Chart.Chart));
            _view.Chart[0].CustomVertAxis = _view.Chart.Axes.Custom[0];
            
            chartLine.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Right;
            chartLine.GetSeriesMark += ChartLine_GetSeriesMark;

            Dictionary<int, dynamic> tagData = new Dictionary<int, dynamic>();

            tagData.Add(0, _view.SelectedPortfolio.PortfolioName);
            chartLine.Tag = tagData;
            chartLine.LinePen.Color = Color.Black;
            chartLine.LinePen.Width = 1;
            chartLine.Brush.Color = Color.Black;

            for (int i = 0; i < data.Count - 1; i++)
            {
                chartLine.Add(data[i].EventDate.Date, Convert.ToDouble(data[i].Portfolio_Value_A));
            }
           
            _view.Chart.Axes.Right.Automatic = false;
            //add 15% space above and below
            double adjustmentForSpacing = Convert.ToDouble(data.Min(d=>d.Portfolio_Value_A)) * 0.05;
            _view.Chart.Axes.Right.Minimum = Convert.ToDouble(data.Min(d=>d.Portfolio_Value_A)) - adjustmentForSpacing;
            _view.Chart.Axes.Right.Maximum = Convert.ToDouble(data.Max(d => d.Portfolio_Value_A)) + adjustmentForSpacing;
            _view.Chart.Axes.Right.MaximumOffset = 0;
            _view.Chart.Axes.Right.Labels.Font = GlobalFont;
            _view.Chart.Axes.Right.Ticks.Color = Color.Black;
            _view.Chart.Axes.Right.Ticks.Width = 1;
            _view.Chart.Axes.Right.Ticks.Length = 2;
            
            _view.Chart.Axes.Bottom.Labels.Style = AxisLabelStyle.PointValue;

            
            _view.Chart.Axes.Bottom.Labels.Font = GlobalFont;
            _view.Chart.Axes.Bottom.Ticks.Width = 1;
            _view.Chart.Axes.Bottom.Ticks.Length = 2;
            _view.Chart.Axes.Bottom.Ticks.Color = Color.Black;

            _view.Chart.Zoom.Direction = Steema.TeeChart.ZoomDirections.Horizontal;


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

Re: How to set the vertical line spacing

Post by Christopher » Fri Jun 19, 2020 9:05 am

Hello!

still not sure about this one - maybe it's the values in your data[] object, becuase when I use code such as this:

Code: Select all

        private void InitializeChart()
        {
            var rnd = new Random();

            var line1 = new Line(_tChart.Chart);

            var day = DateTime.Today;


            for (int i = 0; i < 100; i++)
            {
                line1.Add(day, rnd.Next(1, 100));
                day = day.AddDays(1);
            }

            _tChart.Axes.Bottom.Grid.Visible = true;
            _tChart.Axes.Bottom.Grid.DrawEvery = 1;
        }
I can zoom repeatedly without reproducing your issue. Do you see your issue with the code above? If you don't, could you please modify the code above so I can reproduce your issue here?
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