### ===================================================================================================================
### FUNCTION: Create template for the Plolty plots for VIIA
### ===================================================================================================================
# Copyright ©VIIA 2025
### ===================================================================================================================
### 1. Import modules
### ===================================================================================================================
# General imports
from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING, Optional
# References for functions and classes in the haskoning_structural package
from haskoning_structural.fem_plots import fem_create_template_plotly
# References for functions and classes in the viiaPackage
if TYPE_CHECKING:
from viiapackage.viiaStatus import ViiaProject
### ===================================================================================================================
### 2. Create plotly template
### ===================================================================================================================
[docs]def viia_create_template_plotly(project: ViiaProject = None, template_json: Optional[Path] = None):
"""
This function creates a plotly template from a JSON file. If no file is provided, it uses the default template from
the json file.
Input:
- project (obj): Project object containing collections of fem objects and project variables.
- template_json (Path): Path to the JSON file containing the plotly template. If None, the default template is
used. Default is None.
Output:
- A plotly layout template object created from the JSON file.
For example:
>>> plotly.graph_objects.Figure(data=data, layout={'template': viia_create_template_plotly(project=project)})
"""
if not template_json:
template_json = Path(__file__).parent.parent / 'viiaGraph.json'
return fem_create_template_plotly(template_json=template_json)
### ===================================================================================================================
### 3. End of script
### ===================================================================================================================