LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I Programatically Edit Graph Axis Label Strings??

Solved!
Go to solution

I'm using a graph control that has a Y axis with 8 equal divisions and axis label strings at each division.  I always want 8 equal divisions with label strings at those divisions, however, the maximum value on the graph may change (for example: 0, 10, 20, 30, 40, 50, 60, 70, 80  vs  0, 20, 40, 60, 80, 100, 120, 140, 160).  I can easily set this up through the gui editor.  I can then enable the Label Strings and set the strings to correspond to the values of my 8 divisions. 

 

However, if the maximum axis value is edited by the user (say from 80 to 160), is there any way to programattically modify the values that correpsond to the Axis Label Strings?  It's simple enough the edit the maximum axis value, but this only gets me half way there.

 

Thanks in advance!!

 

Oh, and I'm currently using CVI v8.1.

0 Kudos
Message 1 of 3
(3,357 Views)
Solution
Accepted by topic author byrd01

This is not a simple question!

On one hand, what do you intend to do if the user inputs, say, 125 as the maximum axis value? What about your divisions? And how you prevent the user from changing the minimum value as well?

On the other hand, I seem to remember there is not a specific event fired when the user changes the axis range.

 

I would suggest to put a separate button on the panel for changing the scale, have the use input the desired maximum value with PromptPopup or a similar way, adapt it to a reasonable value and apply it to the graph scale, letting the grpah calculate the value of its 8 divisions by itself.

 

Having said that, consider that the graph axis labels can be programmatically set using label strings: see here, topic "axis strings"; the same can be set at design time in the UIR editor. This can be an option if you decide to go a different way from the one I suggested.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 3
(3,355 Views)

@Roberto Bozzolo wrote:

This is not a simple question!

On one hand, what do you intend to do if the user inputs, say, 125 as the maximum axis value? What about your divisions? And how you prevent the user from changing the minimum value as well?

On the other hand, I seem to remember there is not a specific event fired when the user changes the axis range.

 

I would suggest to put a separate button on the panel for changing the scale, have the use input the desired maximum value with PromptPopup or a similar way, adapt it to a reasonable value and apply it to the graph scale, letting the grpah calculate the value of its 8 divisions by itself.

 

Having said that, consider that the graph axis labels can be programmatically set using label strings: see here, topic "axis strings"; the same can be set at design time in the UIR editor. This can be an option if you decide to go a different way from the one I suggested.


Roberto, Thanks so much for the reply!  It was exactly the info I was looking for. 

 

In the end, I'm not letting the user designate the maximum value of the chart.  The user simply selects the delta value between the divisions, and the maximum is computed based on that.  The minumum value is always 0, and there are always 8 divisions.  I'm actually using this to display 8 separate analog voltage channels on the same graph.  The nominal range of the measured voltage values may change, so the devisions on the graph are the biases that are used to offset each succeeding channel.

 

I've set up default axis label strings on the graph, and have a single numeric control for setting the value between divisions.  I'm using SetAxisScalingMode to set the new max value.  I'm then using the ReplaceAxisItem function to update the axis label strings with their new correpsoding values.  

 

Thanks again for the help!

 

0 Kudos
Message 3 of 3
(3,331 Views)