02-26-2013 09:36 AM
Hi,
Does anybody know how to set up a chart legend that will display the channel comment for the X-Channel? There is a standard option for selecting the Y-Channel comment and the line below also achieves this. In my case the Y-data is shared across all curves and the X-Data is independent. Thanks in advance!
Display the Y-Channel Comment:
@CC(CCN)@
02-27-2013 10:45 AM
Hi GT_Mark,
There is no native connection between the Y channel and the X channel, so the Legend doesn't know what the X channel is. If you have a recipe for determining what the X channel is from the Y channel (that the legend does know about), then that can be encoded in an @@ expression in the legend. Alternatively, you could copy the X channel description to a new property on the Y channel or create a property on the Y channel which contains the X channel name.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
02-28-2013 04:41 AM
02-28-2013 03:06 PM
Thank you for your reply, that provides exactly what I was looking for, though I cannot seem to get DIAdem to take the text "@CC(CurrXChnNo)@" through the script. This appears to be because the initial chart template does not contain any curves. So while I can set the mode to "Curve-Related Text," I cannot fill the fields with the text "@CC(CurrXChnNo)@" by running the script because to my knowledge there is no string to call that will populate the field. Is this correct or is there some way to do this? To my knowledge the following line can only be used when entering "Free Text" and so does not work:
Report.ActiveSheet.Objects.Item("2DAxis2").CurveLegend.Columns.Item(1).Text = "@CC(CurrXChnNo)@"
Thanks in advance!
03-01-2013 02:36 AM - edited 03-01-2013 02:49 AM
You're right, it doesn't work with "curve-related text", no idea, why...
But there is a way - probably not the best one - to do this.
Dim oMy2DaxisSystem, oMy2DCurve, oMyShape, oMyPosition, oMyLegendColumns, oMyCurveLegendPos ' Call Report.NewLayout() Set oMy2DaxisSystem = Report.ActiveSheet.Objects.Add(eReportObject2DAxisSystem,"My2DAxisSystem") Set oMyPosition = oMy2DAxisSystem.Position.ByCoordinate oMyPosition.X1 = 20 oMyPosition.X2 = 80 oMyPosition.Y1 = 20 oMyPosition.Y2 = 80 ' Set oMy2DCurve = oMy2DaxisSystem.Curves2D.Add(e2DShapeLine, "MyNewCurve") Set oMyShape = oMy2DCurve.Shape oMyShape.XChannel.Reference = "[1]/[15]" oMyShape.YChannel.Reference = "[1]/[25]" oMy2DaxisSystem.CurveLegend.Visible = True oMy2DaxisSystem.CurveLegend.Settings.ShowGridLines = FALSE ' Set oMyCurveLegendPos = oMy2DaxisSystem.CurveLegend.Position oMyCurveLegendPos.SizeMode = eLegendSizeElementwise oMyCurveLegendPos.ElementHeight = 6 oMyCurveLegendPos.ElementWidth = 35 oMy2DaxisSystem.CurveLegend.Settings.Font.Size = 5 ' Set oMyLegendColumns = oMy2DaxisSystem.CurveLegend.Columns Call oMyLegendColumns.Add oMyLegendColumns(1).Type = eLegendTextComment oMyLegendColumns(1).RelativeWidth = 1 oMyLegendColumns(2).Type = eLegendTextCustomText oMyLegendColumns(2).RelativeWidth = 1 oMyLegendColumns(2).Text = "@CC(CurrXChnNo)@" ' Call Report.Refresh()
The code is available in Examples, I just added some minor details.
Another way (shorter, but not so universally valid) is to extend your code:
Report.ActiveSheet.Objects.Item("2DAxis2").CurveLegend.Columns.Item(1).Type = eLegendTextCustomText
Report.ActiveSheet.Objects.Item("2DAxis2").CurveLegend.Columns.Item(1).Text = "@CC(CurrXChnNo)@"
IMO, this works only if you already have the graph.
And take care about the object name ("2DAxis2"), this can vary from page to page...
03-07-2013 03:17 PM - edited 03-07-2013 03:27 PM
Thanks for your replies. These solutions do put a band aid on the problem when only one curve is on a graph. However when any of these solutions are used on a chart containing more than 1 curve, only the Description text from the last curve is used as the legend text for ALL curve legend entries.
I would think this is a critical function for report-generating software such as DIAdem. Please keep the suggestions coming and thanks in advance!
03-08-2013 05:58 PM
Hi GT_Mark
R&D regularly looks over our Idea Exchanges for functionality that our users want to have in future product versions. If you come up with any ideas for improving DIAdem, such as added this functionality, I would encourage you to post to the DIAdem Idea Exchange. I have included a link below to the Idea Exchange for your convenience.
DIAdem Idea Exchange: http://forums.ni.com/t5/DIAdem-Idea-Exchange/idb-p/diademideas
Regards,
Jason D
Applications Engineer
National Instruments