Histogram 2D

Histogram 2D chart displays a collection of two-dimensional histograms. Each histogram is drawn as a number of rectangular color spots reflecting the PDF value or envelope at the corresponding (X,Y). The chart X and Y axis are always scaled to fit all histograms. The chart has a collection of Histogram 2D Data objects and the collection of associated visual appearance descriptions. The chart may have scale text labels and a grid.

Histogram2D

When 2D histogram displays bins, the color of each rectangular cell does not reflect its PDF value (relative frequency) for the whole 2D plane, but within its X-axis interval only. 

 To create a histogram 2D

  1. Drag the Histogram 2D  element from the  Analysis palette into the graphical editor.
  2. In the Properties view, open the section Data, and specify histogram data item(s) you want to display on the 2D histogram.

Properties

General

Name – The name of the histogram. The name is used to identify and access the histogram from code.

Ignore – If selected, the histogram is excluded from the model.

Visible on upper level – If selected, the histogram is also visible on the upper level where this agent lives.

Show envelopes - If selected, histogram 2D data are displayed as envelopes.

Show bins - If selected, histogram 2D data are displayed as bins.

Data

  This button opens new property section, which allows to configure one more data item you want to visualize on this histogram: 

Title – The title for this data item, which will be shown in the histogram legend. 

Histogram – The name of the Histogram2D Data object, which will be displayed on this histogram.

Color – Color, which will be used to draw this data item value on the histogram. Click inside the control and choose a color from the set of most used ones, or choose some custom color using the Colors dialog box.

To remove a data item from the histogram, click the  button below the data item's property section. Use the arrows   and to arrange the order of the data item sections.

Data update

Do not update data automatically - If selected, chart is not updated automatically with new data samples.

Update data automatically – If selected, new data samples are added automatically with the specified Recurrence time. Also, you can define here whether you want to Use model time or Use calendar dates. Depending on this choice, you can specify when updating begins with either First update time or Update date properties.

Appearance

Horizontal axis labels – The control specifies the position of horizontal axis labels relative to the chart (Below or Above). Choose None, if you do not want labels to be displayed.

Vertical axis labels – The control specifies the position of vertical axis labels relative to the chart (Left or Right). Choose None, if you do not want labels to be displayed.

Background color – Background color for the chart. 

Border color – Color used to draw chart border. 

Labels color – The control specifies the color of the chart labels.

Grid color – The control specifies the color of the chart grid. Choose No Fill, if you do not want grid to be displayed.

Position and size

X – The x-coordinate of the histogram's upper left corner.

Y – The y-coordinate of the histogram's upper left corner.

Width – The width of the histogram (in pixels).

Height – The height of the histogram (in pixels).

Legend

Show legend – If selected, the chart legend is displayed. You can control the legend position relative to the chart using the Position group of buttons. The size of the area allocated for the legend can be defined using either Width or Height control (depends on the legend's Position). Text color can also be adjusted.

Chart area

This section defines 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).

Background color – Background color for the chart area. 

Border color – Color used to draw the border of the chart area. 

Advanced

Visible – The chart visibility.  The chart is visible when the specified expression evaluates to true, and not visible otherwise.

Replication –  The replication factor of the chart. Here you specify how many copies of the chart will be created. If you leave this field empty, only one chart will be created.

On item removal –  The code executed when the user removes some particular data item(s) from the chart. This code is executed either when the user removes items from the context menu of the chart legend, and when data items are removed programmatically via functions remove() and removeAll().
You can use two variables here:
int removedIndex
- index of the just removed data item.
boolean programmatically - defines, whether the item was removed programmatically (true), or not (false).

On selection change –  The code executed when the user selects some particular data item(s). This code is executed either when the user changes the selection by clicking on items in the chart legend, and when the selection is changed programmatically via the function selectItem()
You can use two variables here:
int[] selectedIndices - the indices of currently selected data items.
boolean programmatically - defines, whether items were selected programmatically (true), or not (false).

Show name – If selected, the name of the histogram is displayed on a presentation diagram.

Adding/removing data items

 To alter the histogram's display mode

  1. Select the histogram in the graphical editor or in the Projects view.
  2. Go to the Properties view.
  3. In case you want to display histogram as a number of rectangular color spots reflecting the PDF value, choose the Show bins option.
  4. In case you want to display histogram as envelopes at the corresponding (X,Y), choose the Show envelopes option.
 To add a data item on a histogram 2D
  1. Select the histogram in the graphical editor or in the Projects view.
  2. Go to the Data section of the Properties view.
  3. Click the  Add histogram data button. New property section defining settings for one more data item appears above.
  4. In this section, choose the data object from the Histogram combo box.
  5. In the Title box, type the text that will be shown in the chart legend as the title of the this data item.
  6. Specify the color for this data object. Click the arrow in the Color control and choose the color.

If you do not need displaying some data object no more, you may easily remove it from the histogram any moment you like.

 To remove a data item from a histogram
  1. Select the histogram in the graphical editor or in the Projects view.
  2. On the Data section of the Properties view, select the section defining the data item you want to remove.
  3. Click the  button below all sections.

Functions

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.

Parameter: x - the new value of X coordinate

void setY(double y)

Sets the Y coordinate of the chart.

Parameter: y - the new value of Y coordinate

void setPos(double x,
double y)

Sets new coordinates for the chart shape.

Parameters:
x - the new value of x coordinate
y - the new value of 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 w)

Sets new width for the chart shape.

Parameter: w - new value of the chart width

void setHeight(double h)

Sets new height for the chart shape.

Parameter: h - 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.

Parameter:
v - visibility: if true - the chart is set to be visible, if false - not visible.

Adding and removing chart's data items

Function

Description

void addHistogram2D
(Histogram2DData hist,
String title,
Color color)

Adds a histogram 2D data object to the chart with the specified visual appearance.

Parameters:
hist - the histogram 2D object to add
title - the histogram 2D data title
color - the color corresponding to the highest PDF

int getCount()

Returns the number of data items currently displayed by this chart.

ChartItem get(int i)

Returns the chart's Histogram2DData item with the given index.

String getTitle(int i)

Returns the title of chart's Histogram2DData item with the given index.

Color getColor(int i)

Returns the color of the chart item (Histogram2DData) with the given index.

void remove(int i)

Removes the Histogram2DData item with the given index from the chart.

int remove(ChartItem ci)

Removes the given Histogram2DData item from the chart.

void removeAll()

Removes all items from the chart.

Selecting data items

Function

Description

void selectItem(int itemIndex, boolean selected)

Selects/deselects (depending on selected value) chart item with given index.

void setSelectedItemIndices(int[] selectedIndices)

Selects only chart items with the given indices.

Parameters:
selectedIndices - an array with indices of chart items to be selected (other chart items will be deselected), may be null - this clears selection

int[] getSelectedItemIndices()

Returns the number of chart items (data items or data sets) currently displayed by this chart.

Updating chart data manually

Function

Description

void updateData()

Updates all data items displayed by this chart. 

Copying chart data to the Clipboard

Function

Description

String copyToClipboard()

Copies all chart data to the system clipboard in text form. Returns the text representation of all chart data.


Related topics

Chart Area

Chart Legend

Chart Grid and Labels

Updating Charts

Changing Chart Appearance at Runtime

 API Reference: Histogram2D Class