DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to link the x-axis of multiple REPORT plots in DIAdem 2018? (Not from VIEW)

Hello,

 

We have report templates with selected channels for auto-processing pdf reports. Unfortunately, DIAdem does not adequately re-scale the pdf report x-axis, resulting in colliding time labels (even with auto-scale selected in plot properties). This results in low confidence that a report won't have formatting errors along the time axis and subsequently someone having to load that data set into DIAdem, go through clicking on each plot and adjusting time scale (extremely time consuming).

 

  1. Is generating a pdf with axis errors a known issue that others have problems with?
    • We are passing variables from LabVIEW and controlling DIAdem environment via automation VIs
    • Variables call a DIAdem script to load data, export to pdf using report template
  2. Is there a way to adjust all report plot axis (for re-formatting and zooming purposes)?
    • I know you can use VIEW to "zoom" then transfer to report, but we want to avoid as many clicks as possible so staying in report would be ideal
    • I know that using the Ctrl+SHIFT+C function in script record mode, you can capture dialog box parameters (such as report plot x-axis ;)), is this a possible method for adjusting all plots?

Thank you for your time and any suggestions. I can provide screen shots if necessary but it really is just a matter of the x-axis not scaling in a way that will always avoid labels colliding...

 

BG

0 Kudos
Message 1 of 2
(2,604 Views)

In general, it is easier to create a Report layout with the formatting desired, then to programmatically adjust the report. But sometimes you need to make adjustments programmatically, so I am providing an example on how to make the most common adjustments. As you noted, you can discover the script commands by manually making adjustments to the Report dialog, and then capturing them to the clipboard via Ctrl+SHIFT+C.

You mentioned a need for "zooming". You can do this in Report via the "Display" and then "Axis Parameters" tab. See my example on making the adjustment.

You mentined "labels colliding". The easiest way to fix this is to make the adjustment manually ("Display", "Axis Parameters" tab, ..) and then capture the settings to the clipboard via CTRL-SHIFT-C. See my example of X-Axis tick lable collision resolution.

I hope this helps.

Find more script tips at www.SavvyDIAdemSolutions.com

 

'-------------------------------------------------------------------------------
' Create custom 2DChart in Report, zoom in to a particular portion of the X-Axis,
' and create/fix X-axis tick label collisions.

Call Report.NewLayout
Call bDoReport2DChart()
Call WndShow("REPORT")

Function bDoReport2DChart()
bDoReport2DChart = False
Call Data.Root.Clear()
'Load a single numeric time channel + numeric data channel
If FileExist(ProgramDrv & "Examples\Data\ADOExample.tdm") Then
Call DataFileLoadSel(ProgramDrv & "Examples\Data\ADOExample.tdm",,"[1]/[1]|[1]/[4]")
ElseIf FileExist(CommonDocumentsPath & "Data\Example.TDM") Then
Call DataFileLoadSel(CommonDocumentsPath & "Data\Example.TDM",,"[1]/[3]")
End If
If Data.Root.ChannelGroups.Count = 0 Then Exit Function

Dim oRptSht, oRptObj, oCurve2D, iCurve, oElement, oChnX, oChnY, eNSystemsMode, o2DAxisXScaling, o2DAxisXTick
Dim bUIAutoRefresh, bViewAutoRefresh
bUIAutoRefresh = UIAutoRefresh: bViewAutoRefresh = View.AutoRefresh
Call UIAutoRefreshSet(True): View.AutoRefresh = True
Set oChnX = Data.Root.ChannelGroups(1).Channels(1)
Set oChnY = Data.Root.ChannelGroups(1).Channels(2)

'Add a new Report sheet named "My2dRpt1".
If Report.Sheets.Exists("My2DRpt1") Then Call Report.Sheets.Remove("My2DRpt1")
Set oRptSht = Report.Sheets.Add("My2DRpt1")
'Create the 2D chart
Set oRptObj = oRptSht.Objects.Add(eReportObject2DAxisSystem, "2DAxisNSystems")
'Set the 2D chart position on the Report sheet
oRptObj.Position.ByCoordinate.X1 = 12
oRptObj.Position.ByCoordinate.X2 = 95
oRptObj.Position.ByCoordinate.Y1 = 10
oRptObj.Position.ByCoordinate.Y2 = 78
iCurve = 0
iCurve = iCurve + 1
Set oCurve2D = oRptObj.Curves2D.Add(e2DShapeLine, "2DCurve" & str(iCurve))
oCurve2D.Shape.XChannel.Reference = oChnX.GetReference(eRefTypeIndexIndex)
oCurve2D.Shape.YChannel.Reference = oChnY.GetReference(eRefTypeIndexIndex)

'Show the X-Axis label
oRptObj.XAxis.Label.Text = "@@ChnName(CurrChnNo)@@ [@@ChnDim(CurrChnNo)@@]"
'Show the Y-Axis labels if eNSystemsMode = e2DAxisNSystems
eNSystemsMode = e2DAxisNSystems
If eNSystemsMode = e2DAxisNSystems Then
oRptObj.YAxis.Label.Text = "@@ChnName(CurrChnNo)@@ [@@ChnDim(CurrChnNo)@@]"
Else
oRptObj.CurveLegend.Visible = True
oRptObj.CurveLegend.Frame.Visible = False
oRptObj.CurveLegend.Position.InteractiveMoveMode=eLegendMoveAutomatic
oRptObj.CurveLegend.Position.RelativePosition = eLegendRelativePositionTopLeft
oRptObj.CurveLegend.Position.SizeMode =eLegendSizeElementwise
oRptObj.CurveLegend.Position.Anchor.Type=eLegendAnchorTypePageRelated
oRptObj.CurveLegend.Position.Anchor.PageRelatedX = 75
oRptObj.CurveLegend.Position.Anchor.PageRelatedY = 90
oRptObj.CurveLegend.Settings.UseAutoFontSize = False
oRptObj.CurveLegend.Settings.Font.Size = 3.0
End If
oRptObj.Settings.NSystemsMode = eNSystemsMode
oRptObj.YAxis.Label.UseCurveColor = True

'------------------- 2DAxisXScaling ------------------------------
Set o2DAxisXScaling = oRptObj.XAxis.Scaling
o2DAxisXScaling.AutoScalingType = eAxisAutoScalingBeginEndManual
o2DAxisXScaling.Begin = 3.25
o2DAxisXScaling.CustomScalingID = ""
o2DAxisXScaling.DateTimeRepresentation = eDateTimeRepresentationLegacy
o2DAxisXScaling.End = 6.25
o2DAxisXScaling.MiniTickCount = 1
o2DAxisXScaling.Origin = 3.25
o2DAxisXScaling.SpanWidth = 3
o2DAxisXScaling.Type = e2DXScalingLinear

'These setting will make the X-axis tick labels collide
o2DAxisXScaling.AutoScalingType = eAxisAutoScalingSpanWidthTickManual
'------------------- 2DAxisXTick ------------------------------
'Set o2DAxisXTick = Report.Sheets("My2DRpt1").Objects("2DAxisNSystems").XAxis.Scaling.Tick
Set o2DAxisXTick = o2DAxisXScaling.Tick
o2DAxisXTick.Distance = 0.05
o2DAxisXTick.Origin = 0
o2DAxisXTick.SpacingType = eAxisTickSpacingDefinedByDistance

'**************************************************************
'This setting will fix the X-axis tick label collision (see also the setting several lines up).
'(comment out the line and run the script to observe the effect on the Report)
o2DAxisXTick.Distance = 0.5
'**************************************************************

'Example of how to add free text to the Report sheet
Set oRptObj = oRptSht.Objects.Add(eReportObjectText, "RptTitle")
oRptObj.Font.Size = 6
oRptObj.PositionXY.X = 52.132
oRptObj.PositionXY.Y = 93.648
oRptObj.PositionXY.RelativePosition = eRelativePositionCenter
oRptObj.Text = "My Chart Title"
Set oRptObj = Nothing

Set oChnX = Nothing: Set oChnY = Nothing: Set oRptObj = Nothing: Set o2DAxisXScaling = Nothing: Set o2DAxisXTick = Nothing
Call UIAutoRefreshSet(bUIAutoRefresh): View.AutoRefresh = bViewAutoRefresh: Call View.Refresh()
bDoReport2DChart = True
End Function 'bDoReport2DChart()

 

Message 2 of 2
(2,556 Views)