Skip to content

Commit

Permalink
fix(plugin-chart-table): hide cell bar for group by fields (#957)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmud authored and zhaoyongjie committed Nov 26, 2021
1 parent d142881 commit eb16861
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export default function TableChart<D extends DataRecord = DataRecord>(
height,
width,
data,
isRawRecords,
columns: columnsMeta,
alignPositiveNegative = false,
colorPositiveNegative = false,
Expand Down Expand Up @@ -205,14 +206,14 @@ export default function TableChart<D extends DataRecord = DataRecord>(

const getColumnConfigs = useCallback(
(column: DataColumnMeta, i: number): ColumnWithLooseAccessor<D> => {
const { key, label, dataType } = column;
const { key, label, dataType, isMetric } = column;
let className = '';
if (dataType === GenericDataType.NUMERIC) {
className += ' dt-metric';
} else if (emitFilter) {
className += ' dt-is-filter';
}
const valueRange = showCellBars && getValueRange(key);
const valueRange = showCellBars && (isMetric || isRawRecords) && getValueRange(key);
return {
id: String(i), // to allow duplicate column keys
// must use custom accessor to allow `.` in column names
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
TimeFormats,
GenericDataType,
getMetricLabel,
QueryMode,
} from '@superset-ui/core';

import isEqualColumns from './utils/isEqualColumns';
Expand Down Expand Up @@ -136,6 +137,8 @@ const processColumns = memoizeOne(function processColumns(props: TableChartProps
key,
label,
dataType,
isMetric,
isPercentMetric,
formatter,
};
});
Expand Down Expand Up @@ -183,6 +186,7 @@ export default function transformProps(chartProps: TableChartProps): TableChartT
page_length: pageSize,
table_filter: tableFilter,
order_desc: sortDesc = false,
query_mode: queryMode,
} = formData;

const [metrics, percentMetrics, columns] = processColumns(chartProps);
Expand All @@ -191,6 +195,7 @@ export default function transformProps(chartProps: TableChartProps): TableChartT
return {
height,
width,
isRawRecords: queryMode === QueryMode.raw,
data,
columns,
metrics,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export interface DataColumnMeta {
label: string;
dataType: GenericDataType;
formatter?: TimeFormatter | NumberFormatter | CustomFormatter;
isMetric?: boolean;
isPercentMetric?: boolean;
}

export interface TableChartData {
Expand Down Expand Up @@ -74,6 +76,7 @@ export interface TableChartProps extends ChartProps {
export interface TableChartTransformedProps<D extends DataRecord = DataRecord> {
height: number;
width: number;
isRawRecords?: boolean;
data: D[];
columns: DataColumnMeta[];
metrics?: (keyof D)[];
Expand Down

0 comments on commit eb16861

Please sign in to comment.