Skip to content

Commit

Permalink
feat(heatmap): remove min/max value properties as they should be cont…
Browse files Browse the repository at this point in the history
…rolled where needed, for example the colors
  • Loading branch information
plouc committed Jan 12, 2022
1 parent b5527c1 commit 7a5a922
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 19 deletions.
2 changes: 0 additions & 2 deletions packages/heatmap/src/HeatMap.tsx
Expand Up @@ -23,8 +23,6 @@ type InnerHeatMapProps<Datum extends HeatMapDatum, ExtraProps extends object> =
const InnerHeatMap = <Datum extends HeatMapDatum, ExtraProps extends object>({
data,
layers = svgDefaultProps.layers,
minValue: _minValue = svgDefaultProps.minValue,
maxValue: _maxValue = svgDefaultProps.maxValue,
valueFormat,
width,
height,
Expand Down
17 changes: 9 additions & 8 deletions 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'
Expand All @@ -25,8 +25,6 @@ type InnerNetworkCanvasProps<Datum extends HeatMapDatum, ExtraProps extends obje
const InnerHeatMapCanvas = <Datum extends HeatMapDatum, ExtraProps extends object>({
data,
layers = canvasDefaultProps.layers,
minValue: _minValue = canvasDefaultProps.minValue,
maxValue: _maxValue = canvasDefaultProps.maxValue,
valueFormat,
width,
height,
Expand Down Expand Up @@ -113,11 +111,14 @@ const InnerHeatMapCanvas = <Datum extends HeatMapDatum, ExtraProps extends objec

const theme = useTheme()

const customLayerProps: CustomLayerProps<Datum> = {
cells,
activeCell,
setActiveCell,
}
const customLayerProps: CustomLayerProps<Datum> = useMemo(
() => ({
cells,
activeCell,
setActiveCell,
}),
[cells, activeCell, setActiveCell]
)

useEffect(() => {
if (canvasEl.current === null) return
Expand Down
3 changes: 0 additions & 3 deletions packages/heatmap/src/defaults.ts
Expand Up @@ -17,9 +17,6 @@ export const commonDefaultProps: Omit<
} = {
layers: ['grid', 'axes', 'cells', 'legends', 'annotations'],

minValue: 'auto',
maxValue: 'auto',

forceSquare: false,
xInnerPadding: 0,
xOuterPadding: 0,
Expand Down
4 changes: 0 additions & 4 deletions packages/heatmap/src/hooks.ts
Expand Up @@ -141,8 +141,6 @@ export const useHeatMap = <
ExtraProps extends object = Record<string, never>
>({
data,
minValue: _minValue = commonDefaultProps.minValue,
maxValue: _maxValue = commonDefaultProps.maxValue,
valueFormat,
width,
height,
Expand All @@ -163,8 +161,6 @@ export const useHeatMap = <
hoverTarget = commonDefaultProps.hoverTarget,
}: {
data: HeatMapDataProps<Datum, ExtraProps>['data']
minValue?: HeatMapCommonProps<Datum>['minValue']
maxValue?: HeatMapCommonProps<Datum>['maxValue']
valueFormat?: HeatMapCommonProps<Datum>['valueFormat']
width: number
height: number
Expand Down
2 changes: 0 additions & 2 deletions packages/heatmap/src/types.ts
Expand Up @@ -106,8 +106,6 @@ export type CellCanvasRenderer<Datum extends HeatMapDatum> = (
export type CellShape = 'rect' | 'circle'

export type HeatMapCommonProps<Datum extends HeatMapDatum> = {
minValue: number | 'auto'
maxValue: number | 'auto'
valueFormat: ValueFormat<number>

margin: Box
Expand Down

0 comments on commit 7a5a922

Please sign in to comment.