change the x axis value of a t-chart point graph
change the x axis value of a t-chart point graph
how can i change the value of the x-axis of a t-chart point graph from int to timestamp with format hh:mm:ss.xxxx where xxxx is milliseconds.
Re: change the x axis value of a t-chart point graph
Hi cs_ech,
I think you are looking for that:
I think you are looking for that:
Code: Select all
series1.XValues.DateTime = true;
tChart1.Axes.Bottom.Labels.DateTimeFormat = "hh:mm:ss.ffff";
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: change the x axis value of a t-chart point graph
so I added the following lines in my code:
points1.XValues.DateTime = true;
tChart1.Axes.Bottom.Labels.DateTimeFormat = "hh:mm:ss.ffff";
while (rdr.Read() )
{
DateTime dt = (System.DateTime)rdr.GetValue(0);
Double latency = (Double)rdr.GetValue(1);
Console.WriteLine(counter);
f1.points1.Add(dt, latency);
counter++;
}
However, I do not see an even x-axis spread. I am plotting data ranging from time 8am to 4pm, but, I see 5 divisions of 12:00:00.00 on x-axis. I expect to see 8:00:00.0000 10:00:00.0000 12:00:00.0000 2:00:00.0000 and 4:00:00.0000.
points1.XValues.DateTime = true;
tChart1.Axes.Bottom.Labels.DateTimeFormat = "hh:mm:ss.ffff";
while (rdr.Read() )
{
DateTime dt = (System.DateTime)rdr.GetValue(0);
Double latency = (Double)rdr.GetValue(1);
Console.WriteLine(counter);
f1.points1.Add(dt, latency);
counter++;
}
However, I do not see an even x-axis spread. I am plotting data ranging from time 8am to 4pm, but, I see 5 divisions of 12:00:00.00 on x-axis. I expect to see 8:00:00.0000 10:00:00.0000 12:00:00.0000 2:00:00.0000 and 4:00:00.0000.
Re: change the x axis value of a t-chart point graph
Hello cs_ech,
For reproduce your problem we need yor fiel. Please you could send us a simple project because we could investigated your problem here?
Thanks,
For reproduce your problem we need yor fiel. Please you could send us a simple project because we could investigated your problem here?
Thanks,
Best Regards,
Sandra Pazos / 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: change the x axis value of a t-chart point graph
private void BuildGraphs_Click(object sender, EventArgs e)
{
IDbConnection conn = Get_Connection();
IEnumerator AgoraChecklistEnumerator;
AgoraChecklistEnumerator = AgoraInstancesCheckList.CheckedIndices.GetEnumerator();
int AgoraInstance;
while (AgoraChecklistEnumerator.MoveNext() != false)
{
AgoraInstance = (int)AgoraChecklistEnumerator.Current;
AgoraInstancesCheckList.SetItemChecked(AgoraInstance, false);
DrawPointGraph drawIt = new DrawPointGraph();
GraphForm test_form1 = new GraphForm();
test_form1.name_graph(AgoraInstance);
drawIt.draw_graph(AgoraInstance, test_form1, conn, TableName);
test_form1.Show();
}
public class DrawPointGraph
{
public void draw_graph(int agoraInstance, GraphForm f1, IDbConnection conn, string TableName)
{
string sql;
if (agoraInstance == 0)
{
sql = "select a, aLatency from a.b7 order by a";
}else
{
sql = "select a, aLatency from a.b7 where a=" + ae +" order by a";
}
conn.Open();
IDbCommand command = conn.CreateCommand();
command.CommandTimeout = 2000;
command.CommandText = sql;
IDataReader rdr = command.ExecuteReader();
int counter = 0;
while (rdr.Read() && counter<100 )
{
DateTime dt = (System.DateTime)rdr.GetValue(0);
Double latency = (Double)rdr.GetValue(1);
Console.WriteLine(counter);
f1.points1.Add(dt, latency);
counter++;
}
conn.Close();
}
I am simply retriving data from the db and plotting the graph. Datetime as x axis value and double as y axis value.
{
IDbConnection conn = Get_Connection();
IEnumerator AgoraChecklistEnumerator;
AgoraChecklistEnumerator = AgoraInstancesCheckList.CheckedIndices.GetEnumerator();
int AgoraInstance;
while (AgoraChecklistEnumerator.MoveNext() != false)
{
AgoraInstance = (int)AgoraChecklistEnumerator.Current;
AgoraInstancesCheckList.SetItemChecked(AgoraInstance, false);
DrawPointGraph drawIt = new DrawPointGraph();
GraphForm test_form1 = new GraphForm();
test_form1.name_graph(AgoraInstance);
drawIt.draw_graph(AgoraInstance, test_form1, conn, TableName);
test_form1.Show();
}
public class DrawPointGraph
{
public void draw_graph(int agoraInstance, GraphForm f1, IDbConnection conn, string TableName)
{
string sql;
if (agoraInstance == 0)
{
sql = "select a, aLatency from a.b7 order by a";
}else
{
sql = "select a, aLatency from a.b7 where a=" + ae +" order by a";
}
conn.Open();
IDbCommand command = conn.CreateCommand();
command.CommandTimeout = 2000;
command.CommandText = sql;
IDataReader rdr = command.ExecuteReader();
int counter = 0;
while (rdr.Read() && counter<100 )
{
DateTime dt = (System.DateTime)rdr.GetValue(0);
Double latency = (Double)rdr.GetValue(1);
Console.WriteLine(counter);
f1.points1.Add(dt, latency);
counter++;
}
conn.Close();
}
I am simply retriving data from the db and plotting the graph. Datetime as x axis value and double as y axis value.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: change the x axis value of a t-chart point graph
Hello,
You could try setting desired bottom axis DateTime increment as shown here.
Also please notice that TeeChart tries to plot as many labels as possible in the axes according to their Increment property and not allowing labels to overlap. So it may help you getting more labels than those displayed setting labels Angle to 90, for example:
Hope this helps!
You could try setting desired bottom axis DateTime increment as shown here.
Also please notice that TeeChart tries to plot as many labels as possible in the axes according to their Increment property and not allowing labels to overlap. So it may help you getting more labels than those displayed setting labels Angle to 90, for example:
Code: Select all
tChart1.Axes.Bottom.Labels.Angle = 90;
Best Regards,
Narcís Calvet / 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: change the x axis value of a t-chart point graph
The data that i retieve is in the datetime format:
8/24/2009 9:35:11 AM
8/24/2009 9:35:30 AM
8/24/2009 9:35:33 AM
8/24/2009 9:35:36 AM
8/24/2009 2:19:31 PM
8/24/2009 2:19:31 PM
8/24/2009 2:19:32 PM
8/24/2009 3:05:00 PM
8/24/2009 3:05:00 PM
8/24/2009 3:05:00 PM
I am not sure how the follwoing add method works:
DateTime dt = (System.DateTime)rdr.GetValue(0); //where rdr is the Idatareader. The sample pf the data that is being retrieved is given above
Double latency = (Double)rdr.GetValue(1);
f1.points1.Add(dt,latency);
I tried f1.points1.Add(latency); instead and I get the same x-axis spread as when i use f1.points1.Add(dt,latency).
This means that the the add method overload that takes two arguments of type datetime and double is not working correctly. Do i need to reformat the datetime data that i get (ie: 8/24/2009 3:05:00 PM) ?
I am plotting data ranging from time 9:35am to 3:05pm, but, I see divisions of 12:00:00.00 on x-axis. I expect to see 9:35:00.0000 10:35:00.0000 11:35:00.0000 12:35:00.0000 1:35:00.0000... and so on
8/24/2009 9:35:11 AM
8/24/2009 9:35:30 AM
8/24/2009 9:35:33 AM
8/24/2009 9:35:36 AM
8/24/2009 2:19:31 PM
8/24/2009 2:19:31 PM
8/24/2009 2:19:32 PM
8/24/2009 3:05:00 PM
8/24/2009 3:05:00 PM
8/24/2009 3:05:00 PM
I am not sure how the follwoing add method works:
DateTime dt = (System.DateTime)rdr.GetValue(0); //where rdr is the Idatareader. The sample pf the data that is being retrieved is given above
Double latency = (Double)rdr.GetValue(1);
f1.points1.Add(dt,latency);
I tried f1.points1.Add(latency); instead and I get the same x-axis spread as when i use f1.points1.Add(dt,latency).
This means that the the add method overload that takes two arguments of type datetime and double is not working correctly. Do i need to reformat the datetime data that i get (ie: 8/24/2009 3:05:00 PM) ?
I am plotting data ranging from time 9:35am to 3:05pm, but, I see divisions of 12:00:00.00 on x-axis. I expect to see 9:35:00.0000 10:35:00.0000 11:35:00.0000 12:35:00.0000 1:35:00.0000... and so on
Re: change the x axis value of a t-chart point graph
Hello cs_ech,
I commented two things about your issue:
Second, Could you please arrange a simple example project we can run "as-is" to reproduce the problem here?
You can create a dataset at runtime as Christoper Ireland's example here.
Thanks,
I commented two things about your issue:
First, I don't could reproduce your problem, I made a simple example that add a dateTime and a Double and works correctly. Please, check that this application works fine.I tried f1.points1.Add(latency); instead and I get the same x-axis spread as when i use f1.points1.Add(dt,latency).
This means that the the add method overload that takes two arguments of type datetime and double is not working correctly.
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private Steema.TeeChart.Styles.Bar bar1;
private void InitializeChart()
{
Random rnd = new Random();
DateTime today = DateTime.Today;
TimeSpan twohours = TimeSpan.FromHours(2);
bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
bar1.XValues.DateTime = true;
for (int i = 1; i <= 5; i++)
{
bar1.Add(today, rnd.Next(100));
today += twohours;
}
tChart1.Axes.Bottom.Labels.DateTimeFormat = "hh:mm:ss.ffff";
tChart1.Axes.Bottom.Labels.Angle = 90;
tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.TwoHours);
}
}
}
You can create a dataset at runtime as Christoper Ireland's example here.
Thanks,
Best Regards,
Sandra Pazos / 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: change the x axis value of a t-chart point graph
Please change the graph type to point instead of bar and then increae the data size from 5 to 5000 and to reproduce the error that I get:
private Steema.TeeChart.Styles.Points point1;
private void InitializeChart()
{
System.Random rnd = new System.Random();
System.DateTime today = System.DateTime.Today;
System.TimeSpan twohours = System.TimeSpan.FromMinutes(20.5);
point1 = new Steema.TeeChart.Styles.Points(tChart1.Chart);
point1.XValues.DateTime = true;
for (int i = 1; i <= 500; i++)
{
point1.Add(today, rnd.Next(100));
today += twohours;
}
tChart1.Axes.Bottom.Labels.DateTimeFormat = "hh:mm:ss.ffff";
tChart1.Axes.Bottom.Labels.Angle = 90;
tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.TwoHours);
this.Show();
}
private Steema.TeeChart.Styles.Points point1;
private void InitializeChart()
{
System.Random rnd = new System.Random();
System.DateTime today = System.DateTime.Today;
System.TimeSpan twohours = System.TimeSpan.FromMinutes(20.5);
point1 = new Steema.TeeChart.Styles.Points(tChart1.Chart);
point1.XValues.DateTime = true;
for (int i = 1; i <= 500; i++)
{
point1.Add(today, rnd.Next(100));
today += twohours;
}
tChart1.Axes.Bottom.Labels.DateTimeFormat = "hh:mm:ss.ffff";
tChart1.Axes.Bottom.Labels.Angle = 90;
tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.TwoHours);
this.Show();
}
Re: change the x axis value of a t-chart point graph
Hello cs_ech,
I reproduce your problem, but this is not an error is a behavior of TeeChart. It when there are many labels not paint all, choose automatically intervals, because labels aren't overlapping. If you want always show all labels, there is only one solution use custom labels, but if you add many points, is likely that labels overlap, because depends of chart size and this is limited of screen resolution.
I made a simple example, that add custom labels in Bottom Axes of Chart.
I hope will helps.
Thanks,
I reproduce your problem, but this is not an error is a behavior of TeeChart. It when there are many labels not paint all, choose automatically intervals, because labels aren't overlapping. If you want always show all labels, there is only one solution use custom labels, but if you add many points, is likely that labels overlap, because depends of chart size and this is limited of screen resolution.
I made a simple example, that add custom labels in Bottom Axes of Chart.
Code: Select all
private Steema.TeeChart.Styles.Points points1;
private void InitializeChart()
{
Random rnd = new Random();
DateTime today = DateTime.Today;
TimeSpan twohours = TimeSpan.FromMinutes(20.5);
tChart1.Dock = DockStyle.Fill;
points1 = new Steema.TeeChart.Styles.Points(tChart1.Chart);
tChart1.Aspect.View3D = false;
points1.XValues.DateTime = true;
tChart1.Panel.MarginBottom = 20;
for (int i = 5; i <= 50; i++)
{
points1.Add(today, rnd.Next(100));
today += twohours;
}
tChart1.Axes.Bottom.Labels.Items.Clear();
for (int i = 0; i < points1.Count; i++)
{
tChart1.Axes.Bottom.Labels.Items.Add(points1.XValues[i], points1.Labels[i]);
}
tChart1.Axes.Bottom.Labels.DateTimeFormat = "hh:mm:ss.ffff";
tChart1.Axes.Bottom.Labels.Angle = 90;
tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.TwoHours);
}
Thanks,
Best Regards,
Sandra Pazos / 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 |