Plotly Storage Sunburst#
Interactive Plotly storage sunburst charts and hierarchical tree builders.
- lanspector.sunburst.build_sunburst_figure(reader, table=None, subdir=None, limit=500, max_depth=None, color_by='age', title=None)[source]#
Build an interactive Plotly storage sunburst figure from a crawl database.
Uses
plotly.graph_objects.Sunburstwithbranchvalues="total"so analysts can click any ring to zoom into storage hotspots and identify stale directories for cleanup.- Parameters:
- reader
An open
CrawlReaderor path to a SQLite crawl DB.- table
Crawl table name (defaults to latest crawl).
- subdir
Optional subdirectory prefix filter.
- limit
Maximum number of top directories to include (
Nonefor all).- max_depth
Optional maximum ring depth relative to the common root.
- color_by
Color scale metric:
"age"(days since last access) or"size"(bytes).- title
Optional custom chart title.
- Returns:
- plotly.graph_objects.Figure
Interactive Plotly Sunburst figure.
- Parameters:
- Return type:
Figure
- lanspector.sunburst.export_sunburst_html(reader, output, table=None, subdir=None, limit=500, max_depth=None, color_by='age', include_plotlyjs='inline', open_browser=False)[source]#
Render and save a standalone interactive Plotly HTML sunburst chart.
- Parameters:
- reader
An open
CrawlReaderor path to a SQLite crawl DB.- output
Destination HTML file path.
- table
Crawl table name (defaults to latest crawl).
- subdir
Optional subdirectory prefix filter.
- limit
Maximum top directories to include.
- max_depth
Optional maximum folder ring depth.
- color_by
Color metric (
"age"or"size").- include_plotlyjs
"inline"embeds Plotly.js for offline/air-gapped viewing;"cdn"links CDN.- open_browser
Open the generated HTML file in the system default browser when
True.
- Returns:
- pathlib.Path
Resolved path to the generated HTML file.
- Parameters:
- Return type:
- lanspector.sunburst.build_sunburst_hover_text(hierarchy)[source]#
Build formatted Plotly hover overlay labels with auto-scaled byte sizes.
- Parameters:
- hierarchy
Node table returned by
paths_to_hierarchy_df().
- Returns:
- list[str]
HTML hover overlay strings (one per row) with human-readable
TB/GB/MB/KBsizes, root share percentage, and last-access date.
- Parameters:
hierarchy (DataFrame)
- Return type:
- lanspector.sunburst.format_bytes(num_bytes)[source]#
Format num_bytes into a concise human-readable string (e.g.
12.40 GB).
- lanspector.sunburst.paths_to_flare_dict(df, path_col='path', size_col='size', jout=None)[source]#
Convert a directory-size DataFrame into a nested flare JSON tree dictionary.
- Parameters:
- df
DataFrame with path and size columns.
- path_col
Column containing directory paths.
- size_col
Column containing numeric byte sizes.
- jout
Optional path to persist the resulting JSON tree to disk.
- Returns:
- dict[str, Any]
Nested
{"name": ..., "children": [...]}hierarchy dictionary.
- Parameters:
- Return type:
- lanspector.sunburst.paths_to_hierarchy_df(df, path_col='path', size_col='size', atime_col='max_atime', max_depth=None)[source]#
Aggregate a flat directory-size DataFrame into a Plotly Sunburst node table.
Rolls up descendant byte sizes onto every ancestor node so
branchvalues="total"holds strictly across the entire tree.- Parameters:
- df
DataFrame with
path,size, and optionalmax_atimecolumns.- path_col
Column name holding directory paths.
- size_col
Column name holding immediate byte sizes.
- atime_col
Optional column name holding latest access timestamps.
- max_depth
Optional depth limit below the common root prefix.
- Returns:
- pandas.DataFrame
DataFrame with columns
id,label,parent,size,max_atime,age_days.
- Parameters:
- Return type: