anfra docs

Semantic UI

How the anfra SDK turns a page's interactions into semantic queries

A custom BI app connected directly to a semantic layer still has to handle every interaction itself. When a user picks a region, clicks a bar, or compares to last period, the agent writes code to rebuild each affected query: which filters apply to which charts, how a drill changes the grain, how to calculate the prior period. Every app does this differently, and this code is where the numbers usually go wrong.

Semantic UI is the layer between your frontend code and the semantic layer that handles this for you. Instead of building queries for each interaction, your page declares what it shows and how its parts are connected. anfra Server turns each interaction into a new semantic query.

Objects and connections

The anfra SDK gives your page two kinds of objects:

There are two ways to connect them, and nothing is connected until you declare it:

  • Control mappings (app.mapControl): which queries a control conditions, and on which field.
  • Cross-filters (app.mapCrossFilter): which queries are filtered by rows the reader selects in another query.

Each query then holds its own result, along with its state and any error. Your page reads these to draw each view.

Your page still decides how views look and how they respond to clicks. You can use any HTML, CSS, and charting library.

How an interaction runs

  1. The user changes an input or clicks a view. The page updates the matching control or selection and calls app.execute().
  2. The SDK sends the current queries, control values, and selections to anfra Server.
  3. The server applies the control mappings and cross-filters, resolves each affected query through the semantic layer, and runs it on the warehouse.
  4. Results return to the page. Your subscription redraws the views.

The numbers come from queries that anfra Server runs on your warehouse, using your metric definitions. Page code can still transform the returned rows in JavaScript, but that stays visible as page code: Inspect shows the server query, so nothing computed on top of it is hidden in a metric.

Inspect

Each result carries result.debug, with the AQL that actually ran (your query with the reader's filters, sorts and date drills applied), the generated SQL, when it ran and whether it came from cache. See Debug information.

Under anfra serve, the Inspect panel shows the same for every query in the open app, with its state and any error. See Build a data app.

Next steps

On this page