The bar chart displays a number of data items as bars aligned at one end, whose sizes are proportional to the corresponding data item values. In case of negative data, bars will grow in the opposite direction.
To create a bar chart
- Drag the Bar Chart element from the Analysis palette into the graphical editor.
- In the Data section of the chart’s Properties, configure the data item.
- Specify the title for the data item in the Title box. This text will be shown in the chart legend.
- Enter the expression that will be dynamically evaluated to obtain the current value of the data item in the Value box.
- Specify the color for this data item’s bar. 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.
- Open the Appearance section of the chart’s Properties. Adjust the direction of growth of bars using the Bars direction group of buttons.
- Bars can be shown as distinct bars of arbitrary thickness, or adjacent to each other. Adjust the thickness of bars by setting the value for the Bars relative width property: set to 1 to use the maximum possible width without bars overlapping each other, 0.5 — half that value, and so on.
When finished, specify additional data items you want to be displayed in your chart.
To add a data item
By default, a new bar chart already has one data item. If you want to add another, follow these steps:
- Select the bar chart 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 bar chart 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 bar chart.
- 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.
Value — The expression which dynamically evaluates the data item value.
Color — The color of the data item 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.
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.
- Scale
-
Scale — Defines the scale type for the vertical axis of the plot.
Auto — Auto-scaling mode
100%
Fixed — Minimum and maximum specified in From and To boxes correspondingly.From / To — [Enabled if 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
Bars direction — The group of buttons defining the bar growth direction.
Up
Right
Down
LeftBars relative width — Specifies the thickness of the bars (1 — maximum possible without bars overlapping each other, 0.5 — half, and so on).
Axis labels position — The control specifies the position of axis labels relative to the chart.
Left
Right
None — No labels will be displayedStyle — 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.
- 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 addDataItem(DataItem di) Adds a DataItem element to the chart with a default title and color.
di — the data item to addvoid addDataItem(DataItem di, String title, Color color) Adds a DataItem element to the chart.
di — the data item to add
title — the data item title
color — the color to associate with this data itemint getCount() Returns the number of chart items (data items or data sets) currently being displayed by this chart. DataItem get(int i) Returns the chart item (DataItem, DataSet, and so on) with the given index. String getTitle(int i) Returns the title of the chart item (DataItem, DataSet, and so on) with the given index. Color getColor(int i) Returns the color of the chart item (DataItem, DataSet) with the given index.
i — the index of the item.void 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 item.void remove(int i) Removes the item (DataItem, DataSet, and so on) with the given index from the chart. int remove(ChartItem ci) Removes the given item (DataItem, DataSet) from the chart. 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) from the chart item with the specified index. void setSelectedItemIndices(int[] selectedIndices) Selects only the chart items with the given indices.
selectedIndices — an array of indices of the chart items to select (other chart items will not be selected), can be null — this will clear the selectionint[] getSelectedItemIndices() Returns the number of chart items (data items or data sets) currently being displayed by this chart. - Setting the chart’s axis scale
-
Function Description void setFixedScale(double minimum, double maximum) Sets the fixed scale for the chart.
minimum — the minimum of the chart axis scale
maximum — the maximum of the chart axis scale - Updating chart data manually
-
Function Description void updateData() Updates all data items being 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 coordinatevoid setPos(Point p) Sets new coordinates for the chart shape.
p — the Point object containing the new coordinates - 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 — the visibility: if true — the chart is set to be visible, if false — not visible.
-
How can we improve this article?
-