09-04-2014 06:18 AM
I work on CVI2012SP1 and I´m having some trouble with the graph control.
As the stripchart control does make to much trouble for me I went with the graph control to display a moving chart. This works much more painless than with the stripchart, but now I got another problem with drawing the plots.
I´m deleting all plots and then adding new ones. Then I call RefreshGraph() and the new plot is drawn, but also is the old plot (see the screenshot)!? If I resize the graph only the current plot is drawn.
Why is this so? Is this a bug? How can I work around it?
Solved! Go to Solution.
09-04-2014 06:27 AM
What should we learn from your (nice) graphs - it would be more useful if you could provide a short piece of code showing the problem, allowing us to reproduce it.
09-04-2014 07:46 AM
Sorry, I don´t have a short piece of code for the problem. The problem is that all old plots, which where deleted by the DeleteGraphPlot function, are still drawn when I select "VAL_DELAYED_DRAW".
But I found a solution, I just have to select "VAL_IMMEDIATE_DRAW" for DeleteGraphPlot and it works as expected.
09-04-2014 08:28 AM
Good for you that it is working
...but your description does not fit to the expected behavior: calling RefreshGraph() should remove any plots from screen that were deleted using DeleteGraphPlot in delayed draw mode.
09-05-2014 07:12 AM - edited 09-05-2014 07:13 AM
...but your description does not fit to the expected behavior: calling RefreshGraph() should remove any plots from screen that were deleted using DeleteGraphPlot in delayed draw mode.
Yeah, I also think so.
To test you could create a graph, initialize a buffer with the y-values of a sinus function and do the following all 10 seconds or so:
This is what I´m doing and there the old and deleted plots are still drawn (when VAL_DELAYED_DRAW is selected) till the graph is resized.
09-05-2014 07:29 AM
I would assume that this is because you modify your data before refreshing the graph - all that RefreshGraph knows is the plot handle (and from this it has to derive the plotted data), so if you use the same plot handle for different data sets it can not work...
09-08-2014 03:16 AM
I don´t know if I understood you right.
This is a stripped down example of the code I use:
// Graph nicht zeichnen SetCtrlAttribute(panel->panelHandle,g_scGraphControlIds[CTRL_GRAPH_CHART],ATTR_REFRESH_GRAPH,0); // alte Plots entfernen DeleteGraphPlot(panel->panelHandle,g_scGraphControlIds[CTRL_GRAPH_CHART],-1,VAL_IMMEDIATE_DRAW); // aktive Y- Achse setzen SetCtrlAttribute(panel->panelHandle,g_scGraphControlIds[CTRL_GRAPH_CHART],ATTR_ACTIVE_YAXIS,VAL_RIGHT_YAXIS); // Plots eintragen for(int sensor = 0; sensor < 8; sensor++) { int colorTrace; int colorMinMax; // Farben festlegen if(panel->showTrace[sensor]) { colorTrace = g_GraphTraceColors[sensor]; if(panel->showMinMax[sensor]) { colorMinMax = g_GraphTraceColors[sensor]; } else { colorMinMax = VAL_TRANSPARENT; } } else { colorTrace = VAL_TRANSPARENT; colorMinMax = VAL_TRANSPARENT; } // Value Plot zeichnen panel->plotHandle[sensor * 3] = PlotXY(panel->panelHandle,g_scGraphControlIds[CTRL_GRAPH_CHART],g_sGraphXBuffer,valueBuffer[sensor],numPointsChart,VAL_INTEGER,VAL_DOUBLE,g_GraphLineThickness,VAL_NO_POINT,VAL_SOLID,1,colorTrace); // Min Plot zeichnen panel->plotHandle[sensor * 3 + 1] = PlotXY(panel->panelHandle,g_scGraphControlIds[CTRL_GRAPH_CHART],g_sGraphXBuffer,minBuffer[sensor],numPointsChart,VAL_INTEGER,VAL_DOUBLE,g_GraphLineThickness,VAL_NO_POINT,VAL_SOLID,1,colorMinMax); // Max Plot zeichnen panel->plotHandle[sensor * 3 + 2] = PlotXY(panel->panelHandle,g_scGraphControlIds[CTRL_GRAPH_CHART],g_sGraphXBuffer,maxBuffer[sensor],numPointsChart,VAL_INTEGER,VAL_DOUBLE,g_GraphLineThickness,VAL_NO_POINT,VAL_SOLID,1,colorMinMax); } // Graph zeichnen SetCtrlAttribute(panel->panelHandle,g_scGraphControlIds[CTRL_GRAPH_CHART],ATTR_REFRESH_GRAPH,1); RefreshGraph(panel->panelHandle,g_scGraphControlIds[CTRL_GRAPH_CHART]);
As said, if I replace the "VAL_IMMEDIATE_DRAW" with "VAL_DELAYED_DRAW" the old plots are drawn until I resize teh graph.
As I see it, I´m not reusing the plot handles, but getting new ones for every change (of the data) I make.
09-08-2014 08:03 AM
The problem does not occure if I make the graph invisible, delete the old plots, add the new plots and then make it visible again. This also solves my flickering problem.
09-09-2014 06:39 AM
Well, the documentation does not elaborate when the plot handles are 'freed', when calling DeleteGraphPlot or when the graph is refreshed (I would have assumed the latter). But then in my understanding it should not depend on the visibility of the graph. And if the plot handles are 'freed' right after calling DeleteGraphPlot then it should not depend on the refresh mode... maybe someone from NI will join in and help...
09-11-2014 01:50 AM
So I tried to make a simple version for this problem and what can I say, I can´t reproduce the problem in the simple version.
When I got time I need to try to reproduce the problem with my project.