Passing date & time data using DPLOT api

Q&A for C, C++, and/or C# developers using DPlot
Post Reply
khan
Posts: 2
Joined: Fri Jun 16, 2006 6:05 am

Passing date & time data using DPLOT api

Post by khan »

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?
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

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.
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.
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
khan
Posts: 2
Joined: Fri Jun 16, 2006 6:05 am

Post by khan »

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! :-)

Many thanks,
khan
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

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.
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.
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: Select all

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
sasha
Posts: 1
Joined: Tue Mar 20, 2007 10:39 am

Display date/time on the x-axis

Post by sasha »

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
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

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
Post Reply