From 7a5a922b014ecfeed16c0f42c4833b7be4197288 Mon Sep 17 00:00:00 2001 From: plouc Date: Mon, 10 Jan 2022 07:19:23 +0900 Subject: [PATCH] feat(heatmap): remove min/max value properties as they should be controlled where needed, for example the colors --- packages/heatmap/src/HeatMap.tsx | 2 -- packages/heatmap/src/HeatMapCanvas.tsx | 17 +++++++++-------- packages/heatmap/src/defaults.ts | 3 --- packages/heatmap/src/hooks.ts | 4 ---- packages/heatmap/src/types.ts | 2 -- 5 files changed, 9 insertions(+), 19 deletions(-) diff --git a/packages/heatmap/src/HeatMap.tsx b/packages/heatmap/src/HeatMap.tsx index d446c09ab2..736875594e 100644 --- a/packages/heatmap/src/HeatMap.tsx +++ b/packages/heatmap/src/HeatMap.tsx @@ -23,8 +23,6 @@ type InnerHeatMapProps = const InnerHeatMap = ({ data, layers = svgDefaultProps.layers, - minValue: _minValue = svgDefaultProps.minValue, - maxValue: _maxValue = svgDefaultProps.maxValue, valueFormat, width, height, diff --git a/packages/heatmap/src/HeatMapCanvas.tsx b/packages/heatmap/src/HeatMapCanvas.tsx index 13dd6651bc..7f86bd1902 100644 --- a/packages/heatmap/src/HeatMapCanvas.tsx +++ b/packages/heatmap/src/HeatMapCanvas.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef, useCallback, createElement } from 'react' +import { useEffect, useRef, useCallback, createElement, useMemo } from 'react' import { getRelativeCursor, isCursorInRect, useDimensions, useTheme, Container } from '@nivo/core' import { renderAxesToCanvas, renderGridLinesToCanvas } from '@nivo/axes' import { useTooltip } from '@nivo/tooltip' @@ -25,8 +25,6 @@ type InnerNetworkCanvasProps({ data, layers = canvasDefaultProps.layers, - minValue: _minValue = canvasDefaultProps.minValue, - maxValue: _maxValue = canvasDefaultProps.maxValue, valueFormat, width, height, @@ -113,11 +111,14 @@ const InnerHeatMapCanvas = = { - cells, - activeCell, - setActiveCell, - } + const customLayerProps: CustomLayerProps = useMemo( + () => ({ + cells, + activeCell, + setActiveCell, + }), + [cells, activeCell, setActiveCell] + ) useEffect(() => { if (canvasEl.current === null) return diff --git a/packages/heatmap/src/defaults.ts b/packages/heatmap/src/defaults.ts index 8c6510e6f1..3ff0f5dd95 100644 --- a/packages/heatmap/src/defaults.ts +++ b/packages/heatmap/src/defaults.ts @@ -17,9 +17,6 @@ export const commonDefaultProps: Omit< } = { layers: ['grid', 'axes', 'cells', 'legends', 'annotations'], - minValue: 'auto', - maxValue: 'auto', - forceSquare: false, xInnerPadding: 0, xOuterPadding: 0, diff --git a/packages/heatmap/src/hooks.ts b/packages/heatmap/src/hooks.ts index 5cd0a76045..7645e91c1e 100644 --- a/packages/heatmap/src/hooks.ts +++ b/packages/heatmap/src/hooks.ts @@ -141,8 +141,6 @@ export const useHeatMap = < ExtraProps extends object = Record >({ data, - minValue: _minValue = commonDefaultProps.minValue, - maxValue: _maxValue = commonDefaultProps.maxValue, valueFormat, width, height, @@ -163,8 +161,6 @@ export const useHeatMap = < hoverTarget = commonDefaultProps.hoverTarget, }: { data: HeatMapDataProps['data'] - minValue?: HeatMapCommonProps['minValue'] - maxValue?: HeatMapCommonProps['maxValue'] valueFormat?: HeatMapCommonProps['valueFormat'] width: number height: number diff --git a/packages/heatmap/src/types.ts b/packages/heatmap/src/types.ts index 7554d2a67f..d248a2140a 100644 --- a/packages/heatmap/src/types.ts +++ b/packages/heatmap/src/types.ts @@ -106,8 +106,6 @@ export type CellCanvasRenderer = ( export type CellShape = 'rect' | 'circle' export type HeatMapCommonProps = { - minValue: number | 'auto' - maxValue: number | 'auto' valueFormat: ValueFormat margin: Box