Formulas
The formula editor is where you construct business logic for your application in Nordcraft. It provides a powerful yet accessible way to transform data, perform calculations and implement conditional logic throughout your application.
Formulas in Nordcraft are expressions that:
- Perform logical operations and data transformations
- Execute mathematical calculations
- Filter, search, and manipulate data
- Return consistent results for the same inputs
Formulas are pure functions, which means they:
- Have no side effects (don't modify external state)
- Always return the same output given the same input(s)
- Can be composed together to build more complex logic
A pure function always returns the same result for the same inputs and doesn't change anything outside of itself, ensuring predictability and reliability.
The formula editor
The formula editor appears when editing formulas and wherever you see an fx
button in the Nordcraft interface:
- In the attributes panel when binding values
- In the style variables panel
- In the data panel when defining formulas
- ...
In the formula editor, you can:
- Reference variables, attributes, and other data
- Use built-in functions and operators
- Compose complex logic from simpler operations
- See live preview results as you type
Full-screen mode
For complex formulas, Nordcraft provides a full-screen view of the formula editor. It offers a larger canvas, better visibility of logic and easier navigation for formulas with many operations. To expand, click the icon button in the top-right corner.
Formula foundations
Built on the modern web platform, Nordcraft offers many built-in formulas that closely align with similarly named JavaScript functions. Familiarity with these JavaScript concepts can help you create more effective formulas:
- Array methods (map, filter, reduce, etc.)
- Object methods (keys, values, entries, etc.)