Skip to content
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

Merged
merged 4 commits into from
Jul 15, 2019

Conversation

markov00
Copy link
Member

@markov00 markov00 commented Jul 2, 2019

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:
Screenshot 2019-07-02 at 10 13 31

After:
Screenshot 2019-07-02 at 10 12 48

cc @cchaos
I've some doubts on this because removes two important features right now:

  • without the eye/eyeclosed icons we don't have a graphic representation that specify that a series is hidden. Is a strikethrough enough or is much more difficult to read?
  • There are few legend item interaction that we need to support:
    • Hide/show series (currently the only interaction on TSVB, but not an interaction on vizlib)
    • click to filter (on vizlib clicking on the legend item is used to create and apply a global filter)

Before merging I'd like to check with you @cchaos these things.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

  • Any consumer-facing exports were added to src/index.ts (and stories only import from ../src except for test data & storybook)
  • This was checked for cross-browser compatibility, including a check against IE11
  • Proper documentation or storybook story was added for features that require explanation or tutorials
  • Unit tests were updated or added to match the most common scenarios
  • Each commit follows the convention

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-io
Copy link

codecov-io commented Jul 2, 2019

Codecov Report

Merging #252 into master will increase coverage by 0.06%.
The diff coverage is n/a.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/lib/series/stacked_series_utils.ts 96.47% <0%> (-1.75%) ⬇️
src/state/utils.ts 96.28% <0%> (-0.16%) ⬇️
src/lib/series/specs.ts 100% <0%> (ø) ⬆️
src/lib/series/series.ts 100% <0%> (ø) ⬆️
src/lib/series/domains/y_domain.ts 100% <0%> (ø) ⬆️
src/lib/axes/canvas_text_bbox_calculator.ts 100% <0%> (ø) ⬆️
src/lib/axes/axis_utils.ts 100% <0%> (ø) ⬆️
src/lib/utils/commons.ts 100% <0%> (ø) ⬆️
src/lib/series/rendering.ts 98.06% <0%> (+0.15%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update af92736...e40a42d. Read the comment docs.

@cchaos
Copy link
Contributor

cchaos commented Jul 2, 2019

without the eye/eyeclosed icons we don't have a graphic representation that specify that a series is hidden

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.

There are few legend item interaction that we need to support:

  • Hide/show series (currently the only interaction on TSVB, but not an interaction on vizlib)

Is this not the current interaction by clicking on the legend item?

  • click to filter (on vizlib clicking on the legend item is used to create and apply a global filter)

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:

@cchaos
Copy link
Contributor

cchaos commented Jul 2, 2019

Also I'm not sure if this was introduced in this branch or not but I saw a bug in the Legend / hide legend items by series example when clicking to hide the series:

@markov00
Copy link
Member Author

markov00 commented Jul 2, 2019

  • Hide/show series (currently the only interaction on TSVB, but not an interaction on vizlib)

Is this not the current interaction by clicking on the legend item?

Clicking on vislib chart just only open the contextual menu with the color picker and the + - buttons to filter the element, where in tsvb clicking doesn't add any filter, just hide/show the series.

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.

@markov00
Copy link
Member Author

markov00 commented Jul 3, 2019

@cchaos I've updated the code here with the icon when hiding the series
Screenshot 2019-07-03 at 19 39 16

@markov00 markov00 added :legend Legend related issue :styling Styling related issue enhancement New feature or request labels Jul 3, 2019
Copy link
Collaborator

@nickofthyme nickofthyme left a 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}>
Copy link
Contributor

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 }

Copy link
Member Author

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';
Copy link
Contributor

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?

Copy link
Member Author

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';
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in e40a42d

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@markov00 markov00 merged commit 90a1ba7 into elastic:master Jul 15, 2019
markov00 pushed a commit that referenced this pull request Jul 15, 2019
# [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.
@markov00
Copy link
Member Author

🎉 This PR is included in version 8.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@markov00 markov00 added the released Issue released publicly label Jul 15, 2019
@markov00 markov00 deleted the remove_visibility_button branch November 25, 2020 11:44
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Feb 10, 2022
# [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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request :legend Legend related issue released Issue released publicly :styling Styling related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants