LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

PlotXY: getting an error

Solved!
Go to solution

I'm trying to PlotXY in CVI. I have a graph on the second tab page of my panel, the graph have constant name "GRAPH_SPECTRUM". Here is the test code:

 

int plotHandle;
double x[100], y[100];

for (i = 0; i < 100; i++)
{

x[i] = 1.00 * i;
y[i] = 0.1 * i * i;            // let's try a simple parabola

}

GetPanelHandleFromTabPage (panelHandle, PANEL_TAB, PAGE_TWO, &Tab2PanelHandle);

plotHandle = PlotXY (Tab2PanelHandle, TABPANEL_2_GRAPH_SPECTRUM, x, y, 100, VAL_DOUBLE, VAL_DOUBLE, VAL_FAT_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);

 

I'm getting an error "Function PlotXY: The control is not the type expected by the function"

Could anyone help please?

 

0 Kudos
Message 1 of 4
(2,487 Views)

I think the problem is in the controlID. If I create the graph by NewCtrl and use the return value as the controlID for the PlotXY then it works. But if I use a controlID of the graph defined in the GUI .h then it does not work and gives that error. Looks like a bug?

0 Kudos
Message 2 of 4
(2,464 Views)

A problem could be the value of PAGE_TWO macro: GetPanelHandleFromTabPage wants a zero-based index of the page to address, so unless PAGE_TWO = 1 you are getting the handle of the wrong tab page; you get the error since you are addressing a control which appears not to be a graph.

In which page does the dynamically created graph appear?



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 4
(2,449 Views)
Solution
Accepted by topic author eno7538

Thanks for the help, Roberto. I have other controls on the second page and they work fine:

SetCtrlVal(Tab2PanelHandle, TABPANEL_2_SCAN_NUMBER, 0);

 

Anyway, I did a workaround by creating the graph programmatically and it now works fine:

GetPanelHandleFromTabPage (panelHandle, PANEL_TAB, PAGE_TWO, &Tab2PanelHandle);
graphCtrl = NewCtrl (Tab2PanelHandle, CTRL_GRAPH_LS, "", 10, 200); 

SetCtrlAttribute (Tab2PanelHandle, graphCtrl, ATTR_HEIGHT, 550);

and so on…………..

0 Kudos
Message 4 of 4
(2,441 Views)