LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Set start and end value of a graph

Solved!
Go to solution

Hello,

 

I searched already for the topic but didn't find an answer. I'm a newby to LabWindows.

 

I write a application. For the application there is a graph that shows a signal, y-axis -> Voltage and x-axis -> time. As default the signal begins with the value 0 on the time axis. But my signal does not start with 0. I would like to change the start value and the end value of the axis manually. Does anyone know how this works (between auto scaling)?

 

I have also two x-axis in my graph. I set them with the offset (one at 10 V and one at -10V) but I would like to have two x-axis to start with the value 0 on different heights. Is there a way to implement that?

 

Best Regards

0 Kudos
Message 1 of 14
(5,389 Views)

Hi.

 

The function you're looking for is here: open the Library menu, pick User Interface, select Controls/Graphs/Strip Charts, then Graphs and Strip Charts, Axis Scaling, and SetAxisScalingMode (newer, mightier version of SetAxisRange) is the one.

-----------------------
/* Nothing past this point should fail if the code is working as intended */
0 Kudos
Message 2 of 14
(5,375 Views)

Regarding the first question, you could serach for an example called TimeDateunits.cws in <CVIsamplesDir>\userint folder: it shows how to format the X-axis in time units, both axolute and relative.

 

As per the second question, I don't understand what you are trying to do: you speak about the x-axis, which should be time, but also speack about voltage, so... can you post a drawing of what's your goal?



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?
0 Kudos
Message 3 of 14
(5,376 Views)

Hello,

 

thanks for the answers. 🙂

 

In the following I send you a image. I would like to have two signals with two x-axis. The time is the same by each signal but the amplitude not. Know I would like to show the seperate signals in the same graph. Each signal should have his own x-axis. The amplitude should alway begin by 0.

 

My solution at the moment is, that I plot the two signals in the graph and then set a offset. So I can seperate the signal. As for the example before the first signal starts a 10 V and the second signal at -10 V but I would like to have that both signal start at 0 V at there own x-axis.

 

Best Regards

 

 

0 Kudos
Message 4 of 14
(5,371 Views)

There isn't a native solution, you must be creative Smiley Wink

 

What about this solution?

Screenshot 2016-06-27 10.42.47.png

This is really three graph controls: two controls where to actually plot your signals, both with the border area painted in transparent, the upper one without labels on the Y-axis. A third graph, the leftmost one, is used only for the scale, with all other elements hidden of painted in transparent. This has the advantage to avoid shifting the plot.

 

Actually, your solution of plotting one signal shifted is a good one, but you have the problem of the vertical scale. One possible solution is to use label strings and build your own Y-scale, like in this example:

Screenshot 2016-06-27 10.49.31.png

The second plot in this case must be shifted by 70 units.



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?
0 Kudos
Message 5 of 14
(5,367 Views)

Thank you. I will be creativ! How can I change my graph to such an example of yours?

 

For the first question I have now a failure.

I implemented the solution before.

 

log = 0;
SetCtrlAttribute(panel,Panel_GRAPH_End,ATTR_XAXIS_GAIN,1/(double)SampleRate);
log = (int)log10(SampleRate);
SetCtrlAttribute(panel,Panel_GRAPH_End,ATTR_XPRECISION,log);

SetAxisRange (panelHandle, Panel_GRAPH_End, VAL_MANUAL, (double)BeginlastPeriod/SampleRate, Duration, VAL_MANUAL,
                      -22, 22);

 

But know I get only a straigt line. After this there is only this function:

 

PlotWaveform (panelHandle, Panel_GRAPH_End, Graph_A, SizelastPeriod, VAL_DOUBLE, 1.0, 10, 0.0, 1, VAL_THIN_STEP,
                          VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);

I think the failure is that my start value in this example would be 0.158 and the end value 0,198 and now the funktion does not know how to fill the gab between this values. Must I give a additonal option for this function?

Best Regards

0 Kudos
Message 6 of 14
(5,363 Views)

I'm a bit lost at this! I don't understand what you want to do and what is the goal of all your manipulating of axis gains and precision and so.

Would it be possible to summarize your scenario? I mean, how many signals you want to plot simultaneously, their amplitude (in V) and lenght (in time),...?

 

But trying to keep things simple: wouldn't simply plotting lines in different color be simpler? Or using two native, independent graphs stacked?



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?
0 Kudos
Message 7 of 14
(5,356 Views)

I have two signals that consists of more than one period (not identical periods). For the second signal I have schifted the phase.

 

So now I have two modes. In the first mode I see only the first period of both signals. For the second mode I see the first period in one graph and the last period in one graph of both signals (between are other periods). My client whats to see how the signal changes from the first period to the last period (Voltage and time). For the visualization it is better to see the first period and the last period, from these periods you can see the maximum change of the signal. The y-axis is the voltage, this amplitude is for both graphs the same. Here was the question to seperate both signals in a better way.

 

The other question had to do with the x-axis. The periods are not only different in voltages also in time. The first period starts alway with 0 to some values X. The last period starts with a value Y to the end value Z. Between this periods can be other periods. Y and Z are calculated.

So as example I have a signal that is 100 ms long.

The first period ist 10 ms, so in the first graph I see a signal from 0 -10 ms. The last period ist 30 ms long. Then I should see in the second graph a signal from 70 - 100 ms. But it does not work with the code I postet before.

 

Best Regards

 

 

0 Kudos
Message 8 of 14
(5,352 Views)

What I said about label strings can be applied to the time-axis also: you can build up an array of data that include the correct parts of the signal and a corresponding set of strings for X-axis labels. See Customizing Axis Labels in the control help and timeaxis.cws example



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?
0 Kudos
Message 9 of 14
(5,349 Views)

Ok thank you.

 

But I have still the problem that the signal gets not displayed correct. I always get a straight line.

I also tried with "SetAxisScalingMode" from the example you suggested.

 

 

0 Kudos
Message 10 of 14
(5,346 Views)