How to set the vertical line spacing
Posted: 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
Steema Software - Customer Support Forums
http://216.92.101.67/support/
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;
}
Code: Select all
bottom.MinorGrid.Visible = true;
Great!
How are you adding values into your 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;
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;
}