You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: site/sigmaguides/src/embedding_09_events_v3/embedding_09_events_v3.md
+24-20Lines changed: 24 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ lastUpdated: 2026-05-20
13
13
## Overview
14
14
Duration: 5
15
15
16
-
In this QuickStart, we demonstrate how to pass variables between the host application application and Sigma. Sigma is embedded in the host application using HTML iframe.
16
+
In this QuickStart, we demonstrate how to pass variables between the host application and Sigma. Sigma is embedded in the host application using an HTML iframe.
17
17
18
18
**Inbound Events:**<br>
19
19
These are variables sent from the host application to Sigma. **No listener needs to be coded into the iframe**. Sigma can use these messages to update control values. For example, passing a new value to a Sigma control that is used to filter table data.
@@ -145,8 +145,8 @@ We have designed this page to display an `Events Log` using JavaScript for easy
145
145
<imgsrc="assets/ev_5.png"width="800"/>
146
146
147
147
Event log types are color-coded:
148
-
-**Blue:**Host application to iframe (Inbound)
149
-
-**Green:**iframe to host application (Outbound)
148
+
-**Blue:**iframe to host application (Outbound)
149
+
-**Green:**Host application to iframe (Inbound)
150
150
151
151
The orange region buttons are part of the host application. Clicking any of them sends the selected region value to Sigma via the iframe.
152
152
@@ -160,9 +160,9 @@ For example, if we click the `East` button:
160
160
161
161
Clicking `East` initiates a two-step exchange:
162
162
163
-
1. The host application calls `setStoreRegion("East")`, which sends a `workbook:variables:update` message to Sigma via `postMessage`. This is the **outbound** event — logged in green in the Events Log and in the browser console.
163
+
1. The host application calls `setStoreRegion("East")`, which sends a `workbook:variables:update` message to Sigma via `postMessage`. This is the **inbound** event (host to Sigma) — logged in green in the Events Log and in the browser console.
164
164
165
-
2. Sigma receives the variable update, applies it to the embedded workbook, and sends back a `workbook:variables:onchange` confirmation. This is the **inbound** event — logged in blue.
165
+
2. Sigma receives the variable update, applies it to the embedded workbook, and sends back a `workbook:variables:onchange` confirmation. This is the **outbound** event (Sigma to host) — logged in blue.
166
166
167
167
Both events are visible in the `Events Log` panel and in the browser console simultaneously. The console is useful for inspecting the full payload structure, while the Events Log provides a human-readable view within the page.
168
168
@@ -174,6 +174,10 @@ Conversely, if you select `East and West` from the list control, we can see the
174
174
<strong>NOTE:</strong><br> We are using Chrome for this QuickStart but any browser with inspection functionality should work.
175
175
</aside>
176
176
177
+
If we add a simple bar chart, we can see the [workbook:chart:onvalueselect](https://help.sigmacomputing.com/docs/outbound-event-reference#workbookchartonvalueselect) event fire by clicking on a single bar:
178
+
179
+
<imgsrc="assets/ev_5c.png"width="800"/>
180
+
177
181

178
182
<!-- END -->
179
183
@@ -186,27 +190,27 @@ These listeners allow us to log and inspect messages to and from the iframe —
186
190
187
191
Two key code blocks handle message flow in our HTML file:
188
192
189
-
1.**Inbound events from Sigma to the iframe** are captured using a `window.addEventListener("message")` listener.
190
-
2.**Outbound events from the iframe to Sigma** are triggered via the `postMessage()` call in `setStoreRegion(region)`.
193
+
1.**Outbound events from Sigma to the host** are captured using a `window.addEventListener("message")` listener.
194
+
2.**Inbound events from the host to Sigma** are triggered via the `postMessage()` call in `setStoreRegion(region)`.
191
195
192
196
Each message is logged to the panel with a timestamp, type, payload, and directional label for clarity.
193
197
194
-
### Inbound events to the iframe
195
-
The specific code block for inbound events is:
198
+
### Outbound events from Sigma
199
+
The specific code block for outbound events is:
196
200
197
201
```copy-code
198
202
window.addEventListener("message", (event) => {
199
203
if (event.origin !== "https://app.sigmacomputing.com") return;
200
204
201
205
const { type } = event.data || {};
202
-
console.log("Host Application to iframe (Inbound)", event.data);
206
+
console.log("iframe to Host Application (Outbound)", event.data);
@@ -250,15 +254,15 @@ function setStoreRegion(region) {
250
254
}
251
255
```
252
256
253
-
Here is an explanation of the first command:
257
+
Here is an explanation of the `getElementById` call:
254
258
255
-
<imgsrc="assets/ev_8.png"width="500"/>
259
+
<img src=”assets/ev_8.png” width=”500”/>
256
260
257
-
The second command sends a new value for the variable called “StoreRegion” to the Sigma iframe using the JavaScript postmessage method. PostMessage() is a global method that safely enables cross-origin communication. It’s a lot like Ajax, but with cross-domain capability (i.e., communication between two websites).
261
+
The `postMessage()` call sends a new value for the variable `StoreRegion` to the Sigma iframe. `postMessage()` is a global method that safely enables cross-origin communication between a host page and an embedded iframe.
258
262
259
-
Here is an explanation of the second command:
263
+
Here is an explanation of the `postMessage()` call:
0 commit comments