@@ -46,29 +46,35 @@ class LegendItemComponent extends React.Component<LegendItemProps, LegendItemSta
4646 const { legendItemKey } = this . props ;
4747 const { color, label, isSeriesVisible, displayValue, onMouseEnter, onMouseLeave } = this . props ;
4848
49- const onTitleClick = this . onLegendTitleClick ( legendItemKey ) ;
49+ const onTitleClick = this . onVisibilityClick ( legendItemKey ) ;
5050
5151 const showLegendDisplayValue = this . props . chartStore ! . showLegendDisplayValue . get ( ) ;
5252 const isSelected = legendItemKey === this . props . chartStore ! . selectedLegendItemKey . get ( ) ;
5353 const hasDisplayValue = this . props . chartStore ! . showLegendDisplayValue . get ( ) ;
5454 const hasTitleClickListener = Boolean ( this . props . chartStore ! . onLegendItemClickListener ) ;
55+ const itemClasses = classNames ( 'echLegendItem' , {
56+ 'echLegendItem-isHidden' : ! isSeriesVisible ,
57+ } ) ;
5558 return (
56- < div className = "echLegendItem" onMouseEnter = { onMouseEnter } onMouseLeave = { onMouseLeave } >
57- { this . renderColor ( this . toggleColorPicker , color ) }
58- { this . renderVisibilityButton ( legendItemKey , isSeriesVisible ) }
59+ < div className = { itemClasses } onMouseEnter = { onMouseEnter } onMouseLeave = { onMouseLeave } >
60+ { this . renderColor ( this . toggleColorPicker , color , isSeriesVisible ) }
5961 { this . renderTitle ( label , onTitleClick , hasTitleClickListener , isSelected , hasDisplayValue ) }
6062 { this . renderDisplayValue ( displayValue , showLegendDisplayValue , isSeriesVisible ) }
6163 </ div >
6264 ) ;
6365 }
64- renderColor ( colorClickAction : ( ) => void , color : string | undefined ) {
66+ renderColor ( colorClickAction : ( ) => void , color ? : string , isSeriesVisible : boolean = true ) {
6567 if ( ! color ) {
6668 return null ;
6769 }
68- // TODO add color picler
70+ // TODO add color picker
71+ const iconType = isSeriesVisible ? 'dot' : 'eyeClosed' ;
72+ const iconColor = isSeriesVisible ? color : undefined ;
73+ const title = isSeriesVisible ? 'series color' : 'series hidden' ;
74+ const viewBox = isSeriesVisible ? undefined : '-3 -3 22 22' ;
6975 return (
70- < div className = "echLegendItem__color" >
71- < Icon type = "dot" aria-label = "series color" color = { color } onClick = { colorClickAction } />
76+ < div className = "echLegendItem__color" aria-label = { title } title = { title } >
77+ < Icon type = { iconType } color = { iconColor } onClick = { colorClickAction } viewBox = { viewBox } />
7278 </ div >
7379 ) ;
7480 }
@@ -84,7 +90,7 @@ class LegendItemComponent extends React.Component<LegendItemProps, LegendItemSta
8490
8591 renderTitle (
8692 title : string | undefined ,
87- onTitleClick : ( ) => void ,
93+ onTitleClick : ( event : React . MouseEvent < Element , MouseEvent > ) => void ,
8894 hasTitleClickListener : boolean ,
8995 isSelected : boolean ,
9096 hasDisplayValue : boolean ,
@@ -153,7 +159,7 @@ class LegendItemComponent extends React.Component<LegendItemProps, LegendItemSta
153159 // );
154160 // }
155161
156- private onVisibilityClick = ( legendItemKey : string ) => ( event : React . MouseEvent < SVGElement > ) => {
162+ private onVisibilityClick = ( legendItemKey : string ) => ( event : React . MouseEvent ) => {
157163 if ( event . shiftKey ) {
158164 this . props . chartStore ! . toggleSingleSeries ( legendItemKey ) ;
159165 } else {
0 commit comments