Page 1 of 1

How to set the vertical line spacing

Posted: Thu Jun 04, 2020 6:21 am
by 15686476
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 17406 times

Re: How to set the vertical line spacing

Posted: Wed Jun 10, 2020 11:15 am
by Christopher
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 17358 times

Re: How to set the vertical line spacing

Posted: Thu Jun 11, 2020 3:39 am
by 15686476
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 17349 times

Re: How to set the vertical line spacing

Posted: Thu Jun 11, 2020 8:11 am
by Christopher
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.

Re: How to set the vertical line spacing

Posted: Thu Jun 18, 2020 1:28 am
by 15686476
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 17271 times

Re: How to set the vertical line spacing

Posted: Thu Jun 18, 2020 7:52 am
by Christopher
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?

Re: How to set the vertical line spacing

Posted: Thu Jun 18, 2020 10:16 pm
by 15686476
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;


Re: How to set the vertical line spacing

Posted: Fri Jun 19, 2020 9:05 am
by Christopher
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?