File tree Expand file tree Collapse file tree
packages/ui-components/src/ui/chart Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import * as React from 'react' ;
2- import { useCallback , useMemo , useState } from 'react' ;
2+ import { useMemo } from 'react' ;
33import {
44 Bar ,
55 Customized ,
@@ -16,6 +16,7 @@ import {
1616 ChartTooltipContent ,
1717 PlotAreaBackground ,
1818} from './chart' ;
19+ import { useHiddenKeys } from './use-hidden-keys' ;
1920
2021export type BarChartBarDefinition = {
2122 dataKey : string ;
@@ -56,7 +57,7 @@ export function BarChart({
5657 legendClassName,
5758 className,
5859} : BarChartProps ) : React . JSX . Element {
59- const [ hiddenKeys , setHiddenKeys ] = useState < Set < string > > ( new Set ( ) ) ;
60+ const { hiddenKeys, toggleKey } = useHiddenKeys ( ) ;
6061
6162 const yAxisDomain = useMemo < [ number , number ] > ( ( ) => {
6263 let max = 0 ;
@@ -76,18 +77,6 @@ export function BarChart({
7677 return [ 0 , max ] ;
7778 } , [ data , bars ] ) ;
7879
79- const toggleKey = useCallback ( ( key : string ) => {
80- setHiddenKeys ( ( prev ) => {
81- const next = new Set ( prev ) ;
82- if ( next . has ( key ) ) {
83- next . delete ( key ) ;
84- } else {
85- next . add ( key ) ;
86- }
87- return next ;
88- } ) ;
89- } , [ ] ) ;
90-
9180 return (
9281 < ChartContainer config = { config } className = { className } >
9382 < RechartsBarChart
Original file line number Diff line number Diff line change 11export * from './bar-chart' ;
22export * from './chart' ;
3+ export * from './combo-chart' ;
You can’t perform that action at this time.
0 commit comments