> For the complete documentation index, see [llms.txt](https://help.qtech.co.nz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.qtech.co.nz/datran/datran-vi-scada/datran-trending/plots.md).

# Create, open and share plots

Create a plot, change its default time span and colours, open or delete plots, copy them as templates, open an archived database, and open a plot from a shortcut.

Save Plot saves the current plot, pens and notes into the DATRAN database. To make a plot public (other users can view this plot), remove the tick from the Private check box.

{% hint style="info" %}
**Applies to:** DATRAN Trending V5.x.
{% endhint %}

## Create a plot

1. Click on the **File** menu and select **Create New Plot** (Ctrl+N).
2. Type in the **Name** of the new plot.
3. Set the defaults the plot opens with:

| Setting            | What it does                                                                                                                                     |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| Default start time | Where the X (time) axis starts each time the plot opens or refreshes. Not available when the time span is Today, Yesterday, This week and so on. |
| Default time span  | The width of the X axis displayed each time the plot is opened.                                                                                  |
| Default stop time  | The stop point of the x-axis displayed each time the plot is opened. This can only be changed when the 'Default time span' is set to Custom.     |
| Max time span      | The maximum allowable span of the X axis when using the zoom out button. Keep this at No Limit if you prefer unlimited zoom out capability.      |
| Background colour  | The background colour of the plot. Try to avoid colours that are too glaring to the eye or too dark.                                             |
| Gradient           | A changing background colour, ranging between the background colour and white. Using a gradient on a plot can slow down plot drawing.            |
| Private            | Tick this check box if you want to be the only one that can view this plot in this DATRAN database. To make it public again, remove the tick.    |

4. Click **OK**. A new plot window opens, with the opportunity to set the points/pens for this plot via the **Select Pen Points** dialogue. Activate the pens that you require and select a point for each of the active pens. See [Set up pens](https://help.qtech.co.nz/datran/datran-vi-scada/datran-trending/pens.md).
5. Click **OK**. Retrieval of data could take a couple of minutes depending on how many pens you have selected and how much data the chosen points have.

Please note that the maximum number of plots that can be opened at once is 1000 for any one session of this application or when the computer runs out of memory.

## Change a plot's defaults

Select **Current Plot > Plot Properties**, or click the change plot properties button. You can change the default start time, default time span, default stop time, maximum time span, background colour, background gradient and **Private**.

These details do get saved into the DATRAN database, so next time you open the plot these settings will still be there. If you have made many changes to the plot's start date and span, click **Revert settings from DATRAN database** to change the current plot back to the database settings when the plot was first opened.

Other options on the **Current Plot** menu:

* **Rename Plot**: allows you to rename the current plot.
* **Line Graph** or **Point Graph**: point graph marks each logged value with a square.
* **Hide Legend**, and **Show Y Lines**: displays the Y lines across the graph area of the current plot in 5 intervals.
* **Default Size**: sizes the current viewed plot for perfect viewing on an 800 x 600 screen resolution.

**File > Save Plot**, or the save button, saves the current plot, pens and notes into the DATRAN database. There is a "Save Changes" dialogue: you can easily make changes and experiment, and then discard the changes. Discarding changes won't affect other users of the plot.

## Open or switch plots

* **File > Open Plot** allows you to select a plot to open and then display on the screen.
* **Current Plot > Select Plot**, or the change plot button, shows a different plot in the current window. The **Set** button sets up the selected plot on the current viewed plot area. The **Set & Close** button closes the dialogue and loads the details of the selected plot into the current viewed plot area. To select multiple plots at once, hold down the Ctrl key and use the left mouse button to select the plots that you want to open. Only the Set & Close button will work for multiple plots.
* The previous and next plot buttons allow you to scroll through the plots in the alphabetical order in which they are stored in the DATRAN database.

You can filter the list of plots by using the wildcard character asterisk `*`. For example, to show all plots that have the word "Reservoir" followed by "North", type in `reservoir*north`. A wildcard character is not compulsory. For example, typing in `Rural North` will also show all plots that has the word "Rural" and immediately followed by the word "North". The match is not case-sensitive.

Use the **Refresh** button if you cannot see a plot that has just been created by another copy of DATRAN Trending.

### Plots another user has open

Plots that are currently opened will have the phrase "READ ONLY" beside their name. A read-only plot does not allow changes to the pens or the plot properties but it does allow the user to view the current plot in its entirety. If you decide to open a plot that is currently opened by another user, you will be notified when the plot has been closed by the other user. Click on the Read-Write button if you want to reopen the plot in read-write mode. If a plot is read-only and nobody else has it open, see [Plots open read-only](https://help.qtech.co.nz/datran/datran-vi-scada/datran-trending/troubleshooting/plots-read-only.md).

## Delete a plot

You will not be able to delete the plot if you are not the owner of the plot. This means if you do have a read-only copy open on your computer you will not be able to delete this plot. It is very important that you check with other users to ensure this is not a plot they view often. There is no way to undo it once it has been deleted.

1. Open the plot.
2. Select **Current Plot > Delete Plot**, and confirm.

This will delete all the information about the plot and its pens. This also tells any users who still have a read-only copy of this plot open that this plot has been deleted and that their plot window will be closed.

## Copy plots to another DATRAN database

Plots can be saved as plot template files (`.ptm`) and loaded into another DATRAN database.

* **One plot:** **File > Save To Template File**, and **File > Load From Template File** in the other database.
* **Many plots:** **Database > Export Plots To Template Files**. Filter the list by wildcard or read-only status, select the plots and click **Export** or **Export & Close**. Load them with **Database > Import Plots From Template Files**.

## Open an archived database

An archived database is an older database storing historical data. To access an archived DATRAN database it is important to ensure that this database uses the correct table structure to show plots. This means that only DATRAN databases that have been amended with the new structure can be used with this function. Please contact QTech for further information on how to make older databases accessible by DATRAN Trending.

* **Database > Switch Database** allows you to change the database you are pointing to, using the **Data Link Properties** dialog box.
* **Database > Set Database** allows you to change the database you are pointing to as well as restore an archived DATRAN database:
  1. Select **Archived DATRAN Database**.
  2. Choose the data file (`.mdf`) and log file (`.ldf`).
  3. When **OK** is clicked the files are checked for accuracy and then the first plot in the archived database is displayed.

To access an archived database you need to have it named DATRANarchive. It is recommended that the live database is named DATRANdatabase.

## Open a plot from a shortcut or another program

You can start DATRAN Trending with a particular plot and time range, from a desktop shortcut, the Start menu, or a program such as DATRANVue. The program is `HistTrend`. It takes up to four arguments, in this order:

| Argument               | What it is                                       |
| ---------------------- | ------------------------------------------------ |
| 1. Connection string   | How to connect to the DATRAN database, in quotes |
| 2. Plot name           | The name of the plot is not case sensitive.      |
| 3. Start date and time | The left edge of the plot                        |
| 4. Stop date and time  | The right edge of the plot                       |

All are optional, but you can't skip one and give a later one:

* No arguments: loads the plot which was last opened in a previous session.
* Connection string only: opens up the last opened plot according to settings within the database.
* Connection string and plot: start follows as configured in the plot or the global setting and that goes for the time span.
* Plus a start: the time span will follow the one as configured in the plot.
* Plus a stop: the time span will follow exactly as defined in the parameters.

Dates follow the Windows short date format (and time format) in **Regional settings**. If you did not get the correct date/time format, the application will advise you of the correct date/time format to use. If you are using both date and time, use the double quotation marks (") to combine date and time as the third or fourth parameter.

To skip the connection window completely, the connection string must include the provider, data source and initial catalog, plus the login details. Note that exposing the user credentials in the connection string may be a security hazard, so consider using a low privileged user for the purpose.

If DATRAN Trending is already opened, opening a plot via the command prompt will open it in the DATRAN Trending that is already running instead of creating a new instance of DATRAN Trending.
