DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Use comment from X-Channel data in Chart Legend

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)@

0 Kudos
Message 1 of 7
(5,640 Views)

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

Message 2 of 7
(5,616 Views)
Hello GT_Mark,
 
if I understand you correct, you want to have the description from the X-Channel inside the legend for the Graph.
For this you can also add the curve-related text @CC(CurrXChnNo)@ as shown in the attachment "legend.png".
Another file shows the result.
 
Hope it helps.
Download All
0 Kudos
Message 3 of 7
(5,598 Views)

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!

0 Kudos
Message 4 of 7
(5,576 Views)

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...

 

0 Kudos
Message 5 of 7
(5,565 Views)

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!

0 Kudos
Message 6 of 7
(5,515 Views)

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

0 Kudos
Message 7 of 7
(5,492 Views)