From 91c52d05db62cd7482d4606a4944f6419ca391c4 Mon Sep 17 00:00:00 2001 From: Christian Bors Date: Wed, 27 Sep 2023 10:15:54 +0200 Subject: [PATCH] fix linting --- src/vis/heatmap/Heatmap.tsx | 21 ++++++++++++--------- src/vis/heatmap/HeatmapVisSidebar.tsx | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/vis/heatmap/Heatmap.tsx b/src/vis/heatmap/Heatmap.tsx index 9bd6de583..00e2b8ac5 100644 --- a/src/vis/heatmap/Heatmap.tsx +++ b/src/vis/heatmap/Heatmap.tsx @@ -51,7 +51,7 @@ export function Heatmap({ aggregateVal: aggregateColumn?.resolvedValues.map(({ val }) => val) || [], id: column1.resolvedValues.map(({ id }) => id), }); - }, [aggregateColumn?.resolvedValues, column1, column2, config.aggregateType, config.xSortedBy, config.ySortedBy]); + }, [aggregateColumn?.resolvedValues, column1, column2]); const aggregatedTable = useMemo(() => { if (!baseTable) return null; @@ -70,7 +70,7 @@ export function Heatmap({ .derive({ rowTotal: op.sum('aggregateVal') }); // default is ESortTypes.CAT_ASC - let xOrder: string | object = 'xVal'; + let xOrder: string | object; switch (config.xSortedBy) { case ESortTypes.VAL_ASC: xOrder = 'colTotal'; @@ -81,10 +81,13 @@ export function Heatmap({ case ESortTypes.VAL_DESC: xOrder = desc('colTotal'); break; + default: + xOrder = 'xVal'; + break; } // default is ESortTypes.CAT_ASC - let yOrder: string | object = 'yVal'; + let yOrder: string | object; switch (config.ySortedBy) { case ESortTypes.VAL_ASC: yOrder = 'rowTotal'; @@ -95,14 +98,14 @@ export function Heatmap({ case ESortTypes.VAL_DESC: yOrder = desc('rowTotal'); break; + default: + yOrder = 'yVal'; + break; } valueTable = valueTable.orderby(xOrder, yOrder); - // console.log(Array.from(valueTable.column('rowTotal'))); - // console.log(Array.from(valueTable.values('colTotal'))); - return valueTable; - }, [baseTable]); + }, [baseTable, config.aggregateType, config.xSortedBy, config.ySortedBy]); const { groupedValues, rectHeight, rectWidth, yScale, xScale, colorScale } = React.useMemo(() => { const groupedVals = aggregatedTable.objects() as { xVal: string; yVal: string; aggregateVal: number; ids: string[] }[]; @@ -199,7 +202,7 @@ export function Heatmap({ /> ); }); - }, [groupedValues, height, rectHeight, rectWidth, selected, selectionCallback, width, xScale, yScale]); + }, [baseTable, groupedValues, height, rectHeight, rectWidth, selected, selectionCallback, width, xScale, yScale]); const text = useMemo(() => { if (width === 0 || height === 0) return null; @@ -215,7 +218,7 @@ export function Heatmap({ isImmediate={!config.isAnimationEnabled} /> ); - }, [height, margin, rectHeight, rectWidth, width, xScale, yScale]); + }, [height, margin, rectHeight, rectWidth, width, xScale, yScale, config.isAnimationEnabled]); return ( diff --git a/src/vis/heatmap/HeatmapVisSidebar.tsx b/src/vis/heatmap/HeatmapVisSidebar.tsx index 6b18b3a5b..87c668d13 100644 --- a/src/vis/heatmap/HeatmapVisSidebar.tsx +++ b/src/vis/heatmap/HeatmapVisSidebar.tsx @@ -1,10 +1,10 @@ import * as React from 'react'; +import { Switch } from '@mantine/core'; import { ColumnInfo, EAggregateTypes, EColumnTypes, VisColumn } from '../interfaces'; import { AggregateTypeSelect } from '../sidebar/AggregateTypeSelect'; import { CategoricalColumnSelect } from '../sidebar/CategoricalColumnSelect'; import { NumericalColorButtons } from '../sidebar/NumericalColorButtons'; import { IHeatmapConfig } from './interfaces'; -import { Switch } from '@mantine/core'; import { i18n } from '../../i18n'; export function HeatmapVisSidebar({