Showing results for 
Search instead for 
Did you mean: 

Add a waveform to a report graph

Go to solution

I have a question that I think should be pretty basic but I can't figure it out. Using the sample data I want to use VBscript to put a waveform channel into a report layout that I already have set up. Currently I have everything scripted to show up in VIEW, but I want the flexibility to add titles and place labels where I want them so I need to switch to REPORT.


I need to add a bunch of channels so I want to eventually use this example script, but even without the loop I can't get it to work.



Dim Channels, Sheet, Graph

Set Channels = Data.Root.ChannelGroups(2).Channels
Set Sheet = Report.ActiveSheet
Set Graph = Sheet.Objects("2DAxis1")
Call Graph.Curves2D.RemoveAll()

Graph.Curves2D.Add(e2DShapeLine, "Curve1").Shape.YChannel.Reference = Channels(1).GetReference(eReferenceIndexName)


The above script adds the Y-channel I want, but my X-channel is a question mark (?). Why does it do that? I have to manually delete the question mark and then the graph will plot.





0 Kudos
Message 1 of 3
Accepted by topic author TW_Test

When dealing with waveform channels, you need to set the X channel reference to "". See the example below.



Dim oChnWf, oRptSht, oRptObj, oCurve2D
Dim sPathDocuments, sPathData
sPathDocuments = ProgramDrv & "Examples\Documents\"
sPathData = ProgramDrv & "Examples\Data\"
Call Data.Root.Clear()
Call DataFileLoadSel(sPathData & "Example_data.tdm", "TDM", "[2]/*", "Load|ChnXYRelation")
Set oChnWf = Data.GetChannel("Noise data/Noise_1")

Set oRptSht = Report.ActiveSheet 'or Set oRptSheet = Report.Sheets.Item("Sheet 1")
Set oRptObj = oRptSht.Objects.Item("2DAxis1")
Call oRptObj.Curves2D.RemoveAll()
Set oCurve2D = oRptObj.Curves2D.Add(e2DShapeLine, "Curve1")
oCurve2D.Shape.XChannel.Reference = ""
oCurve2D.Shape.YChannel.Reference = oChnWf.GetReference(eReferenceIndexName)
Call Report.Refresh()

Message 2 of 3

Thanks Mark! I knew I was missing some minor detail. I'm kind of kicking myself for not trying "" for the X-channel, but that is how scripting goes for me.

0 Kudos
Message 3 of 3