Scripting Widget Interactions and Data Source Filtering in Analytics Designer (Part 4)
Preview · a free account unlocks the full lesson
Learn how to use Analytics Designer's scripting language to wire up widget events, control filters on data sources, and synchronize multiple charts/tables so an analytic application behaves like a purpose-built app rather than a static story.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Analytics Designer separates itself from standard Stories by giving consultants a scripting layer (a JavaScript-like language specific to SAC) that runs against Application, Page, and Widget objects.
Once a project moves past simple drag-and-drop dashboards, script becomes necessary to deliver behaviors like: filtering one chart based on selection in another, showing/hiding panels based on user role or dropdown value, resetting filters with a button, or triggering data refresh only after several inputs are set.
This is the core reason Analytics Designer exists as a separate tool from Optimized Story Experience with basic interactivity.
The object model matters: an Application contains Pages, Pages contain Widgets (charts, tables, dropdowns, buttons, shapes, script variables), and Widgets expose Data Sources when bound to a model (SAC live/import model, which may itself be sourced from a Datasphere space via live connection or replication). Each widget type exposes a scripting API surface - for example a Chart widget exposes methods like getDataSource(), setDimensionFilter(), and event handlers like onResultChanged or onSelect. A Dropdown/Input Control exposes onSelect with the selected value, and a Button exposes onClick.
A typical interaction pattern: a Dropdown widget's onSelect script calls Chart_1.getDataSource().setDimensionFilter('Region', Dropdown_1.getSelectedKey()) to filter a chart by the chosen region. More advanced flows chain filters across multiple widgets, use Script Variables to hold intermediate state (e.g., a selected year that several widgets read), and use Application-level scripts (onInitialization) to set default filters/date ranges before the user does anything, avoiding an initial full-context expensive query.
Create a free account to keep reading
You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.
- Full explanation
- Code example
- Real project scenario
- Common mistakes
- Best practices
- Interview angle
One tap with Google works too. Every topic keeps its first lesson open to everyone.
Keep exploring
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.