Creating a default state for screen

I’m trying to create a default state for a screen and its components. I have an easy chart with x tags and a table set to a certain time range that’s alterable by a date range slider. I know that any privileged user can delete tags from an easy chart and change its time range, so I am asking for your help on how to create a default button that will restore the screen and its components back to a predetermined format.

Thanks in advance.

To set the tags in the Easy Chart back to their default value, you can simply reassign the tagPens property in a script. That means you’ll need to define the tagPens dataset with the expected format. Take a look at [this] (Can't set pen attributes for Easy Chart template) post where another user is setting tag pens via scripting.
You can do something similar to the Date Range component by setting the startDate and endDate properties in a script.

When I need to do this I'll typically make a custom property (dataset type) on the root container and call it defaultTagPens or similar.
Configure the EasyChart how you want the default config to be, go to the tagPens property and copy that dataset using the button in the dataset editor window.
Paste that dataset into your root container's custom property named defaultTagPens.

After you do that you can set (via button or visionWindowOpened or whichever event you choose) the EasyChart's .tagPens property to the root container's .defaultTagPens custom property.

event.source.parent.getComponent('Easy Chart').tagPens = event.source.parent.defaultTagPens

Effectively accomplishes the same thing as bfuson's solution but the dataset is stored in a custom property as opposed to defining the dataset in the scripting (something I find to be tedious).

If it was possible I would prefer to make the custom property on the EasyChart but for some reason this option is not available in the contextual menu.
Good luck!

1 Like

You can also use a one-way property binding to assign the default to the chart's tagPens property on window open. No button required. If you reconfigure the chart and you want that to be the new default, use the clipboard to copy and paste from tagPens to the custom property. Of course, this also can be done for DB Pens and Calculated pens, if you are using them. (I use DB Pens far more often than tagPens, but YMMV.)