Jump to content

How do I create fixed X-Axis intervals using Chart Properties?


hova2010

Recommended Posts

Here is my application...

I have data acquisition system that acquires a data point once every 4 seconds.

My Waveform Chart accurately displays my data points on the Y- axis.

What Im trying to do is format the X-axis to show the user an accurate time stamp. I have 3 charts....by minute, by hour, by week.

I would like to show the 1min chart X-axis in real 1minute intervals...starting from the start of the application

I would like to show the 1hr chart X-axis in 1 hour intervals

I would like to show the 1 chart graph X-axis in 1 week intervals.

I want to use the chart properties i.e. XScale-Multiplier, XScale-Offset, XScale- Minimum, XScale-Maximum

How do I use the properties to build the X-Axis for each chart?

~J

Link to comment

Here is my attempt at the Waveform Graph

Im trying to set 1 min intervals on the X-axis

I will have 3 pieces of data average, std deviation, and Time

My 1min intervals are not being set by the graph properly

Any reason why?

Jjh_waveform attempt1.vi

J,

They're not being set properly because you are stripping the time info by combining the waveform into the array of random numbers. The waveform is being cast to just data without any timing info. Your net result is you have a 3 element array with no timing info, so on the graph it just shows 12/31/1903 (default "0" time for LabVIEW) and never increases.

I'm attaching a reworked VI that shows the progression of going from A) where your're trying to start from to B) where I think you're wanting to go.

It has 2 loops in it. Loop 1 is where you were trying to start but getting confused. Loop 2 is a rudimentary implementation of what I believe you want. I have included comments in the VI to help you out a little.

Digest that for a bit and see if that helps and what additional questions it prompts.

-Scott

As an aside defualt "0" time in LabVIEW is actually 12:00:00 AM 1/1/1904 UTC, but your time may be a little different based on your time zone.

jh_waveform_rework.vi

Link to comment

J,

They're not being set properly because you are stripping the time info by combining the waveform into the array of random numbers. The waveform is being cast to just data without any timing info. Your net result is you have a 3 element array with no timing info, so on the graph it just shows 12/31/1903 (default "0" time for LabVIEW) and never increases.

I'm attaching a reworked VI that shows the progression of going from A) where your're trying to start from to B) where I think you're wanting to go.

It has 2 loops in it. Loop 1 is where you were trying to start but getting confused. Loop 2 is a rudimentary implementation of what I believe you want. I have included comments in the VI to help you out a little.

Digest that for a bit and see if that helps and what additional questions it prompts.

-Scott

As an aside defualt "0" time in LabVIEW is actually 12:00:00 AM 1/1/1904 UTC, but your time may be a little different based on your time zone.

Hello Scott

this is getting closer...what I really want is the 4s data points to move across the graph while the Time intervals on the X-Axis remain fixed.

Example : If my scan rate is 4s/ sec, the 15th data point should always cross a 1min interval line on the graph in real time.....

So the X-axis may be like this 2:00pm 2:01pm, 2:02pm 2:03pm, etc and the 15 th data point should always match up with a 1min marker

I hope Im explaining this better...

J

Link to comment

Hello Scott

this is getting closer...what I really want is the 4s data points to move across the graph while the Time intervals on the X-Axis remain fixed.

Example : If my scan rate is 4s/ sec, the 15th data point should always cross a 1min interval line on the graph in real time.....

So the X-axis may be like this 2:00pm 2:01pm, 2:02pm 2:03pm, etc and the 15 th data point should always match up with a 1min marker

I hope Im explaining this better...

J

Here is a picture of my Waveform Chart Im currently using...all I need is 1min intervals on the X axis.

And the 1min intervals should be crossed in real time about every 15th data point

(since my scan rate is 1 sample/ 4sec)

thanks

J

post-16518-125545724692_thumb.jpg

Link to comment

So the X-axis may be like this 2:00pm 2:01pm, 2:02pm 2:03pm, etc and the 15 th data point should always match up with a 1min marker

Here is a picture of my Waveform Chart Im currently using...all I need is 1min intervals on the X axis.

And the 1min intervals should be crossed in real time about every 15th data point

(since my scan rate is 1 sample/ 4sec)

I don't agree with your statements or I'm reading too much into them. I think we need to establish whether you are wanting to use relative time or absolute time on your x-axis. Using "2:00pm, 2:01pm, etc." in your first post makes me think you want absolute time. But the general statements that every 15th point should match up with a 1 minute marker make me think relative time.

1) If you use absolute time, every 15th point (starting from 0) will not necessarily cross a 1 min mark. It all depends on when you get your first point. If your first point is at 2:00:16pm then the 15th point will be at 2:01:16pm. The 11th, 26th, 41st, and every subsequent 15 points will cross at 1 min marks.

2) If you use relative time, then every 15th point (0th, 15th, 30th, etc.) will fall on a minute marker, but you won't have the actual time of day on the axis. It will just be elapsed time from the start of your app.

I'm going to assume you want #1 and that I'm just being obtuse and reading too much into your description. I've attached an example that will show this with a waveform graph. Again, for me, charts are too finnicky and limiting to deal with, at least in this instance.

Let me know if this gets you closer still...

-Scott

waveform_graph_markers.vi

Link to comment

I don't agree with your statements or I'm reading too much into them. I think we need to establish whether you are wanting to use relative time or absolute time on your x-axis. Using "2:00pm, 2:01pm, etc." in your first post makes me think you want absolute time. But the general statements that every 15th point should match up with a 1 minute marker make me think relative time.

1) If you use absolute time, every 15th point (starting from 0) will not necessarily cross a 1 min mark. It all depends on when you get your first point. If your first point is at 2:00:16pm then the 15th point will be at 2:01:16pm. The 11th, 26th, 41st, and every subsequent 15 points will cross at 1 min marks.

2) If you use relative time, then every 15th point (0th, 15th, 30th, etc.) will fall on a minute marker, but you won't have the actual time of day on the axis. It will just be elapsed time from the start of your app.

I'm going to assume you want #1 and that I'm just being obtuse and reading too much into your description. I've attached an example that will show this with a waveform graph. Again, for me, charts are too finnicky and limiting to deal with, at least in this instance.

Let me know if this gets you closer still...

-Scott

Thanks Scott

This seems to be what I was looking for! Yes, of course, each minute is designated from the absolute time of the previous minute (or start minute)... 2:01pm 2:02pm were just for illustration purposes.

Will your graph continue to scroll to the right as the data & time fill the first page?

I will need the X scale markers to continue indefinitely until the test is manually stopped.

Thanks

J

Link to comment

Can the same concept be used for a Waveform Chart?

I tried to get it to work with a Chart, but it not going well ...

Can you tell me what Im doing wrong?

You can try it with a chart, but you need to link the property node to the chart and not the graph. You also can't bundle the two values (timestamp and random data) like you are doing for the chart. That will give you two plots, not one plot with timing info. If you want the timing info for your data, you need to use a waveform.

Will your graph continue to scroll to the right as the data & time fill the first page?

I will need the X scale markers to continue indefinitely until the test is manually stopped.

No, the data won't continue to scroll after you reach the end of the graph. We've set up a fixed time axis, so when the # of points passes that fixed scale, the new data will no longer appear. The data is still there, of course; you just can't see it. If you change the end time on the scale or turn on autoscaling, you'll be able to see the data.

To get a fixed time window to scroll, you'll need to manage that programmatically. I can work up an example for you, but I encourage you to continune to play around with it and see if you can get it to work. If you can figure out the how and why it all works on your own, you'll be in a much better position to adapt it in the future.

If you can't get what you want by the end of the day, post back with what you have and we'll work up some more solutions.

-Scott

Link to comment

J,

There are two problems with the example code:

1) The major problem is you were running at a faster loop rate (generating simulated data) than the actual time was changing, Therefore the chart was scrolling faster than new marker lines were being added. The modified VI below adds some "simulated time" to account for this. If you ran your original at a normal rate, it would look to work ok.

2) You keep adding data to the markers array, but it is mostlyd uplicate data. You are growing a larger and larger array. Eventually, all this array data and large marker list will at some point start to hurt the performance of your app. I have modified it to only add a new marker when it doesn't already exist in the list. This marker array will still grow unlimited, but at least it won't have duplicate data. You could further modify it it to have a limited number of markers in the array, say 60, by removing old markers when adding new markers.

-Scott

JH_waveform_graph_markers_update.vi

Link to comment

J,

There are two problems with the example code:

1) The major problem is you were running at a faster loop rate (generating simulated data) than the actual time was changing, Therefore the chart was scrolling faster than new marker lines were being added. The modified VI below adds some "simulated time" to account for this. If you ran your original at a normal rate, it would look to work ok.

2) You keep adding data to the markers array, but it is mostlyd uplicate data. You are growing a larger and larger array. Eventually, all this array data and large marker list will at some point start to hurt the performance of your app. I have modified it to only add a new marker when it doesn't already exist in the list. This marker array will still grow unlimited, but at least it won't have duplicate data. You could further modify it it to have a limited number of markers in the array, say 60, by removing old markers when adding new markers.

-Scott

Hey Scott

I couldnt open that last example, Im using 8.5.1

Also this new code I wrote doesnt work with a Waveform Chart, but it works with your Waveform Graph.

I tried to modify your code to give me a 3 hour time span on the X-axis with 1 hr markers.

Do you know why it works correctly in the Graph but not the Chart?

J

Link to comment

I couldnt open that last example, Im using 8.5.1

Sorry, here it is in 8.5

Also this new code I wrote doesnt work with a Waveform Chart, but it works with your Waveform Graph.

I tried to modify your code to give me a 3 hour time span on the X-axis with 1 hr markers.

Do you know why it works correctly in the Graph but not the Chart?

Did you intend to post an attached VI? If so, it's missing.

JH_waveform_graph_markers_update.vi

Link to comment

Charts have a limited history buffer in terms of points. Right click the chart and choose Chart History Length... to change it.

This allows you to set the max points the chart will hold before throwing away old data. It also enforces a relationship between scale min and max. The default is 1024 points. When using time as a scale, a second equates to 1 point (unless you change the Scale setting, similar to offest). 1024/60 = ~17 minutes.

Try setting it to 11000 and you should get better results.

Link to comment

2 Question Scott:

1) The 1st picture is from your VI ,"JH_waveform_graph_markers[1].vi

I have circled the divisor, "60" in the picture.

Should this number, 60, be changed based on whether Im using markers for minutes, hours, or days?

I have the divisor set at "60" for my minute chart, "3600" for my hour interval chart and "86400" for my day interval chart

Would these numbers be correct? (see "Waveform Chart Grid Markers.JPG")

2) Using "3600" for hour interval and "86400" for the week chart, Im getting "some extra grid markers" on these charts... (see "waveform chart_extra grid lines.JPG")

Can you tell me why?

thanks

J

post-16518-125597856811_thumb.jpg

post-16518-125597861764_thumb.jpg

Link to comment

2 Questions Scott:

1) The 1st picture is from your VI ,"JH_waveform_graph_markers[1].vi

I have circled the divisor, "60" in the picture.

Should this number, 60, be changed based on whether Im using markers for minutes, hours, or days?

I have the divisor set at "60" for my minute chart, "3600" for my hour interval chart and "86400" for my day interval chart

Would these numbers be correct? (see "Waveform Chart Grid Markers.JPG")

2) Using "3600" for hour interval and "86400" for the week chart, Im getting "some extra grid markers" on these charts... (see "waveform chart_extra grid lines.JPG")

Can you tell me why?

thanks

J

My entire grid marker code is attached...

post-16518-125599006476_thumb.jpg

Link to comment

1) The 1st picture is from your VI ,"JH_waveform_graph_markers[1].vi

I have circled the divisor, "60" in the picture.

Should this number, 60, be changed based on whether Im using markers for minutes, hours, or days?

I have the divisor set at "60" for my minute chart, "3600" for my hour interval chart and "86400" for my day interval chart

Would these numbers be correct? (see "Waveform Chart Grid Markers.JPG")

2) Using "3600" for hour interval and "86400" for the week chart, Im getting "some extra grid markers" on these charts... (see "waveform chart_extra grid lines.JPG")

Can you tell me why?

J,

1) Yes, those numbers are correct.

2) No, I really don't know why. I see it on the wavefrom graph as well. It is probably some minor bug or anomaly in the graph/chart drawing code. If it bothers you enough, turn off the minor grid for the x scale.

The code looks correct. Remember, to keep gettting new markers you need to add to the list and take off the older markers. I can't really tell if that's what you're doing off to the right.

-Scott

Link to comment

I knocked up a quick version of what I was talking about earlier about creating "views" of logged data. If you were to use it you would still need to figure out how to get "Month" data in properly and slide the scale (don't want to do all your work :) )

But should give you an idea.

  • Like 1
Link to comment

I knocked up a quick version of what I was talking about earlier about creating "views" of logged data. If you were to use it you would still need to figure out how to get "Month" data in properly and slide the scale (don't want to do all your work :) )

But should give you an idea.

Is anyone able to save this to a previous version other than 8.6 for the OP?

Both LV x32 and x64 crash if I try to save below 8.6.

Link to comment

Nope. No luck. I even tried rewriting portions of it to see if could get it to save. Crashes every time.

Sorry...

Me too. I even deleted bits until I had just an event case left.....still crashed when trying to save.

Victory!

One point to the man with the magic digits. The secret?

Edited by ShaunR
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.