08-30-2017 05:48 AM
I am attempting to draw legends based on a variable number of plots. I use LGInsertLegendItemForPlot. When I draw the legend for a single plot, no problem. It draws the plot description ("buffer" in LGInsertLegendItemForPlot) and it draws the plot legend (i.e 4 data points using, say, crosses, with the correct colour, mimicking the actual plot). When I want to show two legends (two plots/plothandles) it does the same but the two descriptions are on top of one another. The plot legends are not on top of one another but below one another, as expected. I played around with the "position" variable but this does not seem to make any difference. Any suggestions?
Regards and thanks
Erik
08-30-2017 06:05 AM
Hi,
...where did you find this function?
OK, let's assume it exists, what are your height parameters, and what is auto size set to?
What happens if you use SetCtrlAttribute (panelHandle, graphCtrl, ATTR_LEGEND_AUTO_SIZE, 1); ?
08-30-2017 06:17 AM
Good day
This function is part of the legend.fp instrument driver functions. According to "Help" the toolbox.fp is also required, which is included in the project. I tried your suggestion (ATTR_LEGEND_AUTO_SIZE) but that does not make a difference. Irrespective of that one can see in the graph legend control that it increases in size when 0, 1 or 2 legends are to be shown (height increases).
Erik
08-30-2017 06:49 AM - edited 08-30-2017 06:50 AM
Hello, the legend control is a very old instrument that has been superseded in CVI7.0 with the introduction of graph controls with built-in legend; it remains in recent installs basically for backward compatibility. See this discussion and the other one linked there for reference.
If you are using a newer version of CVI I suggest you to move to built-in legends, basically created by means of some attributes to be passed to SetPlotAttribute. You may also take a look at userint\graphlegend.cws example
08-30-2017 06:49 AM
08-30-2017 07:01 AM
The software was probably first written with CVI 5.0 and I think that legend.fp was probably copied and pasted as the software (and CVI) was updated. We are currently using CVI 2012 so it is very possible that you are correct. I am now going to rewrite it using the newer functions as per your suggestion and do away with the old instrument driver. Thanks very much for your help. Greatly appreciated.
Erik