-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(legend): remove visibility button #252
Conversation
the visibility button is removed and the visibility change is applied on the legend item title BREAKING CHANGE: the `onLegendItemClick` click handler is no longer applied when clicking on the title. Instead a simple visibility change is applied.
Codecov Report
@@ Coverage Diff @@
## master #252 +/- ##
==========================================
+ Coverage 97.84% 97.91% +0.06%
==========================================
Files 36 36
Lines 2693 3162 +469
Branches 607 790 +183
==========================================
+ Hits 2635 3096 +461
- Misses 51 55 +4
- Partials 7 11 +4
Continue to review full report at Codecov.
|
What we do in Maps is replace the legend color indicator with the eyeClosed icon. We can do the same here though we may need to replace the icon with a smaller version since it's a bit overbearing compared to the dot.
Is this not the current interaction by clicking on the legend item?
Yes back when that functionality was actually in elastic-charts I had spoken with @emmacunningham about the UI for this and had proposed that any "extra" functionality that the consumer needs to add per legend item would be housed in an overflow context menu. Essentially: |
Clicking on vislib chart just only open the contextual menu with the color picker and the So the click will just hide/show the series without adding any filter. On a different PR we can add the contextual menu back again, so you can add any type of action on the selected legend item. |
@cchaos I've updated the code here with the icon when hiding the series |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Tested locally.
@@ -46,29 +46,32 @@ class LegendItemComponent extends React.Component<LegendItemProps, LegendItemSta | |||
const { legendItemKey } = this.props; | |||
const { color, label, isSeriesVisible, displayValue, onMouseEnter, onMouseLeave } = this.props; | |||
|
|||
const onTitleClick = this.onLegendTitleClick(legendItemKey); | |||
const onTitleClick = this.onVisibilityClick(legendItemKey); | |||
|
|||
const showLegendDisplayValue = this.props.chartStore!.showLegendDisplayValue.get(); | |||
const isSelected = legendItemKey === this.props.chartStore!.selectedLegendItemKey.get(); | |||
const hasDisplayValue = this.props.chartStore!.showLegendDisplayValue.get(); | |||
const hasTitleClickListener = Boolean(this.props.chartStore!.onLegendItemClickListener); | |||
return ( | |||
<div className="echLegendItem" onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you append a class of echLegendItem-isHidden
if it's hidden and then in the CSS do
.echLegendItem-isHidden { color: $euiColorDarkShade }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 42adb3b
const iconType = isSeriesVisible ? 'dot' : 'eyeClosed'; | ||
const iconColor = isSeriesVisible ? color : undefined; | ||
const ariaLabel = isSeriesVisible ? 'series color' : 'series hidden'; | ||
const viewBox = isSeriesVisible ? undefined : '-3 -3 22 22'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting way of sizing down the SVG, does this work in all browsers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, or at least it works correctly on Chrome, Firefox and IE 11. viewBox
is on the svg specs supported since 1.1
// TODO add color picker | ||
const iconType = isSeriesVisible ? 'dot' : 'eyeClosed'; | ||
const iconColor = isSeriesVisible ? color : undefined; | ||
const ariaLabel = isSeriesVisible ? 'series color' : 'series hidden'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have learned that aria-label
attributes directly on svg
's don't work with screen readers. You should apply this to the wrapping div. I would also add this as the title
attribute to the wrapping div.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in e40a42d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
# [8.0.0](v7.2.1...v8.0.0) (2019-07-15) ### Code Refactoring * **legend:** remove visibility button ([#252](#252)) ([90a1ba7](90a1ba7)) ### Features * **style:** allow fill and stroke overrides ([#258](#258)) ([99c5e9f](99c5e9f)) ### BREAKING CHANGES * **style:** `LineStyle`, `AreaStyle` and `BarSeriesStyle` types differs on the optional values. `stroke` and `fill` on the theme or specific series style now override the computed series color. * fix: no unused locals error on theme * fix: avoid key prop override by spread operator * test: increase test coverage on PR changes * fix: fontSize is now always a number * test: increase coverage for rendendering * refactor(story): simplify theme merging on `with value label` story * refactor: removed mergeWithDefaultTheme * **legend:** the `onLegendItemClick` click handler is no longer applied when clicking on the title. Instead a simple visibility change is applied.
🎉 This PR is included in version 8.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [8.0.0](elastic/elastic-charts@v7.2.1...v8.0.0) (2019-07-15) ### Code Refactoring * **legend:** remove visibility button ([opensearch-project#252](elastic/elastic-charts#252)) ([efb3823](elastic/elastic-charts@efb3823)) ### Features * **style:** allow fill and stroke overrides ([opensearch-project#258](elastic/elastic-charts#258)) ([1648996](elastic/elastic-charts@1648996)) ### BREAKING CHANGES * **style:** `LineStyle`, `AreaStyle` and `BarSeriesStyle` types differs on the optional values. `stroke` and `fill` on the theme or specific series style now override the computed series color. * fix: no unused locals error on theme * fix: avoid key prop override by spread operator * test: increase test coverage on PR changes * fix: fontSize is now always a number * test: increase coverage for rendendering * refactor(story): simplify theme merging on `with value label` story * refactor: removed mergeWithDefaultTheme * **legend:** the `onLegendItemClick` click handler is no longer applied when clicking on the title. Instead a simple visibility change is applied.
Summary
This PR removes the visibility button. The visibility change handling is applied on the legend item title.
BREAKING CHANGE: the
onLegendItemClick
click handler is no longer applied when clicking on the title. Instead a simple visibility change is applied.Before:
After:
cc @cchaos
I've some doubts on this because removes two important features right now:
strikethroughenough or is much more difficult to read?Before merging I'd like to check with you @cchaos these things.
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.src/index.ts
(and stories only import from../src
except for test data & storybook)