import { createOrgChart, JsonOrgChartDataSource } from '@hm-design/org-chart'; import engineUrl from '@hm-design/org-chart/engine.css?url'; import coreUrl from '@hm-design/org-chart/style.css?url'; import { datasets, readQuery } from './data'; import './chart-only.css'; const { data, layout, embed } = readQuery(); if (embed) document.body.classList.add('embed'); const chart = createOrgChart({ container: document.getElementById('chart')!, dataSource: new JsonOrgChartDataSource(datasets[data]!()), stylesheetUrls: { engine: engineUrl, core: coreUrl }, displayMode: 'readOnly', layoutMode: 'auto', autoLayout: { type: layout }, // Chart Only implies initialView "fit" and wheelZoom "direct". presentationMode: 'chart-only', // Regression fixture: Fit below the manual zoom floor, without huge data. zoom: new URLSearchParams(location.search).has('verify-min') ? { min: 0.8 } : undefined, }); void chart.mount(); // Verification seam only: replace the whole dataset through the public handle. Object.assign(window, { orgChart: chart, replaceData: (key: string) => chart.update(datasets[key]!()) });