LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Labelling graph

Hi All,
 
I was wondering if someone can help me out with my problem. Well i have a graph that i plot using the PlotRectangle function......i hv a scale and depending on the data the bar shows accordingly...now i am tryin to display a label of that value so the min and max...so if strip is on x axis...want to show the value of the min and the max of the data that was plotted.
 
I would appreciate if someone can help me out.
 
Thanks
 
k1_ke
0 Kudos
Message 1 of 25
(5,155 Views)

If your goal is to display a text inside the plot area exactly near the max & min points PlotText is the function you need. You will need to define a metafont prior to using this function and pass its name to it in case you need fonts different from the predefined metafonts. X and Y coordinates are in terms of ATTR_ACTIVE_XAXIS and ACTIVE_YAXIS set for the graph, so that you must not struggle in coordinates translation.

Supposing XMin and Ymin are actual X and Y values in engineering units for the min of your plot, you can simply use

PlotText (panel, control, Xmin, Ymin, "The min value", VAL_APP_META_FONT, VAL_RED, VAL_TRANSPARENT);



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 2 of 25
(5,150 Views)

Hi Roberto,

Thank you very much for replying. Well i want to display the intial and final value that was plotted using the PlotRectangle function..attached is the picute of what i want to achieve.

Also i have want to print the panel....i used the PrintPanel option.....it also brings up the printer setup window bt doesnt print anythign when press ok....and the next time i try to run the program it crashes...say cannot load main panel as its not a uir file...its somehw changed to tui format...this happens only after i try to print the contents on the panel.

hope it helps

Thanks

k1_ke

 

0 Kudos
Message 3 of 25
(5,142 Views)

k1_ke, take a look at the attached sample for a solution on how to plot texts on your graph.

With regard to printing problems, I never had problems with PrintPanel command: I use it extensively to produce test reports with satisfactory results.

PrintPanel shows up the print dialog box only if the corresponding parameter is set in the command, otherwise not. The printout is normally produced on the selected printer if the dialog box is shown and on the default printer if not. Have you checked the return value from ParintPanel? It can return 3 types of values:
0: Success. No error found
<0: system error. Use GetGeneralErrorString to obtain an explanation of this error
>0: printing error. An explanation of this kind of error is given in the function help. You must design your own warning function in case you want to warn the operator with an explanation of these errors.

I can see no relation between PrintPanel and your UIR being corrupted so that the program is not able to start over again. This issue is probably due to other parts of your code.



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 4 of 25
(5,118 Views)

Hi Roberto,

Thank you for the reply. It worked out great and i was able to understand hw it worked.

Now regarding the printing the panel....below is the callback for it...everytime i click on print.....the printer setup window pops up...i choose the printer n stuff..press ok....everythign wrks fine...i can do anything on my uir....bt yet that panel hasnt printed...then i quit my uir....but the next time i load it up......it crashes in the main loop when i try to load main.uir....it says this file is tui and not .uir.....am i doing something wrong while trying to print? i checked for error msg after the printpanel...it returned 0.

int CVICALLBACK PrintCallback (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
 switch (event)
 {
  case EVENT_COMMIT:
   PrintPanel (panelhandle, "main.uir", VAL_VISIBLE_AREA,VAL_VISIBLE_AREA, 1);
   break;
 }
 return 0;
}

Hope to hear from you soon.

Thanks

k1_ke

0 Kudos
Message 5 of 25
(5,109 Views)

@k1_ke wrote:

   PrintPanel (panelhandle, "main.uir", VAL_VISIBLE_AREA,VAL_VISIBLE_AREA, 1);


The second parameter in PrintPanel is the name of an (optional) output file; according to the help for this field:
 
If the name is not empty, the output is redirected to the file.

That is: to actually print to a printer, leave this field empty. If you fill this field, the function will create a printer file with the name you put in the field. With your code, you are effectively overwriting your UIR file with the print file from this function. If I'm not wrong, the printer file  is intended to be printed in a second time with a simple "Copy" to the printer.


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 6 of 25
(5,110 Views)

Hi Roberto,

Thank you so much. I need to start paying more attention to the fine prints! It worked great!

Ok now i have another question, my next task is to display i live signal which i will b receiving via rs232 onto a graph. i basically i was goin to keep reading the serial port and plot......is it possible for me to use plotline() or what should i use?? or if there any is another better suggestion do let me know..

Thanks for you help!

k1_ke

0 Kudos
Message 7 of 25
(5,103 Views)

Dependng on your decisions you can do two ways:

1. Acquire all of your data and use PlotXY: this is comfortable for short phenomena

2. For slow and long-lasting processes, acquire a point and PlotLine from (xold, yold) to (xnew, ynew). the "old" values are those obtained in previous step: they must be static variables so that they survive from one iteration to the next; at every iteration you must copy "new" values to "old" values after plotting

Or, if you want to plot in time and you are relatively constant in acquisition, you can think to use a strip chart instead of a graph: with strip charts you simply need to add every single value to the chart and it will be automatically connected to previous ones.



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 8 of 25
(5,093 Views)

Thanks Roberto for helping me out yet again. I really appreciate you taking the time to solve my problem quick!

Well i have to plot it in real time and display it as the data is coming...as its a video feed signal....i was looking into the strip chart but the max on x axis is 10000...i need to display around 32000.....is there any way i can still use it? Also if so its goin to be easier as i dont hv to worry abt the new and previous values if using plotline().

Plot XY() is out of the question as i need to display as the data is coming....cant wait until i receive all the data

Lets see hw it goes.

thanks

k1_ke

0 Kudos
Message 9 of 25
(5,088 Views)

I don't think the 10k limit of the strip chart can be overcome, so it seems that a graph and PlotLine is the only solution to your problem.

But let's try to consider the situation on another point of view.

32k points are **a lot** of measures to display on a screen. How large is your screen resolution? 1024? 1280 pixels? something more? It's still a fraction of the number of point to be displayed. What I am saying is that a lot of your points shares the same pixel along the X axis. Supposing the phenomenon you are plotting is not heavily varying along the Y axis, it is very possible that you can plot only 1 point every 3 or 4 acquired without loosing the visible aspect of the diagram on screen. You must store all measures on disk so that in case of need you can reload them from it and display a part of the process in full detail, but in ordinary situation you can simplify your application to a limit that can find place on a strip chart.

This same consideration could be applied if using a graph. Moreover, you could use two different controls (two strip charts) to display the process being observed: one strip chart updated at maximum detail and showing only last 500 or 1000 measures, the other strip chart (or graph) updated every 10 measures and displaying the whole process.



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 10 of 25
(5,084 Views)