Skip to content

Commit c5756e7

Browse files
committed
Respect # hidden tag in line chart channel assignment
Apply the same fix from bar charts to line charts: skip hidden dimensions during auto channel assignment and embedded tag walking, so they can be used for order_by without appearing as axes or series.
1 parent b763c5b commit c5756e7

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

packages/malloy-render/src/plugins/line-chart/get-line_chart-settings.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ export function getLineChartSettings(
220220
walkFields(explore, field => {
221221
const tag = field.tag;
222222
const pathTo = explore.pathTo(field);
223+
// Skip hidden fields unless they have an explicit channel tag
224+
const hasChannelTag = tag.has('x') || tag.has('y') || tag.has('series');
225+
if (field.isHidden() && !hasChannelTag) return;
223226
if (tag.has('x')) {
224227
embeddedX.push(pathTo);
225228
}
@@ -247,17 +250,19 @@ export function getLineChartSettings(
247250
});
248251
}
249252

253+
// Exclude hidden dimensions from chart channel assignment;
254+
// they remain in the data (e.g. for order_by) but aren't rendered.
250255
const dimensions = explore.fields.filter(
251-
f => f.isBasic() && f.wasDimension()
256+
f => f.isBasic() && f.wasDimension() && !f.isHidden()
252257
);
253258

254259
const measures = explore.fields.filter(f => f.wasCalculation());
255260

256261
// If still no x or y, attempt to pick the best choice
257262
if (xChannel.fields.length === 0) {
258-
// Pick date/time field first if it exists
263+
// Pick date/time field first if it exists (skip hidden)
259264
const dateTimeField = explore.fields.find(
260-
f => f.wasDimension() && f.isTime()
265+
f => f.wasDimension() && f.isTime() && !f.isHidden()
261266
);
262267
if (dateTimeField) xChannel.fields.push(explore.pathTo(dateTimeField));
263268
// Pick first dimension field for x

packages/malloy-render/src/stories/line_charts.stories.malloy

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,18 @@ source: products is duckdb.table("static/data/products.parquet") extend {
470470
aggregate: `Sales $` is sum(`Sales $`)
471471
order_by: m
472472
}
473+
474+
#(story)
475+
# line_chart
476+
view: hidden_dimension is {
477+
group_by:
478+
brand
479+
# hidden
480+
dcId
481+
aggregate: total_sales
482+
order_by: dcId
483+
limit: 10
484+
}
473485
}
474486

475487
source: missing_data is duckdb.table("static/data/missing_data.csv") extend {

0 commit comments

Comments
 (0)