diff --git a/src/components/legend/_legend_item.scss b/src/components/legend/_legend_item.scss index f5c03bfe94..cd3c4e31a7 100644 --- a/src/components/legend/_legend_item.scss +++ b/src/components/legend/_legend_item.scss @@ -52,7 +52,7 @@ text-align: right; font-feature-settings: 'tnum'; - &.echLegendItem__displayValue--hidden { + &--hidden { display: none; } } diff --git a/src/components/legend/legend.tsx b/src/components/legend/legend.tsx index ec9b68f90e..f984b2fe7a 100644 --- a/src/components/legend/legend.tsx +++ b/src/components/legend/legend.tsx @@ -48,27 +48,7 @@ class LegendComponent extends React.Component { return (
-
- {[...legendItems.values()].map((item) => { - // const { isLegendItemVisible } = item; - - // const legendItemProps = { - // key: item.key, - // className: classNames('echLegendList__item', { - // 'echLegendList__item--hidden': !isLegendItemVisible, - // }), - // onMouseEnter: this.onLegendItemMouseover(item.key), - // onMouseLeave: this.onLegendItemMouseout, - // }; - - return this.renderLegendElement( - item, - item.key, - this.onLegendItemMouseover(item.key), - this.onLegendItemMouseout, - ); - })} -
+
{[...legendItems.values()].map(this.renderLegendElement)}
); @@ -82,23 +62,28 @@ class LegendComponent extends React.Component { this.props.chartStore!.onLegendItemOut(); }; - private renderLegendElement = ( - { color, label, isSeriesVisible, displayValue }: SeriesLegendItem, - legendItemKey: string, - onMouseEnter: (event: React.MouseEvent) => void, - onMouseLeave: () => void, - ) => { + private renderLegendElement = (item: SeriesLegendItem) => { + const { key, displayValue } = item; const tooltipValues = this.props.chartStore!.legendItemTooltipValues.get(); let tooltipValue; - if (tooltipValues && tooltipValues.get(legendItemKey)) { - tooltipValue = tooltipValues.get(legendItemKey); + if (tooltipValues && tooltipValues.get(key)) { + tooltipValue = tooltipValues.get(key); } - const display = tooltipValue != null ? tooltipValue : displayValue.formatted; - const props = { color, label, isSeriesVisible, legendItemKey, displayValue: display }; + const newDisplayValue = tooltipValue != null ? tooltipValue : displayValue.formatted; + console.log('renderLegendElement', item.key, item.isLegendItemVisible); - return ; + return ( + + ); }; } diff --git a/src/components/legend/legend_item.tsx b/src/components/legend/legend_item.tsx index c72937d5d4..d23ac9df9c 100644 --- a/src/components/legend/legend_item.tsx +++ b/src/components/legend/legend_item.tsx @@ -11,6 +11,7 @@ interface LegendItemProps { color: string | undefined; label: string | undefined; isSeriesVisible?: boolean; + isLegendItemVisible?: boolean; displayValue: string; onMouseEnter: (event: React.MouseEvent) => void; onMouseLeave: () => void; @@ -44,7 +45,7 @@ class LegendItemComponent extends React.Component {this.renderColor(this.toggleColorPicker, color, isSeriesVisible)}