Skip to content

Commit b4aa19a

Browse files
committed
feat:(Chart) funnel chart add drillable
1 parent 64d0109 commit b4aa19a

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

frontend/src/app/components/ChartGraph/BasicFunnelChart/BasicFunnelChart.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import ChartDataSetDTO, {
3131
import {
3232
getAutoFunnelTopPosition,
3333
getColumnRenderName,
34+
getDrillableRows,
3435
getExtraSeriesDataFormat,
3536
getExtraSeriesRowData,
3637
getGridStyle,
@@ -42,6 +43,7 @@ import {
4243
import { init } from 'echarts';
4344
import isEmpty from 'lodash/isEmpty';
4445
import Chart from '../../../models/Chart';
46+
import { ChartDrillOption } from '../../../models/ChartDrillOption';
4547
import Config from './config';
4648
import { Series, SeriesData } from './types';
4749

@@ -86,7 +88,11 @@ class BasicFunnelChart extends Chart {
8688
if (!this.isMatchRequirement(props.config)) {
8789
return;
8890
}
89-
const newOptions = this.getOptions(props.dataset, props.config);
91+
const newOptions = this.getOptions(
92+
props.dataset,
93+
props.config,
94+
props.drillOption,
95+
);
9096
this.chart?.setOption(Object.assign({}, newOptions), true);
9197
}
9298

@@ -98,12 +104,17 @@ class BasicFunnelChart extends Chart {
98104
this.chart?.resize({ width: context?.width, height: context?.height });
99105
}
100106

101-
private getOptions(dataset: ChartDataSetDTO, config: ChartConfig) {
107+
private getOptions(
108+
dataset: ChartDataSetDTO,
109+
config: ChartConfig,
110+
drillOption: ChartDrillOption,
111+
) {
102112
const styleConfigs = config.styles || [];
103113
const dataConfigs = config.datas || [];
104-
const groupConfigs = dataConfigs
105-
.filter(c => c.type === ChartDataSectionType.GROUP)
106-
.flatMap(config => config.rows || []);
114+
const groupConfigs: ChartDataSectionField[] = getDrillableRows(
115+
dataConfigs,
116+
drillOption,
117+
);
107118
const aggregateConfigs = dataConfigs
108119
.filter(c => c.type === ChartDataSectionType.AGGREGATE)
109120
.flatMap(config => config.rows || []);

frontend/src/app/components/ChartGraph/BasicFunnelChart/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const config: ChartConfig = {
3131
STRING: ['alias', 'colorize', 'sortable'],
3232
DATE: ['alias', 'colorize', 'sortable'],
3333
},
34+
drillable: true,
3435
},
3536
{
3637
label: 'metrics',

0 commit comments

Comments
 (0)