2023-08-02 20:41:09 +05:30
|
|
|
import { CheckboxChangeEvent } from 'antd/es/checkbox';
|
|
|
|
|
import { ColumnType } from 'antd/es/table';
|
|
|
|
|
import { ChartData } from 'chart.js';
|
|
|
|
|
|
|
|
|
|
import { ColumnsKeyAndDataIndex, ColumnsTitle } from '../contants';
|
|
|
|
|
import { DataSetProps } from '../types';
|
|
|
|
|
import { getGraphManagerTableHeaderTitle } from '../utils';
|
2023-10-08 23:21:17 +05:30
|
|
|
import CustomCheckBox from './CustomCheckBox';
|
2023-08-02 20:41:09 +05:30
|
|
|
import { getLabel } from './GetLabel';
|
|
|
|
|
|
|
|
|
|
export const getGraphManagerTableColumns = ({
|
|
|
|
|
data,
|
|
|
|
|
checkBoxOnChangeHandler,
|
|
|
|
|
graphVisibilityState,
|
|
|
|
|
labelClickedHandler,
|
|
|
|
|
yAxisUnit,
|
|
|
|
|
}: GetGraphManagerTableColumnsProps): ColumnType<DataSetProps>[] => [
|
|
|
|
|
{
|
|
|
|
|
title: '',
|
|
|
|
|
width: 50,
|
|
|
|
|
dataIndex: ColumnsKeyAndDataIndex.Index,
|
|
|
|
|
key: ColumnsKeyAndDataIndex.Index,
|
2023-11-02 20:32:01 +05:30
|
|
|
render: (_: string, record: DataSetProps): JSX.Element => (
|
2023-10-08 23:21:17 +05:30
|
|
|
<CustomCheckBox
|
|
|
|
|
data={data}
|
2023-11-02 20:32:01 +05:30
|
|
|
index={record.index}
|
2023-10-08 23:21:17 +05:30
|
|
|
checkBoxOnChangeHandler={checkBoxOnChangeHandler}
|
|
|
|
|
graphVisibilityState={graphVisibilityState}
|
|
|
|
|
/>
|
|
|
|
|
),
|
2023-08-02 20:41:09 +05:30
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: ColumnsTitle[ColumnsKeyAndDataIndex.Label],
|
|
|
|
|
width: 300,
|
|
|
|
|
dataIndex: ColumnsKeyAndDataIndex.Label,
|
|
|
|
|
key: ColumnsKeyAndDataIndex.Label,
|
|
|
|
|
...getLabel(labelClickedHandler),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: getGraphManagerTableHeaderTitle(
|
|
|
|
|
ColumnsTitle[ColumnsKeyAndDataIndex.Avg],
|
|
|
|
|
yAxisUnit,
|
|
|
|
|
),
|
|
|
|
|
width: 90,
|
|
|
|
|
dataIndex: ColumnsKeyAndDataIndex.Avg,
|
|
|
|
|
key: ColumnsKeyAndDataIndex.Avg,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: getGraphManagerTableHeaderTitle(
|
|
|
|
|
ColumnsTitle[ColumnsKeyAndDataIndex.Sum],
|
|
|
|
|
yAxisUnit,
|
|
|
|
|
),
|
|
|
|
|
width: 90,
|
|
|
|
|
dataIndex: ColumnsKeyAndDataIndex.Sum,
|
|
|
|
|
key: ColumnsKeyAndDataIndex.Sum,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: getGraphManagerTableHeaderTitle(
|
|
|
|
|
ColumnsTitle[ColumnsKeyAndDataIndex.Max],
|
|
|
|
|
yAxisUnit,
|
|
|
|
|
),
|
|
|
|
|
width: 90,
|
|
|
|
|
dataIndex: ColumnsKeyAndDataIndex.Max,
|
|
|
|
|
key: ColumnsKeyAndDataIndex.Max,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: getGraphManagerTableHeaderTitle(
|
|
|
|
|
ColumnsTitle[ColumnsKeyAndDataIndex.Min],
|
|
|
|
|
yAxisUnit,
|
|
|
|
|
),
|
|
|
|
|
width: 90,
|
|
|
|
|
dataIndex: ColumnsKeyAndDataIndex.Min,
|
|
|
|
|
key: ColumnsKeyAndDataIndex.Min,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
interface GetGraphManagerTableColumnsProps {
|
|
|
|
|
data: ChartData;
|
|
|
|
|
checkBoxOnChangeHandler: (e: CheckboxChangeEvent, index: number) => void;
|
|
|
|
|
labelClickedHandler: (labelIndex: number) => void;
|
|
|
|
|
graphVisibilityState: boolean[];
|
|
|
|
|
yAxisUnit?: string;
|
|
|
|
|
}
|