Issue with plotting datetime series

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
SDG
Newbie
Newbie
Posts: 40
Joined: Tue Apr 08, 2003 4:00 am

Issue with plotting datetime series

Post by SDG » Wed Sep 09, 2009 2:53 pm

Hi,

We are facing issue when trying to plot two series on chart with datetime on X axis(DD-MM-YYYY hh:mm:ss). First series is plotting normally while the second is not. Kindly advise.

Thanks,
Dinesh.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Issue with plotting datetime series

Post by Narcís » Wed Sep 09, 2009 3:09 pm

Hi Dinesh,

Could you please give us more detailed information about the exact problem? A simple code snippet on how to reproduce it and an image showing it would be very helpful.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

SDG
Newbie
Newbie
Posts: 40
Joined: Tue Apr 08, 2003 4:00 am

Re: Issue with plotting datetime series

Post by SDG » Thu Sep 10, 2009 5:00 am

Hi Narcís,

We have bought TeeChart for Java V2 recently. Please look into the attached snapshot. In the X-axis we are plotting date and time series, and Y-Axis is the amounts. "Debit" series are plotted properly, but "Credit" is completely wrong. You can see the x-axis values at each node. If I uncheck the "Debit" series, then "Credit" series will be drawn properly. But requirement is both should be viewed at a time.

We are using Series.Add(<<double>>, <<string>>) method to add points. The datetime value at X-axis are in the string value. Kindly advice us to solve the problem.

Best,
Thanks.
Attachments
pbgraph.JPG
pbgraph.JPG (141.82 KiB) Viewed 16119 times

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Issue with plotting datetime series

Post by Narcís » Thu Sep 10, 2009 10:22 am

Hi SDG,

Thanks for the information.
We are using Series.Add(<<double>>, <<string>>) method to add points. The datetime value at X-axis are in the string value.
In that case you should use the add(datetime, double, string) or add(datetime, double) methods for populating series.

Hope this helps!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

SDG
Newbie
Newbie
Posts: 40
Joined: Tue Apr 08, 2003 4:00 am

Re: Issue with plotting datetime series

Post by SDG » Thu Sep 10, 2009 1:06 pm

Hi Narcís,

Thanks for your reply. This helped us to some extent, but we did not get exact result.
We get the datetime data from a Oracle stored procedure as "01-08-2008 02:16:00". We have used below given code to convert from datetime in the form of string to DateTime object. The datetime displayed at X-axis is still wrong. The format for the X-axis label is "dd-mm-yyyy hh.mm.ss". Kindly advise us.

-----------------------------Code to convert string to datetime object-------------------------------------------------
public DateTime getDateTime(String l_strDateTime){
Calendar calObj = Calendar.getInstance();
StringTokenizer l_strDateTokenizer1 = new StringTokenizer(l_strDateTime," ");
String l_strDate = null;
String l_strTime = null;
while(l_strDateTokenizer1.hasMoreTokens()) {
l_strDate = l_strDateTokenizer1.nextToken();
l_strTime = l_strDateTokenizer1.nextToken();
}
StringTokenizer l_strDateTokenizer2 = new StringTokenizer(l_strDate,"-");
int l_intDay = 0, l_intMonth = 0, l_intYear = 0;
while(l_strDateTokenizer2.hasMoreTokens()) {
l_intDay = Integer.parseInt(l_strDateTokenizer2.nextToken());
l_intMonth = Integer.parseInt(l_strDateTokenizer2.nextToken());
l_intYear = Integer.parseInt(l_strDateTokenizer2.nextToken());
}
StringTokenizer l_strDateTokenizer3 = new StringTokenizer(l_strTime,":");
int l_intHour = 0, l_intMinute = 0, l_intSecond = 0;
while(l_strDateTokenizer2.hasMoreTokens()) {
l_intHour = Integer.parseInt(l_strDateTokenizer3.nextToken());
l_intMinute =Integer.parseInt(l_strDateTokenizer3.nextToken());
l_intSecond = Integer.parseInt(l_strDateTokenizer3.nextToken());
}
calObj.set(l_intYear, l_intMonth, l_intDay, l_intMinute, l_intSecond);
return new DateTime(calObj.getTimeInMillis());
}
------------------------------------------------------------------------------

Best,
Thanks,
Dinesh and Ronad.
Attachments
pbGraph.JPG
pbGraph.JPG (132.01 KiB) Viewed 16121 times

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Issue with plotting datetime series

Post by Narcís » Thu Sep 10, 2009 2:32 pm

Hi Dinesh and Ronad,

Thanks for the information. Could you please attach a simple example project or post a code snippet we can run "as-is" to reproduce the problem here?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

SDG
Newbie
Newbie
Posts: 40
Joined: Tue Apr 08, 2003 4:00 am

Re: Issue with plotting datetime series

Post by SDG » Fri Sep 11, 2009 7:10 am

Hi Narcís,

Please copy TeeChart.Swing.jar in fdmscharts folder and open RightFrame.html to view the sample.
The java code for same is also provided.

Thanks,
Dinesh and Ronad.
Attachments
Sample.zip
(8.38 KiB) Downloaded 990 times

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Issue with plotting datetime series

Post by Narcís » Mon Sep 14, 2009 10:59 am

Hi Dinesh and Ronad,

Thanks for the example project. Now I understand which is the exact problem. You need to set bottom axis DateTime format as shown below, months being represented by MM as mm means minutes instead of months.

Code: Select all

			chart1.getAxes().getBottom().getLabels().setDateTimeFormat("dd-MM-yyyy hh:mm:ss");
Hope this helps!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply