mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* move charts to toolkit * refactor imports * fix tests * change the behavior of the color mode hook and add the noWatermark prop * fix gas tracker test and fix toolkit build
17 lines
556 B
TypeScript
17 lines
556 B
TypeScript
import { range } from 'es-toolkit';
|
|
import React from 'react';
|
|
|
|
export function useChartLegend(dataLength: number) {
|
|
const [ selectedLines, setSelectedLines ] = React.useState<Array<number>>(range(dataLength));
|
|
|
|
const handleLegendItemClick = React.useCallback((index: number) => {
|
|
const nextSelectedLines = selectedLines.includes(index) ? selectedLines.filter((item) => item !== index) : [ ...selectedLines, index ];
|
|
setSelectedLines(nextSelectedLines);
|
|
}, [ selectedLines ]);
|
|
|
|
return {
|
|
selectedLines,
|
|
handleLegendItemClick,
|
|
};
|
|
}
|