diff --git a/ui/src/shared/components/Dygraph.js b/ui/src/shared/components/Dygraph.js index 571e3f1d56..d9ecf3062e 100644 --- a/ui/src/shared/components/Dygraph.js +++ b/ui/src/shared/components/Dygraph.js @@ -24,6 +24,7 @@ export default class Dygraph extends Component { isHidden: true, isAscending: true, isSnipped: false, + isFilterVisible: false, } this.sync = ::this.sync @@ -32,6 +33,7 @@ export default class Dygraph extends Component { this.handleLegendInputChange = ::this.handleLegendInputChange this.handleSnipLabel = ::this.handleSnipLabel this.handleHideLegend = ::this.handleHideLegend + this.handleToggleFilter = ::this.handleToggleFilter } static defaultProps = { @@ -280,6 +282,13 @@ export default class Dygraph extends Component { this.setState({isSnipped: !this.state.isSnipped}) } + handleToggleFilter() { + this.setState({ + isFilterVisible: !this.state.isFilterVisible, + filterText: '', + }) + } + handleHideLegend(e) { const {top, bottom, left, right} = this.graphRef.getBoundingClientRect() @@ -303,6 +312,7 @@ export default class Dygraph extends Component { sortType, isHidden, isSnipped, + isFilterVisible, } = this.state return ( @@ -312,13 +322,15 @@ export default class Dygraph extends Component { sortType={sortType} onHide={this.handleHideLegend} isHidden={isHidden} + isFilterVisible={isFilterVisible} isSnipped={isSnipped} filterText={filterText} isAscending={isAscending} onSnip={this.handleSnipLabel} onSort={this.handleSortLegend} - legendRef={el => this.legendRef = el} + legendRef={el => (this.legendRef = el)} onInputChange={this.handleLegendInputChange} + onToggleFilter={this.handleToggleFilter} />
{ diff --git a/ui/src/shared/components/DygraphLegend.js b/ui/src/shared/components/DygraphLegend.js index 9104136d68..18b7b48f54 100644 --- a/ui/src/shared/components/DygraphLegend.js +++ b/ui/src/shared/components/DygraphLegend.js @@ -13,12 +13,14 @@ const DygraphLegend = ({ onSnip, onHide, isHidden, + isFilterVisible, isSnipped, sortType, legendRef, filterText, isAscending, onInputChange, + onToggleFilter, xHTML, }) => { const sorted = _.sortBy( @@ -68,19 +70,32 @@ const DygraphLegend = ({ >
{xHTML}
- {renderSortAlpha} {renderSortNum} +
+ {isFilterVisible + ? + : null} +
{filtered.map(({label, color, yHTML, isHighlighted}) => { const seriesClass = isHighlighted @@ -88,9 +103,9 @@ const DygraphLegend = ({ : 'dygraph-legend--row' return (
- + {isSnipped ? removeMeasurement(label) : label} - +
{yHTML || 'no value'}
) @@ -120,12 +135,14 @@ DygraphLegend.propTypes = { onHide: func.isRequired, onSort: func.isRequired, onInputChange: func.isRequired, + onToggleFilter: func.isRequired, filterText: string.isRequired, isAscending: bool.isRequired, sortType: string.isRequired, isHidden: bool.isRequired, legendRef: func.isRequired, isSnipped: bool.isRequired, + isFilterVisible: bool.isRequired, } export default DygraphLegend diff --git a/ui/src/style/components/dygraphs.scss b/ui/src/style/components/dygraphs.scss index 131bd84fb3..654c309042 100644 --- a/ui/src/style/components/dygraphs.scss +++ b/ui/src/style/components/dygraphs.scss @@ -152,9 +152,6 @@ display: flex; align-items: center; flex-wrap: nowrap; - padding-bottom: 8px; - border-bottom: 2px solid $g5-pepper; - margin-bottom: 8px; > .btn { margin-left: 4px; } } @@ -164,9 +161,17 @@ line-height: 30px; font-weight: 600; color: $g13-mist; + flex: 1 0 0; } .dygraph-legend--filter { flex: 1 0 0; + margin-top: 8px; +} +.dygraph-legend--divider { + width: 100%; + margin: 8px 0; + height: 2px; + background-color: $g5-pepper; } .dygraph-legend--contents { font-size: 13px; @@ -187,7 +192,7 @@ line-height: 13px; padding: 3px 0; - caption { + span { font-weight: 600; padding: 0; white-space: nowrap;