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
How to set the vertical line spacing
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: How to set the vertical line spacing
Apologies for the lateness of this reply. In TeeChart we have a Grid and a MinorGrid for each axis - so code such as this:
Will give us:
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;
}
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 |
Re: How to set the vertical line spacing
Thank you for responding. I tried to enable the minorgrid
but this is what I got, if you notice, the vertical line I want is still missing (red arrow)
Code: Select all
bottom.MinorGrid.Visible = true;
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: How to set the vertical line spacing
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 |
Re: How to set the vertical line spacing
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.
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.
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: How to set the vertical line spacing
Great!
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 |
Re: How to set the vertical line spacing
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;
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: How to set the vertical line spacing
Hello!
still not sure about this one - maybe it's the values in your data[] object, becuase when I use code such as this:
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?
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;
}
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 |