-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support sub-schemas in Mermaid flowchart #11
Comments
Is this what you have in mind? flowchart TB
subgraph analytics
analytics.kpis(kpis)
subgraph finance
analytics.finance.kpis(kpis)
end
end
subgraph core
core.customers(customers)
core.orders(orders)
end
subgraph staging
staging.orders(orders)
staging.customers(customers)
staging.payments(payments)
end
core.orders --> analytics.finance.kpis
core.customers --> analytics.kpis
core.orders --> analytics.kpis
staging.customers --> core.customers
staging.orders --> core.customers
staging.payments --> core.customers
staging.orders --> core.orders
staging.payments --> core.orders
|
Yes! |
I was thinking of some recursive approach and what data structure would support it. If we had the data in such a format ⬇️ data = {
"analytics": ["kpis", {"finance": ["kpis"]}],
"core": ["customers", "orders"],
"staging": ["orders", "customers", "payments"]
} then something like this would work well ⬇️ def format_data(data: dict[str, list[str | dict]]):
for schema, values in data.items():
print_schema(schema, values)
def print_schema(schema: str, values: list[str | dict], prefix: str = ""):
print(f"\nsubgraph {schema}")
if isinstance(values, list):
for value in values:
if isinstance(value, dict):
(sub_schema, sub_values), = value.items()
new_prefix = f"{prefix}.{schema}" if prefix else schema
print_schema(sub_schema, sub_values, new_prefix) # RECURSIVE STEP
else:
path = ".".join(filter(None, [prefix, schema, value]))
print(f"{path}({value})")
print("end") Output ⬇️
❓ @MaxHalford What do you think?
|
I think it's ok to have this stuff in |
Done in #13, example here. Thanks @LeonardoNatale! |
The jaffle_shop example has a
kpis.finance
sub-schema. It would be cool if the Mermaid output handles any level of depth for (sub-)schemas.The text was updated successfully, but these errors were encountered: