We did receive your e-mail and example and replied to it yesterday and today. Didn't you receive our e-mails?
Anyway, this was a bug (TF02012833) which has been fixed for the next maintenance release. In the meantime, I also suggested you a workaround that consisted on using the GetAxisLabel event. Here is the code:
Code: Select all
public partial class Form1 : Form
{
private DataTable sourceTable;
private DataColumn colXData;
private DataColumn colYData;
private DataColumn colColor;
private DataColumn newC;
private Steema.TeeChart.Styles.FastLine f;
private Annotation anno1;
private Steema.TeeChart.Axis axis1;
private string[] XLabels;
public Form1()
{
InitializeComponent();
LoadDB();
ShowGraph();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void LoadDB()
{
//System.DateTime
sourceTable = new DataTable("sourceTable");
colXData = new DataColumn("XData", Type.GetType("System.DateTime"));
colYData = new DataColumn("YData", Type.GetType("System.String"));
colColor = new DataColumn("Color", Type.GetType("System.Object"));
newC = new DataColumn("newC", Type.GetType("System.Object"));
// add colls
sourceTable.Columns.Add(colXData);
sourceTable.Columns.Add(colYData);
sourceTable.Columns.Add(colColor);
sourceTable.Columns.Add(newC);
// fill data
DataRow NewRow;
int time = 100;
int start = 100;
int end = 130;
long now = DateTime.Now.Ticks;
for (int i = start; i < end; i++)
{
NewRow = sourceTable.NewRow();
// NewRow["Desc"] = "Label" + i.ToString();
NewRow["YData"] = i * i;//Math.Sin(i*2*Math.PI/360);
NewRow["newC"] = i * 5.5f;
if ((i % 5) == 0)
{
time = time + 1;
NewRow["Color"] = Color.Red;
}
else
{
time = time + 2;
NewRow["Color"] = Color.Blue;
}
DateTime next = new DateTime(now);
next = next.AddMilliseconds(time);
NewRow["XData"] = next;
//string tmpDate = "11:11:11." + time;
//XLabels[i - start] = tmpDate;
//NewRow["XData"] = DateTime.Parse(tmpDate);
sourceTable.Rows.Add(NewRow);
}
}
private void ShowGraph()
{
tChart1.Panel.MarginLeft = 8;
this.axis1 = new Steema.TeeChart.Axis(this.tChart1.Chart);
//axis1.Increment = (double)Steema.TeeChart.DateTimeSteps.OneMillisecond;
axis1.StartPosition = 0;
axis1.EndPosition = 50;
axis1.AxisPen.Style = System.Drawing.Drawing2D.DashStyle.Solid;
axis1.AxisPen.Color = Color.Red;
axis1.AutomaticMaximum = true;
axis1.AutomaticMinimum = true;
tChart1.Axes.Custom.Add(axis1);
//tChart1.Axes.Bottom.Labels.ValueFormat = "0.#";
////tChart1.Axes.Bottom.Labels.Style = Steema.TeeChart.AxisLabelStyle.Value;
//tChart1.Axes.Bottom.Labels.Separation = 0;
//tChart1.Axes.Bottom.Labels.DateTimeFormat = "hh:mm:ss:FFF";
////tChart1.Axes.Bottom.Labels.Angle = 90;
//tChart1.Axes.Bottom.Grid.Visible = false;
////tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneMillisecond);
tChart1.Tools.Add(anno1 = new Annotation());
anno1.Shape.CustomPosition = true;
anno1.Shape.Left = axis1.Position + 50;
anno1.Shape.Top = axis1.IStartPos + 50;
anno1.Shape.Font.Color = Color.Blue;
anno1.Text = "ok";
anno1.AutoSize = true;
anno1.Shape.Transparent = true;
f = new Steema.TeeChart.Styles.FastLine();
f.DrawAllPoints = false;
tChart1.Series.Add(f);
f.CustomVertAxis = axis1;
f.LinePen.Width = 4;
f.ValueFormat = "";
//f.XValues.DateTime = true;
f.XValues.DataMember = "XData";
f.YValues.DataMember = "Ydata";
// f.ColorMember = "Color";
//f.LabelMember = "newC";
f.DataSource = sourceTable;
tChart1.Axes.Bottom.Labels.ValueFormat = "";
tChart1.GetAxisLabel += new Steema.TeeChart.GetAxisLabelEventHandler(tChart1_GetAxisLabel);
}
void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
{
if (sender == tChart1.Axes.Bottom)
{
DateTime dt = DateTime.FromOADate(Convert.ToDouble(e.LabelText));
dt.Millisecond.ToString();
e.LabelText = dt.ToLongTimeString() + ":" + dt.Millisecond.ToString();
}
}
}