LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How CVI graph divide X axis

Hi!
I need to label X-axis by Label Strings on Graph control. But I can't to determine the values near the axis divisions. Axis is divided in n+1 parts, and
n parts are equal to each other but the last part is not equal. Anybody know the algorithm of dividing
x-axis in autoscale mode ?
0 Kudos
Message 1 of 5
(3,618 Views)
The details of the algorithm are a little involved to get into here, but it is true that the gap between the minimum value and the first inner marker, as well as the gap between the maximum value and the second inner marker don't necessarily match the gaps between each pair of inner markers. The latter are all identical, but the other two can vary. This is done in order to display "round" numbers for the inner markers, even as the max and min might not be a "round" number. So, for example, if your axis range is (0.23, 0.92) you might end up with an axis containing the following values:

0.23, 0.40, 0.60, 0.80, 0.92

If your purpose is to have equal gaps throughout the axis, I have a couple of suggestions that you might want to try:

1. You can experiment with t
he ATTR_XLOOSE_FIT_AUTOSCALING and ATTR_XLOOSE_FIT_AUTOSCALING_UNIT attributes. In the example I gave above, you could use these attributes change the range of the axis, so that with the same plot data, you would end up with:

0.20, 0.40, 0.60, 0.80, 1.00

2. You can set the number of divisions manually. This entails setting the ATTR_XDIVISIONS attribute to a fixed number, n. When you do that, a side effect is that the gaps are all identical. So again, using the same example, if you set the number of divisions to 4, you would end up with:

0.2300, 0.4025, 0.5750, 0.7475, 0.9200

Hope this helps

Luis
NI
0 Kudos
Message 2 of 5
(3,618 Views)
Thank for answer, this can solve my problem.
But is it a way to know what labels are near
inner markers to relabel it ?
I have X-axis labelled in days (more than 1 month)and want to mark it in form day/month.
0 Kudos
Message 3 of 5
(3,618 Views)
I'm not sure I understand your question. When you define a label-value pair -- such as ("February",2) for example -- that label will be always be displayed as long as it is within the (max,min) range of the axis, and as long as it does not overlap another label. Is that what you are asking?

Or is it the case that you need to make sure that the markers are in the same location when you display labels as they were when you displayed values? For example, if the axis used to show:

1, 4, 7

then you want it to display exactly:

January, April, July

and not:

January February, March, April...

Is that you are asking? If so, then the only way you have of knowing exactly which markers will be displayed, and at which values, is by setting the
number of divisions to a fixed number. In this case, the value for marker i is always given by the following:

val(i) = min + i * (max - min) / n

where 'n' is the number of divisions, and 'i' is the marker index (with 'min' being the 0th marker)

By the way, the next version of CVI will have built-in time units in graph controls, so hopefully you won't have to go to these lengths much longer 🙂

Luis
0 Kudos
Message 4 of 5
(3,618 Views)
Thanks, I do as you suggest:
GetCtrlAttr -> actual x divisions
SetCtrlAttr -> x divisions
(because I need Auto x divisions)
And then relabel x-axis. Result are good enough.
0 Kudos
Message 5 of 5
(3,618 Views)