06-20-2023 07:12 PM
Hello,
I am plotting multiple curves on a 2D Axis System in Report, and want to show the maximum of each X-channel in the legend.
For the Y-channel, I am able to accomplish this by assigning the following to the legend column text (it works):
"@@Str(Data.GetChannel(CurrChnNo).Properties(""maximum"").Value, ""AutoAdj"")@@"
However, for the X-channel, I try to get the same result with the following (it doesn't work):
"@@Str(Data.GetChannel(""[@@CurrGroupIdx@@]/[@@CurrXChnIdx@@]"").Properties(""maximum"").Value, ""AutoAdj"")@@"
The logfile outputs the following error:
If I run the expressions shown in the error on their own within the script, I get a result. Not sure why it won't work in Report.
Any help would be appreciated!
06-21-2023 02:16 AM
To access properties of the X channel in the legend of the layout, the variable CurrXChnReference can be used in the expression. With the following line, I could display the maximum of X in my REPORT layout, where the X channel is a numeric channel.
@@Str(Data.GetChannel(CurrXChnReference).Properties("Maximum").Value, "AutoAdj")@@
06-21-2023 06:21 AM
Using CurrXChnReference shows the maximum value of the X-channel for only the last curve that I plot (and is applied to all other curves). CurrYChnReference does the same for the Y-channel.
06-21-2023 09:58 AM
OK, I only had two curves that both used the same X channel, so I didn't notice the issue. For multiple curves with different X channels, CurrXChnReference does indeed not return the matching channel reference from the X channel. I was able to reproduce the behavior in very old versions as well. The variable should work in the legend in REPORT. I will create a bug for this to be fixed.
06-22-2023 03:17 AM
There is a workaround to display the maximum of the X channel of the curve. This requires a user command, that is entered as an expression in the legend.
Steps:
1) The user command looks as follows. Please adapt the name of the axis system accordingly.
function GetXChannelMaximum(CurveIndex)
GetXChannelMaximum = str(Data.GetChannel(Report.ActiveSheet.Objects("2DAxis1").Curves2D(CurveIndex).Shape.XChannel.Reference).Maximum, "AutoAdj")
end function
2) Save the script and register it in the User Commands dialog.
3) Select curve-related text in the legend and enter it as follows:
@@GetXChannelMaximum(1)@@
@@GetXChannelMaximum(2)@@
The parameter is the index of the curve in the curve list.