MCPcopy Create free account
hub / github.com/microsoft/data-formulator / computeThreadColumnLayout

Function computeThreadColumnLayout

src/views/DataThread.tsx:2705–2719  ·  view source on GitHub ↗

* Compute a balanced column layout for threads. * * @param heights – Estimated pixel height for each thread (in display order). * @param numColumns – Maximum number of columns to distribute into. * @param flexOrder – When true, threads may be reordered across columns for * b

(
    heights: number[],
    numColumns: number,
    flexOrder: boolean = false,
)

Source from the content-addressed store, hash-verified

2703 * thread indices. Empty columns are omitted.
2704 */
2705function computeThreadColumnLayout(
2706 heights: number[],
2707 numColumns: number,
2708 flexOrder: boolean = false,
2709): number[][] {
2710 if (heights.length === 0) return [];
2711 if (heights.length === 1) return [[0]];
2712
2713 const cols = Math.min(numColumns, heights.length);
2714 if (cols <= 1) return [heights.map((_, i) => i)];
2715
2716 return flexOrder
2717 ? layoutFlexOrder(heights, cols)
2718 : layoutPreserveOrder(heights, cols);
2719}
2720
2721/**
2722 * Balanced layout *with* reordering (LPT – Longest Processing Time first).

Callers 1

chooseBestColumnLayoutFunction · 0.85

Calls 2

layoutFlexOrderFunction · 0.85
layoutPreserveOrderFunction · 0.85

Tested by

no test coverage detected