The time plot displays the history of several data items during the latest time horizon as lines. The time axis is always horizontal and directed to the right. Depending on the interpolation type, the line between two data samples is either interpolated linearly or keeps the previous value until the next one.
To create a time plot
- Drag the Time plot element from the Analysis palette into the graphical editor.
- In the Data section of the chart’s Properties, configure the data item.
-
First, choose the source of data for this data item: Value or Dataset.
- If you want to display how a variable or a parameter changes over time, choose the Value option and type the name of this variable or parameter in the Value field. Otherwise, type any expression you want: this expression will be evaluated with the defined recurrence time and the result of the calculation will be added to the chart.
- Otherwise, if you want to display values collected in some dataset, choose the Dataset option and type the dataset’s name in the edit box on the right.
- In the Title edit box, type the text that will be shown in the chart legend as the title of this data item.
-
Click in the Style box to adjust the appearance of the chart:
- Specify the color to paint points and line for this data item. Click the colored box to choose the custom color using the color picker, or use the edit box on the color picker’s right to adjust the color’s transparency.
- In Point style, select the marker style among the suggested options.
- Define the Line width using the available controls.
- Open the Appearance section of the chart’s Properties. In the Time axis format field you can choose the format of time axis labels: whether you want Model time units (like 0, 10, 20, …) or Model date formatted somehow (like Jan 21, 2009, 11:00:48 PM, Jan 22, 2009, 01:00:28 AM, and so on) to be displayed.
When finished, specify additional data items you want to be displayed in your chart.
To add a data item
By default, a new plot already has one data item. If you want to add another, follow these steps:
- Select the plot in the graphical editor or in the Projects view.
- Go to the Data section of the Properties view.
- Click the Add button. A new property section with settings for one more data item will appear below.
To remove a data item
- Select the plot in the graphical editor or in the Projects view.
- Go to the Data section of the Properties view.
- Locate the section defining the data item you want to remove from the plot.
- In this section, click the button.
- General
-
Name — The name of the chart. The name is used to identify and access the chart from the code.
Ignore — If selected, the chart is excluded from the model.
Lock — If selected, the chart is locked, so it could not be selected in the graphical editor with a mouse click. Model developers would not be able to move it, resize, or modify its properties anyhow, unless the chart is unlocked.
- Data
-
Depending on the type of the chart, one or more data items may already be present in its properties.
Add — This button opens a new property section, which allows for configuring the data you want to visualize on this chart.
Title — The title for this data item. It will be shown in the chart legend.
The combo box allows choosing where a value should be picked for this data item:
Value — [Visible if the Value option is selected] The expression that will be evaluated to obtain a new value to be added onto the chart.
Dataset — [Visible if the Dataset option is selected] The name of the dataset that collects values you want to display on this chart.
Style — Click to access extra data item appearance options:
Color — The color of the data item’s value on the chart. Click the colored box to choose the custom color using the color picker, or use the edit box on the color picker’s right to adjust the color’s transparency.
Point style — The style of the marker which will be used to display data points on the plot.
Line width — The width of the line connecting the data item’s points on the plot.
Use the and arrows to arrange the order of the data item sections.
To remove the data item from the chart, click the button below the data item’s property section.
- Data update
-
Update data automatically — If selected, new data samples will be added automatically with the specified Recurrence time. You can also specify whether you want to Use model time or Use calendar dates. Depending on this choice, you can specify when to start updating using either the First update time or Update date properties.
Maximum number of samples (applies to "Value" data) — Maximum number of the latest values that will be displayed for each data item with the option selected.
- Scale
-
Time window — The time horizon displayed by the chart.
Time window moves — Specifies whether the time window moves according to the current model time (Continuously) or it moves only when a new data point is added to the chart (As data becomes available).
Vertical scale — Defines the scale type of the vertical axis of the plot.
Auto — Auto-scaling mode
Fixed — Minimum and maximum specified in From and To boxes correspondinglyFrom / To — [Enabled if Vertical scale: Fixed] Defines the minimum and maximum for the vertical axis of the plot.
- Legend
-
Show legend — If selected, the chart legend is displayed.
Position — [Enabled if Show legend is selected] Sets the legend position (relative to the chart).
Area size — [Enabled if Show legend is selected] The size of the area allocated for the chart legend.
For the North and South positions, this setting affects the area’s height. For the East and West positions, this setting affects the area’s width.Text color — The color of the legend’s text. Click the colored box to choose the custom color using the color picker.
To adjust the text’s transparency, use the edit box on the color picker’s right. - Appearance
-
Vertical axis labels — Specifies the position of the vertical axis labels relative to the chart.
Left
Right
None — No labels will be displayedTime axis labels — The control specifies the position of horizontal axis labels relative to the chart (Below or Above).
Below
Above
None — No labels will be displayedTime axis format — The format of the time axis: Model time units (0, 10, 20, …) or Model date (Jan 21, 2009, 11:00:48 PM, Jan 22, 2009, 01:00:28 AM, …) to be displayed.
Style — Click to access extra appearance options:
Background color — The background color of the chart. Click the colored box to choose the custom color using the color picker, or use the edit box on the color picker’s right to adjust the color’s transparency.
Labels color — The chart label color. Click the colored box to choose the custom color using the color picker, or use the edit box on the color picker’s right to adjust the color’s transparency.
Grid color — The chart grid color. Click the colored box to choose the custom color using the color picker, or use the edit box on the color picker’s right to adjust the color’s transparency.
Border color — The chart border color. Click the colored box to choose the custom color using the color picker, or use the edit box on the color picker’s right to adjust the color’s transparency.
Draw line — If selected, the data item’s points on the plot are connected with lines.
Interpolation — [Visible if the Draw line option is selected] Defines the interpolation of the plot, that is, what values the plot takes between two adjacent data points.
Linear — two adjacent data points are connected with a straight-line segment
Step — the y-value between two adjacent set points is the same as in the point with less x-valueFill area under line — [Visible if the Draw line option is selected] If selected, the area under the line will be filled with the line color.
- Position and size
-
Level — The level this chart belongs to.
X — The x-coordinate of the chart’s upper left corner.
Y — The y-coordinate of the chart’s upper left corner.
Width — The width of the chart shape (in pixels).
Height — The height of the chart shape (in pixels).
- Chart area
-
This section defines the visual properties of the chart area.
X Offset — The x-offset of the chart area relative to the whole area allocated for the chart and all its accompanying elements.
Y Offset — The y-offset of the chart area relative to the whole area allocated for the chart and all its accompanying elements.
Width — The width of the chart area (in pixels).
Height — The height of the chart area (in pixels).
Style — Click to access extra options:
Background color — The chart area background color. Click the colored box to choose the custom color using the color picker, or use the edit box on the color picker’s right to adjust the color’s transparency.
Axis color — The chart area axis color. Click the colored box to choose the custom color using the color picker, or use the edit box on the color picker’s right to adjust the color’s transparency.
- Data items
-
Function Description void addDataSet(DataSet ds) Adds a DataSet data set to the chart. It has the default title (Data set) and visual appearance: royalBlue color, the line with width 1 is drawn, points are not drawn, linear interpolation.
ds — the data set to addvoid addDataSet(DataSet ds, String title) Adds a DataSet data set to the chart, with a given title and the default visual appearance: royalBlue color, the line with width 1 is drawn, points are not drawn, linear interpolation.
ds — the data set to add
title — the data set's titlevoid addDataSet(DataSet ds, String title, Appearance appearance) Adds a DataSet data set to the chart a given title and the appearance set by the configuration specified in the Appearance object passed as a parameter.
ds — the data set to add
title — the data set’s title
appearance — the object describing the data set’s appearancevoid addDataSet(DataSet ds, String title, Color color, boolean drawLine, int interpolationType, float lineWidth, int pointStyle) Adds a DataSet to the chart with the specified visual appearance.
ds — the data set to add
title — the data set title
color — the color of the data set plot
drawLine — if true, the plot line is drawn
interpolationType — interpolation type between two data points: TimePlot.INTERPOLATION_LINEAR — linear or TimePlot.INTERPOLATION_STEP — step interpolation
lineWidth — the width of the line (0 for thinnest possible)
pointStyle — what to draw at data points: TimePlot.POINT_SQUARE — squares, TimePlot.POINT_CIRCLE — circles, TimePlot.POINT_TRIANGLE — triangles, or TimePlot.POINT_NONE — none.void addDataSet(DataSet ds, String title, Color color, boolean drawLine, boolean fillAreaUnderLine, int interpolationType,double lineWidth, int pointStyle) Adds a DataSet to the chart with the specified visual appearance.
ds — the data set to add
title — the data set title
color — the color of the data set plot
drawLine — if true, the plot line is drawn
fillAreaUnderLine — if true, the area under line is filled
interpolationType — interpolation type between two data points: TimePlot.INTERPOLATION_LINEAR — linear or TimePlot.INTERPOLATION_STEP — step interpolation
lineWidth — the width of the line (0 for thinnest possible)
pointStyle — what to draw at data points: TimePlot.POINT_SQUARE — squares, TimePlot.POINT_CIRCLE — circles, TimePlot.POINT_TRIANGLE — triangles, or TimePlot.POINT_NONE — none.int getCount() Returns the number of chart items (data items or data sets) currently displayed by this chart. DataSet get(int i) Returns the chart item (DataItem, DataSet, and so on) with the given index.
i — the index of the itemString getTitle(int i) Returns the title of the chart item (DataItem, DataSet, and so on) with the given index.
i — the index of the itemColor getColor(int i) Returns the color of the chart item (DataItem, DataSet) with the given index.
i — the index of the itemvoid setColor(int i, Color c) Sets the new color of the chart item (DataItem, DataSet) with the given index.
i — the index of the item;=
c — the new color of the itemvoid remove(int i) Removes the item (DataItem, DataSet, and so on) with the given index from the chart.
i — The index of the data element.int remove(ChartItem ci) Removes the given item (DataItem, DataSet) from the chart.
i — The item to remove.void removeAll() Removes all items from the chart. - Selecting data items
-
Function Description void selectItem(int itemIndex, boolean selected) Selects or deselects (depending on the selected value) the chart item with the given index.
itemIndex — The index of the data element.
select — sets whether to select or deselect the element.void setSelectedItemIndices(int[] selectedIndices) Selects only chart items with the given indices.
selectedIndices — an array with indices of chart items to be selected (other chart items will be deselected), may be null — this clears selectionint[] getSelectedItemIndices() Returns the number of the chart items (data items or data sets) currently displayed by this chart. - Setting the axis scale of the chart
-
Function Description void setFixedVerticalScale(double minimum, double maximum) Sets the fixed scale for the vertical axis of the plot.
minimum — the minimum of chart axis scale
maximum — the maximum of chart axis scale - Updating chart data manually
-
Function Description void updateData() Updates all data items displayed by this chart. - Location
-
Function Description double getX() Returns the X coordinate of the chart (namely, the X coordinate of its upper left corner). double getY() Returns the Y coordinate of the chart (namely, the Y coordinate of its upper left corner). void setX(double x) Sets the X coordinate of the chart.
x — the new value of the X coordinatevoid setY(double y) Sets the Y coordinate of the chart.
y — the new value of the Y coordinatevoid setPos(double x, double y) Sets new coordinates for the chart shape.
x — the new value of the X coordinate
y — the new value of the Y coordinate - Size
-
Function Description double getWidth() Returns the width of the chart shape. double getHeight() Returns the height of the chart shape. void setWidth(double width) Sets new width for the chart shape.
width — the new value of the chart widthvoid setHeight(double height) Sets new height for the chart shape.
height — the new value of the chart height - Visibility
-
Function Description boolean isVisible() Checks the visibility of the chart. Returns true if the chart is visible, and false otherwise. void setVisible(boolean v) Sets the visibility of the chart.
v — visibility: if true — the chart is set to be visible, if false — not visible.
-
How can we improve this article?
-