mirror of
https://github.com/apache/superset.git
synced 2026-04-27 20:14:54 +00:00
feat: Implement context menu for drill by (#23454)
This commit is contained in:
committed by
GitHub
parent
542bf25729
commit
9fbfd1c1d8
@@ -131,42 +131,52 @@ export default function EchartsMixedTimeseries({
|
||||
const { data, seriesName, seriesIndex } = eventParams;
|
||||
const pointerEvent = eventParams.event.event;
|
||||
const drillToDetailFilters: BinaryQueryObjectFilterClause[] = [];
|
||||
if (data) {
|
||||
const values = [
|
||||
...(eventParams.name ? [eventParams.name] : []),
|
||||
...(isFirstQuery(seriesIndex) ? labelMap : labelMapB)[
|
||||
eventParams.seriesName
|
||||
],
|
||||
];
|
||||
if (xAxis.type === AxisType.time) {
|
||||
drillToDetailFilters.push({
|
||||
col:
|
||||
xAxis.label === DTTM_ALIAS
|
||||
? formData.granularitySqla
|
||||
: xAxis.label,
|
||||
grain: formData.timeGrainSqla,
|
||||
op: '==',
|
||||
val: data[0],
|
||||
formattedVal: xValueFormatter(data[0]),
|
||||
});
|
||||
}
|
||||
[
|
||||
...(xAxis.type === AxisType.category ? [xAxis.label] : []),
|
||||
...(isFirstQuery(seriesIndex)
|
||||
? formData.groupby
|
||||
: formData.groupbyB),
|
||||
].forEach((dimension, i) =>
|
||||
drillToDetailFilters.push({
|
||||
const drillByFilters: BinaryQueryObjectFilterClause[] = [];
|
||||
const isFirst = isFirstQuery(seriesIndex);
|
||||
const values = [
|
||||
...(eventParams.name ? [eventParams.name] : []),
|
||||
...(isFirst ? labelMap : labelMapB)[eventParams.seriesName],
|
||||
];
|
||||
if (data && xAxis.type === AxisType.time) {
|
||||
drillToDetailFilters.push({
|
||||
col:
|
||||
xAxis.label === DTTM_ALIAS
|
||||
? formData.granularitySqla
|
||||
: xAxis.label,
|
||||
grain: formData.timeGrainSqla,
|
||||
op: '==',
|
||||
val: data[0],
|
||||
formattedVal: xValueFormatter(data[0]),
|
||||
});
|
||||
}
|
||||
[
|
||||
...(data && xAxis.type === AxisType.category ? [xAxis.label] : []),
|
||||
...(isFirst ? formData.groupby : formData.groupbyB),
|
||||
].forEach((dimension, i) =>
|
||||
drillToDetailFilters.push({
|
||||
col: dimension,
|
||||
op: '==',
|
||||
val: values[i],
|
||||
formattedVal: String(values[i]),
|
||||
}),
|
||||
);
|
||||
|
||||
[...(isFirst ? formData.groupby : formData.groupbyB)].forEach(
|
||||
(dimension, i) =>
|
||||
drillByFilters.push({
|
||||
col: dimension,
|
||||
op: '==',
|
||||
val: values[i],
|
||||
formattedVal: String(values[i]),
|
||||
}),
|
||||
);
|
||||
}
|
||||
);
|
||||
onContextMenu(pointerEvent.clientX, pointerEvent.clientY, {
|
||||
drillToDetail: drillToDetailFilters,
|
||||
crossFilter: getCrossFilterDataMask(seriesName, seriesIndex),
|
||||
drillBy: {
|
||||
filters: drillByFilters,
|
||||
groupbyFieldName: isFirst ? 'groupby' : 'groupby_b',
|
||||
adhocFilterFieldName: isFirst ? 'adhoc_filters' : 'adhoc_filters_b',
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@@ -54,7 +54,11 @@ export default class EchartsTimeseriesChartPlugin extends ChartPlugin<
|
||||
controlPanel,
|
||||
loadChart: () => import('./EchartsMixedTimeseries'),
|
||||
metadata: new ChartMetadata({
|
||||
behaviors: [Behavior.INTERACTIVE_CHART, Behavior.DRILL_TO_DETAIL],
|
||||
behaviors: [
|
||||
Behavior.INTERACTIVE_CHART,
|
||||
Behavior.DRILL_TO_DETAIL,
|
||||
Behavior.DRILL_BY,
|
||||
],
|
||||
category: t('Evolution'),
|
||||
credits: ['https://echarts.apache.org'],
|
||||
description: hasGenericChartAxes
|
||||
|
||||
Reference in New Issue
Block a user