Manage widget dependencies (JS and CSS)
mainWidgets can declare specific JavaScript and CSS dependencies using a dependencies list. Dependencies follow the format type:name (e.g., js:d3 or css:histogram).
js:name: Loads a local JavaScript file from the project's static directory.css:name: Loads a local CSS file from the project's static directory.http...: If the dependency string starts withhttp, it is treated as an external CDN library.
Dependency Loading Priority:
- Core DataMap files (
datamap.js,data_selection_manager.js). - Widget-specific JS files.
- Widget-specific CSS files.
- External CDN libraries.
class HistogramWidget(WidgetBase):
dependencies = ["js:d3", "js:histogram", "css:histogram"]
# Example of how dependencies are parsed internally
# 'js:d3' -> type: 'js', name: 'd3'
# 'https://cdn...' -> type: 'external', name: 'https://cdn...'