Skip to content

Commit e5c1718

Browse files
Merge pull request #27 from nfdi4cat/gen_chart_update
Update metadata chart assets and generator
2 parents 7a567d5 + c27cbcb commit e5c1718

8 files changed

Lines changed: 118 additions & 806 deletions

docs/assets/metadata_characterization_hierarchy.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/assets/metadata_collapsed_charts_all_sheets.html

Lines changed: 0 additions & 800 deletions
This file was deleted.

docs/assets/metadata_coremeta4cat_overview.html

Lines changed: 25 additions & 0 deletions
Large diffs are not rendered by default.

docs/assets/metadata_reaction_hierarchy.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/assets/metadata_simulation_hierarchy.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/assets/metadata_synthesis_hierarchy.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ The Simulation metadata group specifies the essential information for reporting
104104
## Interactive diagram
105105

106106
<iframe
107-
src="assets/metadata_collapsed_charts_all_sheets.html"
107+
src="assets/metadata_coremeta4cat_overview.html"
108108
width="100%"
109109
height= "800vh"
110110
style="border: 2px solid #5C88DA; background-color: #F0F8FF;

scripts/generate_charts.py

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,88 @@ def build_sunburst_chart(schema: dict, class_name: str) -> str:
244244
"""
245245

246246

247+
# ─────────────────────────────────────────────────────────────────────────────
248+
# Overview chart (all four data classes under a single CoreMeta4Cat root)
249+
# ─────────────────────────────────────────────────────────────────────────────
250+
251+
def build_overview_chart(schema: dict) -> str:
252+
"""
253+
Return standalone HTML for a combined sunburst that shows all four
254+
CoreMeta4Cat data classes (Synthesis, Characterization, Reaction,
255+
Simulation) as branches under a single 'CoreMeta4Cat' root node.
256+
Each branch uses the colour palette of its respective data class.
257+
"""
258+
main_classes = ["Synthesis", "Characterization", "Reaction", "Simulation"]
259+
260+
ids: list[str] = []
261+
names: list[str] = []
262+
parents: list[str] = []
263+
colors: list[str] = []
264+
hover: list[str] = []
265+
266+
root_id = "CoreMeta4Cat"
267+
_add_node(ids, names, parents, colors, hover,
268+
root_id, "CoreMeta4Cat", "", "#555555",
269+
"CoreMeta4Cat — catalysis metadata schema")
270+
271+
for cls in main_classes:
272+
key = cls.lower()
273+
color_map = BASE_COLORS.get(key, BASE_COLORS["coremeta4cat"])
274+
cls_id = f"{root_id}|{cls}"
275+
276+
_add_node(ids, names, parents, colors, hover,
277+
cls_id, cls, root_id, color_map["M"],
278+
f"Data class: {cls}")
279+
280+
_build_tree_for_class(
281+
schema, cls, cls_id,
282+
ids, names, parents, colors, hover,
283+
color_map, cls,
284+
)
285+
286+
fig = px.sunburst(ids=ids, names=names, parents=parents, hover_name=hover)
287+
fig.update_traces(marker=dict(colors=colors))
288+
fig.update_layout(
289+
title=dict(text="CoreMeta4Cat — Schema Overview", x=0.5),
290+
margin=dict(t=40, l=10, r=10, b=10),
291+
autosize=True,
292+
)
293+
294+
chart_html = to_html(
295+
fig,
296+
full_html=False,
297+
include_plotlyjs=False,
298+
config={"responsive": True},
299+
)
300+
301+
return f"""<!DOCTYPE html>
302+
<html>
303+
<head>
304+
<meta charset='UTF-8'>
305+
<title>CoreMeta4Cat Schema Overview</title>
306+
<script src='https://cdn.plot.ly/plotly-latest.min.js'></script>
307+
<style>
308+
html, body {{
309+
margin: 0;
310+
padding: 0;
311+
height: 100%;
312+
width: 100%;
313+
}}
314+
.chart-container {{
315+
width: 100%;
316+
height: 100vh;
317+
}}
318+
</style>
319+
</head>
320+
<body>
321+
<div class="chart-container">
322+
{chart_html}
323+
</div>
324+
</body>
325+
</html>
326+
"""
327+
328+
247329
# ─────────────────────────────────────────────────────────────────────────────
248330
# Entry point
249331
# ─────────────────────────────────────────────────────────────────────────────
@@ -263,7 +345,12 @@ def main(schema_dir: str, output_dir: str) -> None:
263345
dest.write_text(html, encoding="utf-8")
264346
print(f" OK {dest}")
265347

266-
print(f"\nDone -- {len(main_classes)} charts written to '{output_dir}'.")
348+
overview_html = build_overview_chart(schema)
349+
overview_dest = out / "metadata_coremeta4cat_overview.html"
350+
overview_dest.write_text(overview_html, encoding="utf-8")
351+
print(f" OK {overview_dest}")
352+
353+
print(f"\nDone -- {len(main_classes) + 1} charts written to '{output_dir}'.")
267354

268355

269356
if __name__ == "__main__":

0 commit comments

Comments
 (0)