Skip to content

Commit

Permalink
feat(heatmap): add missing event handlers to the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
plouc committed Jan 12, 2022
1 parent 849c7d7 commit bac7d7a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 61 deletions.
1 change: 0 additions & 1 deletion packages/heatmap/src/canvas.tsx
Expand Up @@ -14,7 +14,6 @@ export const renderRect = <Datum extends HeatMapDatum>(

ctx.fillStyle = color
if (borderWidth > 0) {
console.log(borderWidth)
ctx.strokeStyle = borderColor
ctx.lineWidth = borderWidth
}
Expand Down
40 changes: 0 additions & 40 deletions packages/heatmap/src/hooks.ts
Expand Up @@ -260,46 +260,6 @@ export const useHeatMap = <
offsetY,
}
}, [data, keys, width, height, padding, forceSquare])
const sizeScale = useMemo(() => {
if (sizeVariation > 0) {
return scaleLinear()
.range([1 - sizeVariation, 1])
.domain([values.min, values.max])
}
}, [sizeVariation, values])
const cells = useMemo(
() =>
computeCells<Datum>({
data,
keys,
getIndex,
xScale: scales.x,
yScale: scales.y,
sizeScale,
cellOpacity,
cellWidth: layoutConfig.cellWidth,
cellHeight: layoutConfig.cellHeight,
colorScale,
nanColor,
getLabel,
getLabelTextColor,
}),
[
data,
keys,
getIndex,
scales,
sizeScale,
cellOpacity,
layoutConfig,
colorScale,
nanColor,
getLabel,
getLabelTextColor,
]
)
*/
}

Expand Down
53 changes: 33 additions & 20 deletions website/src/data/components/heatmap/props.ts
Expand Up @@ -31,6 +31,8 @@ const props: ChartProperty[] = [
}[]
}[]
\`\`\`
Please note that each serie **MUST** have the same length.
`,
},
{
Expand Down Expand Up @@ -418,30 +420,41 @@ const props: ChartProperty[] = [
defaultValue: defaults.isInteractive,
}),
{
key: 'onClick',
flavors: ['svg', 'canvas'],
key: 'tooltip',
group: 'Interactivity',
type: '(cell, event) => void',
help: 'onClick handler.',
type: 'TooltipComponent',
help: 'Custom tooltip component.',
flavors: ['svg', 'canvas'],
description: `
onClick handler, will receive node data
as first argument & event as second one.
The node data has the following shape:
\`\`\`
{
key: string,
value: number,
x: number,
xKey: {string|number},
y: number,
yKey: {string|number},
width: number,
height: number,
opacity: number
}
\`\`\`
An optional component allowing complete tooltip customisation,
it must return a valid HTML element and will receive
the cell's data as a property.
`,
},
{
key: 'onMouseEnter',
flavors: ['svg'],
group: 'Interactivity',
type: '(cell: ComputedCell, event: MouseEvent) => void',
},
{
key: 'onMouseMove',
flavors: ['svg'],
group: 'Interactivity',
type: '(cell: ComputedCell, event: MouseEvent) => void',
},
{
key: 'onMouseLeave',
flavors: ['svg'],
group: 'Interactivity',
type: '(cell: ComputedCell, event: MouseEvent) => void',
},
{
key: 'onClick',
flavors: ['svg', 'canvas'],
group: 'Interactivity',
type: '(cell: ComputedCell, event: MouseEvent) => void',
},
{
key: 'hoverTarget',
flavors: ['svg', 'canvas'],
Expand Down

0 comments on commit bac7d7a

Please sign in to comment.