DPlot Forum Index DPlot
http://www.dplot.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Passing date & time data using DPLOT api

 
Post new topic   Reply to topic    DPlot Forum Index -> C, C++, C#
View previous topic :: View next topic  
Author Message
khan



Joined: 16 Jun 2006
Posts: 2

PostPosted: Fri Jun 16, 2006 6:14 am    Post subject: Passing date & time data using DPLOT api Reply with quote

I have a very simple tool that uses DPLOT to view Windows Perfmon data for viewing memory usage and CPU profiles. The data is timestamped and recorded in the format MMDDYYYY HHMMSS.SSS - example:
06/15/2006 10:43:05.598.
1. What is the preferred way to convert this data into a type that the DPLOT API will accept and understand. Presently, my X axis data increments in steps of 1, but now I'd like to include the timestamps as well. Note - this is not Excel formatted time (though I'm not sure if Perfmon uses a different style). I don't really need the millisecond resolution though.
2. Are there any plans to update the API to accept arrays of strings?
3. Are there any plans to update the API to plot a graph straight from a CSV file with two columns e.g. time, data?
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Fri Jun 16, 2006 9:21 am    Post subject: Reply with quote

Quote:
1. What is the preferred way to convert this data into a type that the DPLOT API will accept and understand. Presently, my X axis data increments in steps of 1, but now I'd like to include the timestamps as well. Note - this is not Excel formatted time (though I'm not sure if Perfmon uses a different style). I don't really need the millisecond resolution though.


I'm not sure I understand your question. If you want to pass your data to DPlot through one of the DPLOTLIB functions, you'll first need to translate your date text to doubles. See the "Data Types" topic in the DPLOTLIB documentation for converting dates. Time would then be added on as a fractional part of the day: 0=midnight, 0.5=noon, etc.

But if you simply want to open a file containing dates and times or paste data from the clipboard, DPlot should handle that correctly now. If you have an example that doesn't work as expected please let me know.

Quote:
2. Are there any plans to update the API to accept arrays of strings?


To be used as labels? I hadn't considered it. You can add individual labels with a TextPointLabel command. I'll think about adding another function to take an array of labels.

Quote:
3. Are there any plans to update the API to plot a graph straight from a CSV file with two columns e.g. time, data?


Again, that should work now. If you have a CSV file that does NOT work properly with DPlot please send me a copy.
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
khan



Joined: 16 Jun 2006
Posts: 2

PostPosted: Fri Jun 16, 2006 9:51 am    Post subject: Reply with quote

Thanks for responding - but I think I've been misunderstood. I don't want to use the DPLOT GUI to edit the graph (i.e. views, labels, etc).
I would like to programmatically pass data using the DPLOTLIB api - and have it generate the graph for me. These are the APIs available to me:
int __stdcall DPlot_Plot(DPLOT *DPlot, float *x, float *y, LPSTR commands);
int __stdcall DPlot_Plot8(DPLOT *DPlot, double *x, double *y, LPSTR commands);
int __stdcall DPlot_Plot8p(DPLOT *DPlot, DWORD *px, DWORD *py, LPSTR commands);
HBITMAP __stdcall DPlot_PlotBitmap(DPLOT *DPlot, float *x, float *y, LPSTR commands, int cx, int cy);
HBITMAP __stdcall DPlot_PlotBitmap8(DPLOT *DPlot, double *x, double *y, LPSTR commands, int cx, int cy);
int __stdcall DPlot_PlotToRect(DPLOT *DPlot, float *x, float *y, LPSTR commands, HWND hwnd, RECT *rc);
int __stdcall DPlot_PlotToRect8(DPLOT *DPlot, double *x, double *y, LPSTR commands, HWND hwnd, RECT *rc);

All the data parameters input are either floats or doubles. This is fine - but it would be nice to have a similar API for example:
1. Pass in a FILE handle (or fully qualified filename)
2. Have the X axis data take in an array of strings, for example (time and date strings), for example:
int __stdcall DPlot_Plot8(DPLOT *DPlot, char**x, double*y, LPSTR commands) where char** is an array of strings as data for the X axis
3. Better describe in detail how dplot api handles date and time. I was unable to find the info I needed, could you please send me the link if there is one?

The reason I'd like to do this is so that I can drag-and-drop multiple files onto my tool (which is a simple command console). The tool parses each file in turn, collects all the X,Y (datetime, double) data, and then pipes it to dplot, where the graph is displayed.
Note: I use DPlot Junior, the free version...

The full DPLOT version does handle CSV files very nicely, but my trial period has expired. I use the free version for personal projects. I think the APIs are quite helpful and very useful - thanks! Smile

Many thanks,
khan
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Fri Jun 16, 2006 10:22 am    Post subject: Reply with quote

Quote:
1. Pass in a FILE handle (or fully qualified filename)


With the full version you can do this with

DPlot_Command(docnum,"[FileOpen(\"filename\")]");

but this will not work with DPlot Jr, which will not open files. That omission is intentional and won't be changed.

Quote:
2. Have the X axis data take in an array of strings, for example (time and date strings), for example:
int __stdcall DPlot_Plot8(DPLOT *DPlot, char**x, double*y, LPSTR commands) where char** is an array of strings as data for the X axis


That's a good suggestion that I'll make an effort at. I can't promise a release date, though.

Quote:
3. Better describe in detail how dplot api handles date and time. I was unable to find the info I needed, could you please send me the link if there is one?


You should have a \docs folder below DPlot Jr that contains the DPLOTLIB documentation. From the index page if you click "Data Types" and scroll to the bottom of the page you'll see:

Code:
if( Month > 2 )
    serial=(int)(365.25*year)+(int)(30.6001*(month+1))+day-694037;
else
    serial=(int)(365.25*(year-1))+(int)(30.6001*(month+13))+day-694037;


where year, month, day, and the return value "serial" are integers.
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sasha



Joined: 20 Mar 2007
Posts: 1

PostPosted: Tue Mar 20, 2007 10:45 am    Post subject: Display date/time on the x-axis Reply with quote

My plot needs to have time on the x-axis. I have created a plot using DPlot_Plot8() which requires two arrays of double for x and y. I can convert my date/time stamps to double using the method suggested in the Data Types section of the DPLOTLIB User's Guide, but the x-axis now displays labels as 39160.57. I'd like the x-axis to display the date/time as 'dd/mm/yy hh:mm:ss'. Is this posible? How would I do this?

Thanks
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Tue Mar 20, 2007 11:31 am    Post subject: Reply with quote

Add a command to the DPlot_Plot8 call or subsequently call DPlot_Command with:

[NumberFormat(0,13)]

That's for date and time. For other number formats search for NumberFormat in the Help file.
_________________
Visualize Your Data
support@dplot.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    DPlot Forum Index -> C, C++, C# All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group