16 lines
1022 B
JavaScript
16 lines
1022 B
JavaScript
export async function startP1(api, inlineFixture) {
|
|
const data = inlineFixture ?? await new api.JsonOrgChartDataSource('./data-p1.json').load();
|
|
const stylesheetUrls = {
|
|
engine: new URL('./assets/engine.css', location.href).href,
|
|
core: new URL('./assets/style.css', location.href).href,
|
|
};
|
|
// ?mode=readOnly shows the view-only Workdesk composition; the default stays interactive.
|
|
const displayMode = new URLSearchParams(location.search).get('mode') === 'readOnly' ? 'readOnly' : 'interactive';
|
|
document.documentElement.dataset.orgchartMode = displayMode;
|
|
const chart = api.createOrgChart({ container: document.getElementById('chart-host'), dataSource: new api.JsonOrgChartDataSource(data), stylesheetUrls, displayMode });
|
|
// Development inspection seam: public Core API only. No engine internals.
|
|
window.OrgChartP1 = { api, data, chart, stylesheetUrls, setData: next => chart.update(next) };
|
|
window.addEventListener('pagehide', () => chart.destroy(), { once: true });
|
|
await chart.mount();
|
|
}
|