Skip to content

Commit 2b3050c

Browse files
committed
events-9-corrections
1 parent 8f84c2b commit 2b3050c

5 files changed

Lines changed: 24 additions & 20 deletions

File tree

148 KB
Loading
274 KB
Loading
-204 KB
Loading
270 KB
Loading

site/sigmaguides/src/embedding_09_events_v3/embedding_09_events_v3.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ lastUpdated: 2026-05-20
1313
## Overview
1414
Duration: 5
1515

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.
1717

1818
**Inbound Events:**<br>
1919
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
145145
<img src="assets/ev_5.png" width="800"/>
146146

147147
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)
150150

151151
The orange region buttons are part of the host application. Clicking any of them sends the selected region value to Sigma via the iframe.
152152

@@ -160,9 +160,9 @@ For example, if we click the `East` button:
160160

161161
Clicking `East` initiates a two-step exchange:
162162

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.
164164

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.
166166

167167
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.
168168

@@ -174,6 +174,10 @@ Conversely, if you select `East and West` from the list control, we can see the
174174
<strong>NOTE:</strong><br> We are using Chrome for this QuickStart but any browser with inspection functionality should work.
175175
</aside>
176176

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+
<img src="assets/ev_5c.png" width="800"/>
180+
177181
![Footer](assets/sigma_footer.png)
178182
<!-- END -->
179183

@@ -186,27 +190,27 @@ These listeners allow us to log and inspect messages to and from the iframe —
186190

187191
Two key code blocks handle message flow in our HTML file:
188192

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)`.
191195

192196
Each message is logged to the panel with a timestamp, type, payload, and directional label for clarity.
193197

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:
196200

197201
```copy-code
198202
window.addEventListener("message", (event) => {
199203
if (event.origin !== "https://app.sigmacomputing.com") return;
200204
201205
const { type } = event.data || {};
202-
console.log("Host Application to iframe (Inbound)", event.data);
206+
console.log("iframe to Host Application (Outbound)", event.data);
203207
204208
const logContainer = document.getElementById("event-output");
205209
const logItem = document.createElement("li");
206210
logItem.style.marginBottom = "8px";
207211
logItem.style.color = "blue";
208212
logItem.innerHTML = `
209-
<strong style="text-decoration: underline;">Host Application to iframe (Inbound)</strong><br/>
213+
<strong style="text-decoration: underline;">iframe to Host Application (Outbound)</strong><br/>
210214
<strong>Timestamp:</strong> ${new Date().toLocaleTimeString()}<br/>
211215
<strong>Event Type:</strong> ${type || "unknown"}<br/>
212216
<strong>Payload:</strong> <code>${JSON.stringify(event.data, null, 2)}</code>
@@ -217,8 +221,8 @@ window.addEventListener("message", (event) => {
217221

218222
This block listens for messages from Sigma and logs them using the message event.
219223

220-
### Outbound events from the iframe
221-
This function sends variable updates to Sigma and logs the outbound message.
224+
### Inbound events to Sigma
225+
This function sends variable updates to Sigma and logs the inbound message.
222226

223227
```copy-code
224228
function setStoreRegion(region) {
@@ -233,14 +237,14 @@ function setStoreRegion(region) {
233237
message,
234238
"https://app.sigmacomputing.com"
235239
);
236-
console.log("iframe to Host Application (Outbound)", message);
240+
console.log("Host Application to iframe (Inbound)", message);
237241
238242
const logContainer = document.getElementById("event-output");
239243
const logItem = document.createElement("li");
240244
logItem.style.marginBottom = "8px";
241245
logItem.style.color = "green";
242246
logItem.innerHTML = `
243-
<strong style="text-decoration: underline;">iframe to Host Application (Outbound)</strong><br/>
247+
<strong style="text-decoration: underline;">Host Application to iframe (Inbound)</strong><br/>
244248
<strong>Timestamp:</strong> ${new Date().toLocaleTimeString()}<br/>
245249
<strong>Event Type:</strong> ${message.type}<br/>
246250
<strong>Payload:</strong> <code>${JSON.stringify(message, null, 2)}</code>
@@ -250,15 +254,15 @@ function setStoreRegion(region) {
250254
}
251255
```
252256

253-
Here is an explanation of the first command:
257+
Here is an explanation of the `getElementById` call:
254258

255-
<img src="assets/ev_8.png" width="500"/>
259+
<img src=assets/ev_8.png width=500/>
256260

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.
258262

259-
Here is an explanation of the second command:
263+
Here is an explanation of the `postMessage()` call:
260264

261-
<img src="assets/ae6.png" width="600"/>
265+
<img src=assets/ae6.png width=600/>
262266

263267
```plaintext
264268
sigma_iframe.contentWindow.postMessage({type:"workbook:variables:update", variables: {StoreRegion: "West"},}, 'https://app.sigmacomputing.com',);

0 commit comments

Comments
 (0)