fix: Typing of labelMap (#21181)
* fix: Typing of labelMap * Adjusts val types
This commit is contained in:
parent
5811262cf2
commit
1143e17742
|
|
@ -40,13 +40,13 @@ export type BaseQueryObjectFilterClause = {
|
|||
|
||||
export type BinaryQueryObjectFilterClause = BaseQueryObjectFilterClause & {
|
||||
op: BinaryOperator;
|
||||
val: string | number | boolean | null | Date;
|
||||
val: string | number | boolean;
|
||||
formattedVal?: string;
|
||||
};
|
||||
|
||||
export type SetQueryObjectFilterClause = BaseQueryObjectFilterClause & {
|
||||
op: SetOperator;
|
||||
val: (string | number | boolean | null | Date)[];
|
||||
val: (string | number | boolean)[];
|
||||
formattedVal?: string[];
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ export interface ChartDataResponseResult {
|
|||
export interface TimeseriesChartDataResponseResult
|
||||
extends ChartDataResponseResult {
|
||||
data: TimeseriesDataRecord[];
|
||||
label_map: Record<string, DataRecordValue[]>;
|
||||
label_map: Record<string, string[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
import {
|
||||
CategoricalColorNamespace,
|
||||
DataRecordValue,
|
||||
getColumnLabel,
|
||||
getMetricLabel,
|
||||
getNumberFormatter,
|
||||
|
|
@ -156,21 +155,18 @@ export default function transformProps(
|
|||
)
|
||||
.flat(2);
|
||||
|
||||
const labelMap = data.reduce(
|
||||
(acc: Record<string, DataRecordValue[]>, datum) => {
|
||||
const label = extractGroupbyLabel({
|
||||
datum,
|
||||
groupby: groupbyLabels,
|
||||
coltypeMapping,
|
||||
timeFormatter: getTimeFormatter(dateFormat),
|
||||
});
|
||||
return {
|
||||
...acc,
|
||||
[label]: groupbyLabels.map(col => datum[col]),
|
||||
};
|
||||
},
|
||||
{},
|
||||
);
|
||||
const labelMap = data.reduce((acc: Record<string, string[]>, datum) => {
|
||||
const label = extractGroupbyLabel({
|
||||
datum,
|
||||
groupby: groupbyLabels,
|
||||
coltypeMapping,
|
||||
timeFormatter: getTimeFormatter(dateFormat),
|
||||
});
|
||||
return {
|
||||
...acc,
|
||||
[label]: groupbyLabels.map(col => datum[col] as string),
|
||||
};
|
||||
}, {});
|
||||
|
||||
const selectedValues = (filterState.selectedValues || []).reduce(
|
||||
(acc: Record<string, number>, selectedValue: string) => {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
import {
|
||||
CategoricalColorNamespace,
|
||||
DataRecordValue,
|
||||
DataRecord,
|
||||
getMetricLabel,
|
||||
getNumberFormatter,
|
||||
|
|
@ -121,20 +120,17 @@ export default function transformProps(
|
|||
const keys = data.map(datum =>
|
||||
extractGroupbyLabel({ datum, groupby: groupbyLabels, coltypeMapping: {} }),
|
||||
);
|
||||
const labelMap = data.reduce(
|
||||
(acc: Record<string, DataRecordValue[]>, datum) => {
|
||||
const label = extractGroupbyLabel({
|
||||
datum,
|
||||
groupby: groupbyLabels,
|
||||
coltypeMapping: {},
|
||||
});
|
||||
return {
|
||||
...acc,
|
||||
[label]: groupbyLabels.map(col => datum[col]),
|
||||
};
|
||||
},
|
||||
{},
|
||||
);
|
||||
const labelMap = data.reduce((acc: Record<string, string[]>, datum) => {
|
||||
const label = extractGroupbyLabel({
|
||||
datum,
|
||||
groupby: groupbyLabels,
|
||||
coltypeMapping: {},
|
||||
});
|
||||
return {
|
||||
...acc,
|
||||
[label]: groupbyLabels.map(col => datum[col] as string),
|
||||
};
|
||||
}, {});
|
||||
|
||||
const { setDataMask = () => {}, onContextMenu } = hooks;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import {
|
|||
DataRecord,
|
||||
getNumberFormatter,
|
||||
getMetricLabel,
|
||||
DataRecordValue,
|
||||
getColumnLabel,
|
||||
} from '@superset-ui/core';
|
||||
import { EChartsCoreOption, GaugeSeriesOption } from 'echarts';
|
||||
|
|
@ -132,7 +131,7 @@ export default function transformProps(
|
|||
FONT_SIZE_MULTIPLIERS.titleOffsetFromTitle * fontSize;
|
||||
const detailOffsetFromTitle =
|
||||
FONT_SIZE_MULTIPLIERS.detailOffsetFromTitle * fontSize;
|
||||
const columnsLabelMap = new Map<string, DataRecordValue[]>();
|
||||
const columnsLabelMap = new Map<string, string[]>();
|
||||
|
||||
const transformedData: GaugeDataItemOption[] = data.map(
|
||||
(data_point, index) => {
|
||||
|
|
@ -141,7 +140,7 @@ export default function transformProps(
|
|||
.join(', ');
|
||||
columnsLabelMap.set(
|
||||
name,
|
||||
groupbyLabels.map(col => data_point[col]),
|
||||
groupbyLabels.map(col => data_point[col] as string),
|
||||
);
|
||||
let item: GaugeDataItemOption = {
|
||||
value: data_point[getMetricLabel(metric as QueryFormMetric)] as number,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
import {
|
||||
AnnotationLayer,
|
||||
TimeGranularity,
|
||||
DataRecordValue,
|
||||
QueryFormData,
|
||||
ChartProps,
|
||||
ChartDataResponseResult,
|
||||
|
|
@ -142,7 +141,7 @@ export type EchartsMixedTimeseriesChartTransformedProps =
|
|||
EChartTransformedProps<EchartsMixedTimeseriesFormData> & {
|
||||
emitFilterB: boolean;
|
||||
groupbyB: QueryFormColumn[];
|
||||
labelMapB: Record<string, DataRecordValue[]>;
|
||||
labelMapB: Record<string, string[]>;
|
||||
seriesBreakdown: number;
|
||||
xValueFormatter: TimeFormatter | StringConstructor;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
import {
|
||||
CategoricalColorNamespace,
|
||||
DataRecordValue,
|
||||
getColumnLabel,
|
||||
getMetricLabel,
|
||||
getNumberFormatter,
|
||||
|
|
@ -185,21 +184,18 @@ export default function transformProps(
|
|||
timeFormatter: getTimeFormatter(dateFormat),
|
||||
}),
|
||||
);
|
||||
const labelMap = data.reduce(
|
||||
(acc: Record<string, DataRecordValue[]>, datum) => {
|
||||
const label = extractGroupbyLabel({
|
||||
datum,
|
||||
groupby: groupbyLabels,
|
||||
coltypeMapping,
|
||||
timeFormatter: getTimeFormatter(dateFormat),
|
||||
});
|
||||
return {
|
||||
...acc,
|
||||
[label]: groupbyLabels.map(col => datum[col]),
|
||||
};
|
||||
},
|
||||
{},
|
||||
);
|
||||
const labelMap = data.reduce((acc: Record<string, string[]>, datum) => {
|
||||
const label = extractGroupbyLabel({
|
||||
datum,
|
||||
groupby: groupbyLabels,
|
||||
coltypeMapping,
|
||||
timeFormatter: getTimeFormatter(dateFormat),
|
||||
});
|
||||
return {
|
||||
...acc,
|
||||
[label]: groupbyLabels.map(col => datum[col] as string),
|
||||
};
|
||||
}, {});
|
||||
|
||||
const { setDataMask = () => {}, onContextMenu } = hooks;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
import {
|
||||
CategoricalColorNamespace,
|
||||
DataRecordValue,
|
||||
ensureIsInt,
|
||||
getColumnLabel,
|
||||
getMetricLabel,
|
||||
|
|
@ -120,7 +119,7 @@ export default function transformProps(
|
|||
const groupbyLabels = groupby.map(getColumnLabel);
|
||||
|
||||
const metricLabelAndMaxValueMap = new Map<string, number>();
|
||||
const columnsLabelMap = new Map<string, DataRecordValue[]>();
|
||||
const columnsLabelMap = new Map<string, string[]>();
|
||||
const transformedData: RadarSeriesDataItemOption[] = [];
|
||||
data.forEach(datum => {
|
||||
const joinedName = extractGroupbyLabel({
|
||||
|
|
@ -132,7 +131,7 @@ export default function transformProps(
|
|||
// map(joined_name: [columnLabel_1, columnLabel_2, ...])
|
||||
columnsLabelMap.set(
|
||||
joinedName,
|
||||
groupbyLabels.map(col => datum[col]),
|
||||
groupbyLabels.map(col => datum[col] as string),
|
||||
);
|
||||
|
||||
// put max value of series into metricLabelAndMaxValueMap
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
import {
|
||||
CategoricalColorNamespace,
|
||||
DataRecord,
|
||||
DataRecordValue,
|
||||
getColumnLabel,
|
||||
getMetricLabel,
|
||||
getNumberFormatter,
|
||||
|
|
@ -150,7 +149,7 @@ export default function transformProps(
|
|||
labelType,
|
||||
});
|
||||
|
||||
const columnsLabelMap = new Map<string, DataRecordValue[]>();
|
||||
const columnsLabelMap = new Map<string, string[]>();
|
||||
|
||||
const transformer = (
|
||||
data: DataRecord[],
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
* under the License.
|
||||
*/
|
||||
import {
|
||||
DataRecordValue,
|
||||
HandlerFunction,
|
||||
QueryFormColumn,
|
||||
QueryObjectFilterClause,
|
||||
|
|
@ -112,7 +111,7 @@ export interface EChartTransformedProps<F> {
|
|||
emitFilter: boolean;
|
||||
setDataMask: SetDataMaskHook;
|
||||
setControlValue?: HandlerFunction;
|
||||
labelMap: Record<string, DataRecordValue[]>;
|
||||
labelMap: Record<string, string[]>;
|
||||
groupby: QueryFormColumn[];
|
||||
selectedValues: Record<number, string>;
|
||||
legendData?: OptionName[];
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { DataRecordValue, QueryObjectFilterClause } from '@superset-ui/core';
|
||||
import { QueryObjectFilterClause } from '@superset-ui/core';
|
||||
import { EChartTransformedProps, EventHandlers } from '../types';
|
||||
|
||||
export type Event = {
|
||||
|
|
@ -42,7 +42,7 @@ export const contextMenuEventHandler =
|
|||
(
|
||||
groupby: EChartTransformedProps<any>['groupby'],
|
||||
onContextMenu: EChartTransformedProps<any>['onContextMenu'],
|
||||
labelMap: Record<string, DataRecordValue[]>,
|
||||
labelMap: Record<string, string[]>,
|
||||
) =>
|
||||
(e: Event) => {
|
||||
if (onContextMenu) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue