Difference between revisions of "OnGraphClick"

Line 31: Line 31:
 
When the click falls on a data point, the locals <code>coord</code> and <code>coordPos</code> provide the index coordinates of the data point. <code>coord</code> has the [[IndexValue]]s whereas <code>coordPos</code> has the positions along the indexes.
 
When the click falls on a data point, the locals <code>coord</code> and <code>coordPos</code> provide the index coordinates of the data point. <code>coord</code> has the [[IndexValue]]s whereas <code>coordPos</code> has the positions along the indexes.
  
 +
=== Clicking in a key ===
 +
This case occurs if you click in the bounding rectangle of a key.  A graph can have multiple keys at one time (e.g., a color key, symbol key and symbol size key).  A single key may also combine multiple roles when the same dimension is mapped to multiple graphing roles.
  
 +
You can test for this case using <code>If where="key" Then</code>.
  
=== Clicking in a key ===
+
When an index is assigned to the key, <code>dim</code> will have a single item, a [[handle]] to that index. If in addition, the user clicks on a key item, the label for that item appears in <code>coord</code> and the position of that item in the index appears in <code>coordPos</code>.  If the click was not on a key item, then the single item in <coord>coord</code> is null and the single item in <code>coordPos</code> is 0.
 +
 
 +
When a value is assigned to the key, ** TBD ***
  
 
=== Clicking on an axis title ===
 
=== Clicking on an axis title ===

Revision as of 00:19, 23 September 2020

A feature proposed for Analytica 5.5

** This page is under construction **

OnGraphClick

The OnGraphClick attribute holds an expression that is evaluated when an end-user clicks the mouse on the variable's result graph. Information about where the click occurred is through several local variables that are set before the expression is evaluated.

Your expression should return true if you want the normal processing of the mouse click to continue. It should return false if you want to suspend the normal processing. If you suspend processing of the click, then datum balloons won't show, key items won't toggle, and zooming by dragging a rubber band rectangle won't work (unless you hold the shift key while dragging).

One example usage sets input variables in the model based on what the user clicks on.

Special local variables

Several local variables are set so that your expression can figure out what was clicked on. The set of locals that are meaningful depends on which part of the graph the user clicked.

  • where: Indicates which part of the graph was clicked on. Possible values are: "plotArea", "key", "axisTitle", "axisLabels" and "background".
  • click_x and click_y: The pixel coordinates of the mouse click relative to the top-left corner.
  • dim: An index used when specifying a data coordinate. The elements are handles of the indexes that are present in the graph (a subset of all the indexes, depending on what's clicked on).
  • coord: The coordinate (by IndexValues) of the data point that was clicked on, or null in the click was not on a datum. This is a one-dimensional array indexed by dim. The cell corresponding to the index in dim contains the value of the index.
  • coordPos: The coordinate (by positions) of the data point that was clicked on, or null in the click was not on a datum. This is a one-dimensional array indexed by dim. The cell corresponding to the index in dim contains the position within the given index.
  • info: This is the same as for OnGraphDraw.
  • roles: This is the same as for OnGraphDraw.

Clicking in the plot area

The plot area is the rectangle bounded by and contained within the horizontal and vertical axes.

You can test for this case using If where="plotArea" Then.

When you click in the plot area, the click may fall either on a data point (which includes within the bar area in a bar chart), on a line segment between two data points (which includes in the fill area in a filled line chart), or on the background of the plot area.

When the click falls on a data point, the locals coord and coordPos provide the index coordinates of the data point. coord has the IndexValues whereas coordPos has the positions along the indexes.

Clicking in a key

This case occurs if you click in the bounding rectangle of a key. A graph can have multiple keys at one time (e.g., a color key, symbol key and symbol size key). A single key may also combine multiple roles when the same dimension is mapped to multiple graphing roles.

You can test for this case using If where="key" Then.

When an index is assigned to the key, dim will have a single item, a handle to that index. If in addition, the user clicks on a key item, the label for that item appears in coord and the position of that item in the index appears in coordPos. If the click was not on a key item, then the single item in <coord>coord is null and the single item in coordPos is 0.

When a value is assigned to the key, ** TBD ***

Clicking on an axis title

Clicking in the axis label area

Clicking on the background

The background is any area outside of the plot area rectangle, outside of any key, and outside of the axis title or label areas.

You can test for this case using If where="background" Then.

The locals dim, coord and coordPos are null.

Comments


You are not allowed to post comments.