The SAS Visual Analytics Embed page now covers mapping report parameters to DC columns from the URL, which the name-based match cannot do for two report objects filtering the same column from differently-named parameters. - new "Mapping parameters to columns" section: the `va_parmap` grammar, the lower-case example, what overrides what, and the rules that matter to a report author (last-hyphen split, label-then-name key matching, one parameter to one column, no fallback to the name match) - the warning banner is documented next to it, including that a parameter is ignored rather than filtered on the wrong column - the `?embed=` table now shows the Filter button per mode, so it is explicit that `embed=true` keeps Data Controller's own filter builder while `embed=va` hands filtering to the report
96 lines
5.8 KiB
Markdown
96 lines
5.8 KiB
Markdown
---
|
|
layout: article
|
|
title: SAS Visual Analytics Embed
|
|
description: Embed the Data Controller editor inside a SAS VA report as a data-driven content object. Row selections in the VA report drive filters and column visibility in the editor.
|
|
---
|
|
|
|
# Embedding inside SAS Visual Analytics
|
|
|
|
Data Controller can be embedded inside a SAS Visual Analytics report as a **data-driven content** (DDC) object. This unlocks scenarios where a user can safely modify the values in an underlying SAS table, and have the visualisation updated- all from inside the same report.
|
|
|
|
## URL
|
|
|
|
Open the editor as a DDC by appending `?embed=va` to the editor route:
|
|
|
|
```
|
|
|
|
`https://yourserver/DC/#/editor/<library>/<table>?embed=va`
|
|
|
|
```
|
|
|
|
The `?embed=` parameter accepts three values:
|
|
|
|
| Value | Chrome | Filter button |
|
|
|---|---|---|
|
|
| `true` | hidden | **shown** - Data Controller's own filter builder works as usual |
|
|
| `va` | hidden | **hidden** - filtering comes from the report instead (see below) |
|
|
| `false` (or omitted) | shown | shown |
|
|
|
|
Chrome means the header, the back button and the sub-nav. In `va` mode the editor is also VA-aware: the report's filters are captured and applied as you change selections, and the columns the grid shows can be controlled from the report's Edit Report interface. Because the report owns the filter in that mode, Data Controller's own **Filter** button is not offered - use the report's controls instead.
|
|
|
|
## How VA drives the editor
|
|
|
|
VA pushes a JSON payload to the iframe via `window.postMessage` whenever the selected rows change. Data Controller listens for these messages and:
|
|
|
|
1. Resolves each VA `parameter` to a DC column by matching on column label.
|
|
2. Builds a filter (using existing [Filter](/filter/) machinery) over the selected values.
|
|
3. Hides any VA columns marked as `brush` so the grid stays focused on the user-editable columns (except primary key cols which are always shown)
|
|
|
|
If VA sends an empty / unmatched message the editor falls back to the unfiltered view but stays in VA mode.
|
|
|
|
More logic available in [`va-messaging.service.ts'](https://git.datacontroller.io/dc/dc/src/branch/main/client/src/app/services/va-messaging.service.ts).
|
|
|
|
## Mapping parameters to columns
|
|
|
|
By default each VA `parameter` is matched to a DC column by name: a parameter whose label is a column of the table filters that column. That means two DC instances in the same report can only filter the same column from a parameter of the same name - so two report tabs cannot hold different filters on one column.
|
|
|
|
The `va_parmap` URL parameter overrides the name match, one entry per mapping, `<VA parameter>-<DC column>`:
|
|
|
|
```text
|
|
https://yourserver/DC/#/editor/<library>/<table>?embed=va&va_parmap=REGION_TAB1-REGION
|
|
```
|
|
|
|
Repeat the parameter to add mappings. A report with two tabs, each holding its own instance of the same table and filtering the same column from its own report parameter:
|
|
|
|
| Report tab | DDC URL |
|
|
|---|---|
|
|
| Tab 1 | `...?embed=va&va_parmap=REGION_TAB1-REGION` |
|
|
| Tab 2 | `...?embed=va&va_parmap=REGION_TAB2-REGION` |
|
|
|
|
The mapping is per parameter, and additive:
|
|
|
|
- a mapped parameter always filters the column it names; that column's type in the table decides how the value is formatted, exactly as for a name match
|
|
- a parameter with no mapping keeps the default name match, so a single instance can mix mapped and unmapped parameters
|
|
- the key is matched case-insensitively against the parameter's label, then against its internal name (e.g. `pr273`)
|
|
- an entry is split at its last `-`, so a label may itself contain hyphens (`Sales-2024-DEPT` maps the label `Sales-2024` to `DEPT`)
|
|
- if the named column is not in the table being opened, the parameter is ignored rather than falling back to the name match - a typo cannot silently filter the wrong column
|
|
- a column name that is not a plain SAS name is ignored
|
|
- the mapping applies to filtering only; which columns the grid displays still follows the columns VA sends
|
|
|
|
If an entry cannot be used the editor shows a warning banner above the grid naming the parameter, the column and the table - for example when the column is not in the table being opened, or the entry is not in the `parameter-column` form. The parameter is then ignored rather than falling back to the name match, so a typo never silently filters the wrong column, and the banner is what distinguishes "the mapping is wrong" from a view that simply has no filter.
|
|
|
|
!!! note
|
|
A parameter label containing `&` must be percent-encoded (`%26`), because `&` separates query parameters. A space may be written as `+` or `%20`.
|
|
|
|
## Filter Modes
|
|
|
|
When running in `embed=va` mode, the editor provides two filter modes, controlled by the **Auto-apply** checkbox:
|
|
|
|
* **Live (default)** - the editor updates automatically as you select rows in the VA report, so the data you see always matches your current selection.
|
|
* **Confirm** - filter changes are held until you click the **Apply** button. This is useful when editing, where an automatic reload would discard unsaved changes.
|
|
|
|
A status indicator shows whether a filter change is pending, loading, or idle. In edit mode, a pending filter is held until you leave edit mode, so your unsaved edits are never lost.
|
|
|
|
## Configuration in VA
|
|
|
|
In the VA Report Designer, add a **Data-Driven Content** object and set the URL to the editor route shown above. Be sure that any report level filters have their corresponding parameters added to the DDC object itself.
|
|
|
|
## Debugging
|
|
|
|
A hook script can tell an embedded editor from a standalone one without any client-side inspection: `work.browser_info` carries the page URL and `referrer`, and `work.browser_url_vars` carries `embed=va`. See [Browser Variables](/developer-guide/browser-variables/).
|
|
|
|
The following snippet can be used in console to dump the values being provided to DC from VA:
|
|
|
|
```
|
|
console.log(JSON.stringify(window.__vaLastMessage?.data, null, 2))
|
|
``` |