displayNumberAsStat Documentation
Purpose
The node is designed to format and display a numerical value as a statistical component. This is particularly useful in analytics dashboards where users need to visualize key performance indicators (KPIs) or other numerical data in a concise and readable format. It allows for customizable titles, subtitles, footers, and units, enhancing the overall user experience in interpreting statistical data.
Settings
1. Title
- Type: String
- Description: The title that appears prominently at the top of the statistical display. This is a key identifier for the metric being shown.
- Default Value:
undefined(the title will be derived from inputs in its absence).
2. Subtitle
- Type: String
- Description: A secondary line that provides context or additional details about the value being displayed. It can help distinguish between similar metrics.
- Default Value:
undefined(the subtitle will be derived from inputs in its absence).
3. Footer Text
- Type: String
- Description: Text that appears at the bottom of the statistic. This can be useful for providing credit, sources, or additional context around the displayed value.
- Default Value:
undefined(the footer will be derived from inputs in its absence).
4. Value Input
- Type: Numeric
- Description: The core numerical value that is being formatted and displayed. This is the essential data that the user wants to visualize.
- Default Value:
undefined(the value will be derived from inputs in its absence).
5. Units
- Type: String
- Description: Text that represents the units measurement of the value displayed (e.g., "USD", "kg", "items"). This provides clarity on what the number represents.
- Default Value: An empty string (
"") (will default to no units if not specified).
6. Precision
- Type: Numeric
- Description: This setting defines the number of decimal places to which the input value will be rounded. It is essential for maintaining consistency and accuracy in reporting numerical data.
- Default Value:
undefined(if not specified, it defaults to zero, rounding the value to a whole number).
How It Works
The node performs the following steps:
- It retrieves various input values from the
inputsobject, which includes the title, subtitle, footer text, numerical value, units, and precision. - It ensures the precision is a non-negative integer by taking the maximum of
0and converting the provided precision input. - The core numerical value is formatted to the specified precision using
Number.toFixed(). - The formatted number is combined with its units to form a complete representation (e.g., "123.45 kg").
- Finally, the function returns a configuration object for the statistical component that includes all the formatted details and any additional configurations passed in.
Data Expectations
The function expects input data in a structured format resembling:
{
"inputs": {
"title": "Total Sales",
"subtitle": "As of Q1 2023",
"footer": "Source: Internal Database",
"input1": 12345.678,
"units": "USD",
"precision": 2
},
"config": {}
}Where config may include additional layout or display settings for integration within the overall analytics platform.
Use Cases & Examples
Use Cases
- Financial Reporting: A finance team needs to display total sales for a quarter along with relevant subtitles for context.
- User Metrics Tracking: A product team analyzes the number of active users versus the previous month and seeks clarity through statistical display.
- Sales Metric Improvement: Marketing teams display current conversion rates from a campaign, requiring precision to track minute changes in performance.
Example Configuration
Scenario: Display Total Sales for a Quarter
A finance team wants to visualize the total sales reported in Q1, making it clear that the number is in USD and rounding to two decimal places.
Configuration Data:
{
"inputs": {
"title": "Total Sales",
"subtitle": "As of Q1 2023",
"footer": "Source: Internal Database",
"input1": 15320.548,
"units": "USD",
"precision": 2
},
"config": {
"tile_type": "stat"
}
}Expected Output:
- Title: Total Sales
- Subtitle: As of Q1 2023
- Footer: Source: Internal Database
- Value: 15320.55 USD
Through this configuration, the finance team can present a neat and informative statistical tile on their analytics dashboard, making performance metrics easily interpretable at a glance.