Page 1 of 1
Issue with plotting datetime series
Posted: Wed Sep 09, 2009 2:53 pm
by 8440512
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.
Re: Issue with plotting datetime series
Posted: Wed Sep 09, 2009 3:09 pm
by narcis
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.
Re: Issue with plotting datetime series
Posted: Thu Sep 10, 2009 5:00 am
by 8440512
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.
Re: Issue with plotting datetime series
Posted: Thu Sep 10, 2009 10:22 am
by narcis
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!
Re: Issue with plotting datetime series
Posted: Thu Sep 10, 2009 1:06 pm
by 8440512
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.
Re: Issue with plotting datetime series
Posted: Thu Sep 10, 2009 2:32 pm
by narcis
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.
Re: Issue with plotting datetime series
Posted: Fri Sep 11, 2009 7:10 am
by 8440512
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.
Re: Issue with plotting datetime series
Posted: Mon Sep 14, 2009 10:59 am
by narcis
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!