Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/docs/using-superset/exploring-data.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,14 @@ endpoints resolve to the same timestamp, the picker warns that the range is empt
you can still apply it. To include a full day, use midnight on that day as the
start and midnight on the following day as the end.

### Drill By Categories in Mixed Charts

On a Mixed Timeseries chart with a categorical x-axis, **Drill by** keeps the
clicked category for the selected query (A or B), for datasets and semantic views.
If the point also belongs to a series group, both filters apply by default; the
scope selector lets you choose the category or the series instead. The other
query's controls and cross-filter behavior are unchanged.

### Drill By Time Buckets

On time-series charts, **Drill by** from a grained temporal axis keeps the clicked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,43 @@ export default function EchartsMixedTimeseries({
if (filter?.grain) {
xAxisFilters.push(filter);
}
} else if (xAxis.type === AxisType.Category && xAxisColumn) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker. Plain Timeseries still resolves a category click with getXAxisValue(data, eventParams.name), so a markerless line or area click there sends no category filter, the same gap this fixes for Mixed. Is a follow-up planned for it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That plain Timeseries path is unchanged here. I'd like to take its markerless-category handling as a separate follow-up so this patch stays focused on Mixed.

// Line/area events carry only the series identity. Resolve their
// pixel position through the shared category axis, not a data index.
const rawValue = getTimeAxisDrillByValue(
data,
Array.isArray(echartOptions.series)
? echartOptions.series[seriesIndex]
: echartOptions.series,
data === undefined
? echartRef.current
?.getEchartInstance()
?.convertFromPixel({ seriesIndex }, [
eventParams.event.offsetX,
eventParams.event.offsetY,
])
: undefined,
0,
true,
data === undefined
? getCategoryAxisValues(echartRef.current?.getEchartInstance(), 0)
: undefined,
);
const categoryValue =
rawValue === undefined ? eventParams.name : rawValue;
Comment thread
aminghadersohi marked this conversation as resolved.
Resolved
if (
categoryValue === null ||
typeof categoryValue === 'string' ||
typeof categoryValue === 'number' ||
typeof categoryValue === 'boolean'
) {
Comment on lines +297 to +302

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Boolean values are valid categorical x-axis values, but this guard rejects them, so drilling from a Boolean category omits its filter.

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Type error

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/EchartsMixedTimeseries.tsx
**Line:** 277:281
**Comment:**
	*Type Error: Boolean values are valid categorical x-axis values, but this guard rejects them, so drilling from a Boolean category omits its filter.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed at 578053e: a Boolean x-axis is a category axis (getAxisType), and data[0] or the matched point stays true/false, so this guard drops it and Drill by runs without the clicked category. Plain Timeseries keeps it through the name fallback.

Suggested change
if (
categoryValue === null ||
typeof categoryValue === 'string' ||
typeof categoryValue === 'number'
) {
if (
categoryValue === null ||
typeof categoryValue === 'string' ||
typeof categoryValue === 'number' ||
typeof categoryValue === 'boolean'
) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 7e64640.

The category-value guard now accepts booleans, so Boolean x-axis values are added to xAxisFilters.

If that's not right, unresolve this thread and CodeAnt will leave it open.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added boolean to the guard in 7e64640. Four red-first cases cover true and false on point and markerless clicks; all six focused suites pass.

xAxisFilters.push({
col: xAxisColumn,
op: '==',
val: categoryValue,
formattedVal: String(categoryValue),
});
Comment thread
aminghadersohi marked this conversation as resolved.
Resolved
}
}
const hasCrossFilter =
(isFirst && groupby.length > 0) || (!isFirst && groupbyB.length > 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,136 @@ test('EchartsMixedTimeseries hover focuses and unfocuses the series', () => {
expect(onFocusedSeries).toHaveBeenLastCalledWith(null);
});

test.each(
['7__table', '7__semantic_view'].flatMap(datasource =>
[0, 1].flatMap(seriesIndex =>
[false, true].map(grouped => ({ datasource, seriesIndex, grouped })),
),
),
)(
'category Drill by scopes $datasource query $seriesIndex grouped=$grouped',
async ({ datasource, seriesIndex, grouped }) => {
const seriesName = grouped ? 'sum__num, boy' : 'sum__num';
const queryData: ChartDataResponseResult & {
label_map: Record<string, string[]>;
} = {
...createQueryData(),
data: [
{ ds: 'CORP', [seriesName]: 42 },
{ ds: 'RETAIL', [seriesName]: 7 },
],
colnames: ['ds', seriesName],
coltypes: [GenericDataType.String, GenericDataType.Numeric],
label_map: {
ds: ['ds'],
[seriesName]: grouped ? ['sum__num', 'boy'] : ['sum__num'],
},
};
const { eventHandlers, onContextMenu } = setup(
{
datasource,
groupby: grouped ? ['gender'] : [],
groupbyB: grouped ? ['gender'] : [],
},
[queryData, queryData],
{ ds: 'Segment' },
);
await eventHandlers.contextmenu({
data: ['CORP', 42],
seriesName,
seriesIndex,
name: 'CORP',
event: { stop: jest.fn(), event: { clientX: 0, clientY: 0 } },
});
const payload = onContextMenu.mock.lastCall[2];
expect(payload.drillBy.xAxisFilters).toEqual([
{ col: 'ds', op: '==', val: 'CORP', formattedVal: 'CORP' },
]);
expect(payload.drillBy.filters).toEqual(
grouped
? [expect.objectContaining({ col: 'gender', op: '==', val: 'boy' })]
: [],
);
expect(payload.drillBy.groupbyFieldName).toBe(
seriesIndex === 0 ? 'groupby' : 'groupby_b',
);
expect(payload.drillBy.adhocFilterFieldName).toBe(
seriesIndex === 0 ? 'adhoc_filters' : 'adhoc_filters_b',
);
expect(Boolean(payload.crossFilter)).toBe(grouped);
},
);

test.each(
[false, true].flatMap(value =>
[false, true].map(markerless => ({ value, markerless })),
),
)(
'Boolean category Drill by preserves $value on markerless=$markerless clicks',
async ({ value, markerless }) => {
const query: ChartDataResponseResult = {
...createQueryData(),
coltypes: [
GenericDataType.Boolean,
GenericDataType.Numeric,
GenericDataType.Numeric,
],
data: [false, true].map(ds => ({
ds,
'sum__num, boy': 1,
'sum__num, girl': 2,
})),
};
const { eventHandlers, onContextMenu } = setup({}, [query, query]);
mockMixedChart.getModel.mockReturnValue({
getComponent: () => ({ getCategories: () => [false, true] }),
});
mockMixedChart.convertFromPixel.mockReturnValue([Number(value), 1]);
await eventHandlers.contextmenu({
...(markerless ? {} : { data: [value, 1], name: String(value) }),
seriesName: 'sum__num, boy',
seriesIndex: 0,
event: {
stop: jest.fn(),
offsetX: 20,
offsetY: 30,
event: { clientX: 11, clientY: 22 },
},
});
expect(onContextMenu.mock.lastCall[2].drillBy.xAxisFilters).toEqual([
{ col: 'ds', op: '==', val: value, formattedVal: String(value) },
]);
},
);

test.each(['', 0, null])(
'category Drill by preserves the typed value %s',
async value => {
const queryData: ChartDataResponseResult = {
...createQueryData(),
coltypes: [
GenericDataType.String,
GenericDataType.Numeric,
GenericDataType.Numeric,
],
};
const { eventHandlers, onContextMenu } = setup(
{ xAxisForceCategorical: true },
[queryData, queryData],
);
await eventHandlers.contextmenu({
data: [value, 1],
seriesName: 'sum__num, boy',
seriesIndex: 0,
name: 'display label',
event: { stop: jest.fn(), event: { clientX: 0, clientY: 0 } },
});
expect(onContextMenu.mock.lastCall[2].drillBy.xAxisFilters).toEqual([
expect.objectContaining({ col: 'ds', op: '==', val: value }),
]);
},
);

test.each([0, 2])(
'Mixed Timeseries Drill by carries the bucket for query series %s',
async seriesIndex => {
Expand Down Expand Up @@ -430,3 +560,54 @@ test('Mixed categorical markerless Drill by uses shared axis categories for a sp
}
}
});

test.each([0, 1, 2])(
'Mixed text-axis markerless Drill by resolves shared category %s for sparse query B',
async categoryIndex => {
const query = {
...createQueryData(),
coltypes: [
GenericDataType.String,
GenericDataType.Numeric,
GenericDataType.Numeric,
],
data: ['ABSENT', 'CORP', 'RETAIL'].map(ds => ({
ds,
'sum__num, boy': 1,
'sum__num, girl': 2,
})),
};
const { eventHandlers, onContextMenu } = setup({}, [
query,
{ ...query, data: query.data.slice(1) },
]);
mockMixedChart.getModel.mockReturnValue({
getComponent: () => ({
getCategories: () => ['ABSENT', 'CORP', 'RETAIL'],
}),
});
mockMixedChart.convertFromPixel.mockReturnValue([categoryIndex, 1]);
await eventHandlers.contextmenu({
seriesName: 'sum__num, boy',
seriesIndex: 2,
event: {
stop: jest.fn(),
offsetX: 20,
offsetY: 30,
event: { clientX: 11, clientY: 22 },
},
});
expect(onContextMenu.mock.lastCall[2].drillBy.xAxisFilters).toEqual(
categoryIndex === 0
? undefined
: [
{
col: 'ds',
op: '==',
val: categoryIndex === 1 ? 'CORP' : 'RETAIL',
formattedVal: categoryIndex === 1 ? 'CORP' : 'RETAIL',
},
],
);
},
);
Loading
Loading