Base Plot Strategy¶
Abstract base class for all plot strategies.
base_plot_strategy ¶
Base Plot Strategy - Abstract Base Class.
This module defines the interface for all plot strategies following the Strategy Pattern.
Classes:
| Name | Description |
|---|---|
BasePlotStrategy | Abstract base class for plot strategies. |
Notes
All concrete strategies must implement: - validate_data() - process_data() - create_figure()
Classes¶
BasePlotStrategy ¶
Bases: ABC
Abstract base class for plot generation strategies.
This class defines the common interface that all plot strategies must implement. It follows the Template Method pattern, where generate_plot() orchestrates the overall process while leaving specific steps to be implemented by subclasses.
Attributes:
| Name | Type | Description |
|---|---|---|
config | Dict[str, Any] | Complete configuration from YAML file |
metadata | Dict[str, Any] | Metadata section from config |
viz_config | Dict[str, Any] | Visualization section from config |
validation_rules | Dict[str, Any] | Validation rules from config |
Notes
Subclasses must implement three abstract methods: - validate_data() - Validate input data - process_data() - Process and transform data - create_figure() - Create Plotly figure
Initialize base strategy with configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | Dict[str, Any] | Complete configuration dictionary from YAML. | required |
Source code in src/domain/plot_strategies/base/base_plot_strategy.py
Functions¶
validate_data abstractmethod ¶
Validate input data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df | DataFrame | Input data to validate. | required |
Raises:
| Type | Description |
|---|---|
ValueError | If validation fails. |
Source code in src/domain/plot_strategies/base/base_plot_strategy.py
process_data abstractmethod ¶
Process and transform data for visualization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df | DataFrame | Input data. | required |
Returns:
| Type | Description |
|---|---|
DataFrame | Processed data ready for visualization. |
Source code in src/domain/plot_strategies/base/base_plot_strategy.py
create_figure abstractmethod ¶
Create Plotly figure from processed data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processed_df | DataFrame | Processed data. | required |
Returns:
| Type | Description |
|---|---|
Figure | Configured Plotly figure. |
Source code in src/domain/plot_strategies/base/base_plot_strategy.py
apply_filters ¶
Apply filters to data.
This is a common implementation that can be overridden by subclasses if needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df | DataFrame | Data to filter. | required |
filters | Optional[Dict[str, Any]] | Filter specifications. | None |
Returns:
| Type | Description |
|---|---|
DataFrame | Filtered data. |
Source code in src/domain/plot_strategies/base/base_plot_strategy.py
apply_customizations ¶
Apply custom styling to figure.
This is a hook for future customization features (FLEXIVEL and FLEXIVEL2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fig | Figure | Base figure. | required |
customizations | Optional[Any] | Customization specifications. | None |
Returns:
| Type | Description |
|---|---|
Figure | Customized figure. |
Source code in src/domain/plot_strategies/base/base_plot_strategy.py
generate_plot ¶
generate_plot(data: DataFrame, filters: Optional[Dict[str, Any]] = None, customizations: Optional[Any] = None) -> go.Figure
Generate complete plot (Template Method).
This method orchestrates the entire plot generation process: 1. Validate input data 2. Process data 3. Apply filters 4. Create figure 5. Apply customizations
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data | DataFrame | Input data. | required |
filters | Optional[Dict[str, Any]] | Filters to apply. | None |
customizations | Optional[Any] | Customizations to apply. | None |
Returns:
| Type | Description |
|---|---|
Figure | Complete Plotly figure. |
Raises:
| Type | Description |
|---|---|
ValueError | If validation fails. |