- Custom Bottom Axis
- MS Chart.JPG (69.38 KiB) Viewed 4705 times
Custom Bottom Axis
Custom Bottom Axis
How can we create Bottom Axis same as shown in above image?
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Custom Bottom Axis
As an approximation, I think this might be a reasonable start:Quant wrote: How can we create Bottom Axis same as shown in above image?
Code: Select all
Candle series = new Candle();
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Series.Add(series);
series.FillSampleValues(100);
tChart1.Axes.Bottom.Labels.DateTimeFormat = "dd";
tChart1.Axes.Bottom.Increment = Utils.GetDateTimeStep(DateTimeSteps.OneWeek);
tChart1.Panel.MarginBottom = 30;
tChart1.AfterDraw += tChart1_AfterDraw;
}
void tChart1_AfterDraw(object sender, Graphics3D g)
{
Axis bottom = tChart1.Axes.Bottom;
Rectangle rect = Utils.FromLTRB(bottom.IStartPos, bottom.Position, bottom.IEndPos, bottom.Position + g.FontHeight * 2);
g.Pen.Color = Color.Red;
g.Brush.Visible = false;
g.Rectangle(rect);
DateTime minDate = DateTime.FromOADate(bottom.Minimum);
DateTime maxDate = DateTime.FromOADate(bottom.Maximum);
for (DateTime date = minDate; date.Date <= maxDate; date = date.AddDays(1))
{
if(date.Day == 1)
{
DateTime tmpDate = new DateTime(date.Year, date.Month, date.Day);
int tmpX = bottom.CalcPosValue(tmpDate.ToOADate());
int tmpY = rect.Bottom + rect.Height;
g.VerticalLine(tmpX, rect.Top, tmpY);
g.Font.Color = Color.Red;
g.TextOut(tmpX, tmpY - g.FontHeight, tmpDate.ToString("MMMM"));
}
}
}
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 |