Create Multiple X Axes in DIAdem

Updated Jul 8, 2024

Environment

Software

  • DIAdem

This article demonstrates how to configure a 2D Axis System in DIAdem to give the illusion of having multiple x-axes.
DIAdem does not support configuring a 2D Axis System with several x-axis, so this example overlays two Axis Systems to achieve a similar functionality.

To overlay multiple Axis Systems in DIAdem and configure the x-axes to appear as though they are linked, follow the steps below.
Note: This tutorial works with the example data that is loaded into DIAdem's Data Portal by default.
 
  1. Launch DIAdem.
    • If using the default example data, click the Save icon in the Data Portal to save it on disk.
    • If using your own data file, load it into the Data Portal.
  2. Select the REPORT tab and create a new layout.
  3. On the new sheet, place a 2D Axis System by clicking Insert >> 2D Axis System.
  4. Double-click the 2D Axis System to open the Add Curves dialog.
  5. From the Data Portal, drag your X and Y channels into the X-channel and Y-channels fields.
    • In this example, the default Speed and Time channels are used for the Y axis and X-axis respectively.
  6. Click OK twice to save changes.

Add Curves.PNG
 
  1. Double-click the Axis System to open the Curve and Axis Definition dialog.
  2. Select the Position tab and make a note of all of the fields under Position as % of worksheet.

Position tab.PNG
 
  1. Click Cancel to close the dialog.
  2. Place another 2D Axis System on the same sheet.
  3. Double-click the new 2D Axis System to open the Add Curves dialog.
  4. Click OK. It doesn't matter which channel is plotted since this will be changed in a later step.
  5. Select the Position tab.
  6. Ensure that all fields under Position as % of worksheet have the same values as the first 2D Axis System.
    • This will place the objects on top of each other.
  7. Select the Curve list tab.
  8. Click the drop-down arrow next to the Color column and select No Color.
    • This will ensure that any channels plotted on the second 2D Axis System are invisible.

No Color Line.PNG
 
  1. Select the Axis Parameters tab.
  2. Click the Y1-Axis >> Scaling tab and ensure that Tick style is set to No ticks.
  3. Click the Y1-Axis >> Numbers tab  and ensure that Font Colors is set to No Color.
  4. Click the Y1-Axis >> Labels tab and ensure that the Text field is empty.
  5. Click the X-Axis >> Scaling tab and ensure that the following settings are configured:
    • Tick style is No ticks.
    • Tick size in % is set to 6.
    • Number of miniticks is set to 0.
  6. Click OK to save changes.
  7. Select the Legend that appears for the second 2D Axis Systems and press Delete to delete it.
  8. Navigate to File >> Save As... to save the report layout.
    • Note: Ensure to save it in the same location as the data file.
  9. Select the SCRIPT tab.
  10. Select File >> New VBS... to create a new Visual Basic Script.
  11. Click File >> Save As... to save the script in the same location as your data file and Report layout.
  12. Enter the following code to load your data file programmatically, where:
    • Dim numSamples declares a variable that will be used later.
    • Call Data.Root.Clear() clears the Data Portal of any current data.
    • Call LogFileDel() clears the Logfile output.
    • Call DataFileLoad(CurrentScriptPath & "<file name>", "<DataPlugin>", "Load|ChnXYRelation") loads a file saved in the same location as your script with the name <file name>.
    • The code below loads a file called "Data.tdm" with the TDM DataPlugin:
 
Dim numSamples

'--- Clear log and load data file into the Data Portal
Call Data.Root.Clear()
Call LogFileDel()

'--- To load a file called Data with the TDM DataPlugin, the below line should resemble:
Call DataFileLoad(CurrentScriptPath & "Data.tdm", "TDM", "Load|ChnXYRelation")
 
  1. Load the report with Call Report.LoadLayout(CurrentScriptPath & "<Report file>") where:
    • The report file should be saved in the same folder as your current script.
    • <Report file> is the name of your report.
    • The code below loads a report file called "Multiple X Axes.tdr": 
 
Call Report.LoadLayout(CurrentScriptPath & "Multiple X Axes.tdr")
 
  1. Create a new channel that will be used as the x-axis data for the second 2D Axis System. This example assumes that the x-axis will be the number of samples in the Y channels.
    1. Set the variable numSamples to the number of samples in the Y Channel.
    2. Use the ChnLinGetImp command to generate a numeric channel of equidistant values from 1 to the value of numSamples.
    3. The code example below sets numSamples to the length of a channel called Speed and then generates a numeric channel called NumberSamples.
 
numSamples = data.Root.ChannelGroups(1).Channels("Speed").Size
Call ChnLinGenImp("NumberSamples", numSamples, 1, 1, "")
 
  1. Refresh the report layout with Call Report.Refresh().
 
Call Report.Refresh()
 
  1. Run the script so that the NumberSamples channel appears in the Data Portal.
  2. The second 2D Axis System must now be configured to plot the new NumberSamples channel:
    1. Select the REPORT tab.
    2. Double-click the x-axis on the second 2D Axis System.
    3. Select the Curve List tab.
    4. Delete the channel in Y-Channel and drag the NumberSamples into the X-Channel field.
    5. Click OK to close the dialog.
  3. Save the report layout.
  4. Now when the script executes:
    1. The first 2D Axis System will plot the Y channel Speed against time.
    2. The second 2D Axis System will automatically plot the number of samples as a secondary x-axis.

After completing the steps in this article, you should have a similar result to the following image.
This image is the result from the attached example files.


Multiple X Axes Result.PNG