Skip to content

Commit 1e74e19

Browse files
TheRillJonclaude
andcommitted
fix: charts with multiple measures/dimensions drill down to Pivot, not TDD
- Block TDD when y.fields has multiple measures (multi-metric charts) - Block TDD when both x is nominal and color is a dimension (multiple dims) - Skip synthetic type:"value" fields (e.g. rill_measures color encoding) in transformChartSpecToPivotState so they don't appear as fake dimensions - Place all non-measure fields in rows initially; when rows contain dimension chips, move time chips from rows to columns Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ee452e2 commit 1e74e19

2 files changed

Lines changed: 37 additions & 17 deletions

File tree

web-common/src/features/canvas/components/charts/util.ts

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,41 @@ export function getLinkStateForTimeDimensionDetail(
2828
dimensionName?: string;
2929
} {
3030
if (!allowedTimeDimensionDetailTypes.includes(type))
31-
return {
32-
canLink: false,
33-
};
31+
return { canLink: false };
3432

3533
const hasXAxis = "x" in spec;
3634
const hasYAxis = "y" in spec;
3735
if (!hasXAxis || !hasYAxis)
38-
return {
39-
canLink: false,
40-
};
36+
return { canLink: false };
4137

4238
const xAxis = spec.x;
4339
const yAxis = spec.y;
4440

45-
if (isFieldConfig(xAxis) && isFieldConfig(yAxis)) {
46-
const colorDimension = spec.color;
47-
if (isFieldConfig(colorDimension)) {
48-
return {
49-
canLink: xAxis.type === "temporal",
50-
measureName: yAxis.field,
51-
dimensionName: colorDimension.field,
52-
};
53-
}
41+
if (!isFieldConfig(xAxis) || !isFieldConfig(yAxis))
42+
return { canLink: false };
5443

44+
if (yAxis.fields && yAxis.fields.length > 1)
45+
return { canLink: false };
46+
47+
const colorDimension = spec.color;
48+
const hasDimensionBreakout =
49+
isFieldConfig(colorDimension) &&
50+
colorDimension.type !== "quantitative" &&
51+
colorDimension.type !== "value";
52+
53+
if (hasDimensionBreakout && xAxis.type === "nominal")
54+
return { canLink: false };
55+
56+
if (hasDimensionBreakout) {
5557
return {
5658
canLink: xAxis.type === "temporal",
5759
measureName: yAxis.field,
60+
dimensionName: colorDimension.field,
5861
};
5962
}
63+
6064
return {
61-
canLink: false,
65+
canLink: xAxis.type === "temporal",
66+
measureName: yAxis.field,
6267
};
6368
}

web-common/src/features/components/charts/explore-transformer.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export function transformChartSpecToPivotState(
3333

3434
const fieldConfig = value;
3535

36+
if (fieldConfig.type === "value") {
37+
continue;
38+
}
39+
3640
// Handle multiple fields case
3741
if (fieldConfig.fields?.length) {
3842
columns.push(
@@ -55,13 +59,24 @@ export function transformChartSpecToPivotState(
5559
type: chipType,
5660
};
5761

58-
if (key === "x" || chipType === PivotChipType.Measure) {
62+
if (chipType === PivotChipType.Measure) {
5963
columns.push(chipData);
6064
} else {
6165
rows.push(chipData);
6266
}
6367
}
6468

69+
const hasDimensionRows = rows.some(
70+
(r) => r.type === PivotChipType.Dimension,
71+
);
72+
if (hasDimensionRows) {
73+
const timeChips = rows.filter((r) => r.type === PivotChipType.Time);
74+
const nonTimeRows = rows.filter((r) => r.type !== PivotChipType.Time);
75+
columns.push(...timeChips);
76+
rows.length = 0;
77+
rows.push(...nonTimeRows);
78+
}
79+
6580
return {
6681
columns,
6782
rows,

0 commit comments

Comments
 (0)