ForecastTile Documentation
Overview
The ForecastTile component is an AI-powered visualization tool that generates forecasts based on historical data. It employs machine learning models to predict future values and provides an interactive interface for users to view and analyze these predictions. The ForecastTile is designed to dynamically update its data based on user configuration and cached results, ensuring efficient data retrieval and visualization.
Purpose
The primary purpose of the ForecastTile is to provide users with a clear and insightful graphical representation of potential future trends based on existing data. This feature is particularly useful for businesses needing to anticipate market shifts, financial forecasts, resource allocation, etc.
Settings
Title
- Input Type: String
- Description: The title of the ForecastTile. This appears prominently at the top of the tile.
- Default Value:
'AI Forecast'
Subtitle
- Input Type: String
- Description: An optional subtitle that provides additional context or information about the forecast.
- Default Value:
undefined
FooterText
- Input Type: String
- Description: Text displayed at the bottom of the ForecastTile.
- Default Value:
undefined
FooterColor
- Input Type: String
- Description: Specifies the color of the footer text. This allows for customization based on the dashboard theme.
- Default Value:
undefined
Config Properties
WorkflowId
- Input Type: String
- Description: An identifier for the workflow associated with the forecast. Influences how the forecast is generated based on the selected workflow context.
- Default Value:
undefined
ForecastPrompt
- Input Type: String
- Description: The prompt that guides the AI in generating the forecast. It must be set for the forecast generation process to occur.
- Default Value:
undefined
ChartType
- Input Type: Dropdown (options are 'line' or 'bar')
- Description: Determines the type of chart used for the display. Affects how the data is visualized: either as line graphs or bar charts.
- Default Value:
'line'
ForecastModel
- Input Type: Dropdown (options include various statistical and machine learning models)
- Description: Specifies the statistical model to be used for generating forecasts. Depending on selection, the accuracy and the behavior of predictions might vary.
- Default Value:
'auto'
ConfidenceLevel
- Input Type: Numeric/String
- Description: Represents the confidence level for the forecast intervals. It defines the range of uncertainty around each forecast point, enhancing user understanding of predictions.
- Default Value:
'95'
SourceDataSnapshot
- Input Type: Array
- Description: Contains a pre-captured snapshot of data used to perform the forecast. This is particularly useful when re-generating forecasts and enhances efficiency.
- Default Value:
undefined
SkipAnimation
- Input Type: Boolean
- Description: Allows users to disable animation when switching between tabs. This can improve performance during rapid interactions.
- Default Value:
false
How It Works
The ForecastTile component operates in the following manner:
-
Data Retrieval:
- On initial load, it checks if forecast data exists in the session cache.
- If not found, it fetches new forecast data based on settings provided in the configuration.
-
AI Integration:
- The component fetches forecast data asynchronously from an API endpoint (
/api/ai/forecast), which accepts parameters such asworkflowId,forecastPrompt,existingData, andmodel.
- The component fetches forecast data asynchronously from an API endpoint (
-
Data Display:
- Once forecast data is available, the component renders it using either a line graph or a bar chart based on user preferences. It also shows confidence intervals as needed.
-
Caching:
- The component persists generated forecasts in a session-level cache (
forecastCache), enabling fast access during tab switches without needing to refetch.
- The component persists generated forecasts in a session-level cache (
-
Error Handling:
- It includes provisions for handling loading states and errors during data fetching, providing users with informative messages and retry options.
Use Cases & Examples
Use Case 1: Financial Forecasting
A financial analyst uses the ForecastTile to analyze market trends based on historical sales data. By configuring the facility to forecast potential revenue for the next six months, they leverage AI to understand possible outcomes under different economic scenarios.
Use Case 2: Resource Allocation in Supply Chain
A supply chain manager utilizes the ForecastTile to predict inventory needs for the upcoming quarter. Adjusting the forecastPrompt to focus on seasonal demand can help optimize stock levels, reducing both surplus and shortages.
Detailed Example Configuration
To implement a resource allocation use case, the configuration data could be set as follows:
{
"title": "Quarterly Inventory Forecast",
"subtitle": "Predicting inventory needs for Q4 based on historical data",
"config": {
"workflowId": "inventory-workflow-2023Q4",
"forecastPrompt": "Forecast inventory requirements based on past sales data from Q1 to Q3.",
"chartType": "bar",
"forecastModel": "auto",
"confidenceLevel": "90",
"sourceDataSnapshot": [
{ "label": "January", "value": 120, "isForecast": false },
{ "label": "February", "value": 135, "isForecast": false },
{ "label": "March", "value": 150, "isForecast": false }
]
}
}In this example configuration, the ForecastTile is tailored to forecast inventory based on historical sales, utilizing various settings that prepare the tile for effective data visualization.