MCPcopy Create free account
hub / github.com/ChartGPU/ChartGPU / computeBarClusterSlots

Function computeBarClusterSlots

src/interaction/findNearestPoint.ts:160–194  ·  view source on GitHub ↗
(
  seriesConfigs: ReadonlyArray<ResolvedBarSeriesConfig>,
)

Source from the content-addressed store, hash-verified

158}>;
159
160export function computeBarClusterSlots(
161 seriesConfigs: ReadonlyArray<ResolvedBarSeriesConfig>,
162): BarClusterSlots {
163 // Cluster slots (mirrors `createBarRenderer.ts`):
164 // - Each unique non-empty stackId gets a single cluster slot.
165 // - Each unstacked series gets its own cluster slot.
166 const stackIdToClusterIndex = new Map<string, number>();
167 const clusterIndexBySeries: number[] = new Array(seriesConfigs.length);
168 const stackIdBySeries: string[] = new Array(seriesConfigs.length);
169
170 let clusterCount = 0;
171 for (let i = 0; i < seriesConfigs.length; i++) {
172 const stackId = normalizeStackId(seriesConfigs[i].stack);
173 stackIdBySeries[i] = stackId;
174
175 if (stackId !== '') {
176 const existing = stackIdToClusterIndex.get(stackId);
177 if (existing !== undefined) {
178 clusterIndexBySeries[i] = existing;
179 } else {
180 const idx = clusterCount++;
181 stackIdToClusterIndex.set(stackId, idx);
182 clusterIndexBySeries[i] = idx;
183 }
184 } else {
185 clusterIndexBySeries[i] = clusterCount++;
186 }
187 }
188
189 return {
190 clusterIndexBySeries,
191 clusterCount: Math.max(1, clusterCount),
192 stackIdBySeries,
193 };
194}
195
196export function computeBarCategoryStep(seriesConfigs: ReadonlyArray<ResolvedBarSeriesConfig>): number {
197 const xs: number[] = [];

Callers 1

computeBarLayoutPxFunction · 0.85

Calls 1

normalizeStackIdFunction · 0.70

Tested by

no test coverage detected