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

[Lens] Color in dimension trigger #76871

Merged
merged 29 commits into from
Nov 17, 2020

Conversation

flash1293
Copy link
Contributor

@flash1293 flash1293 commented Sep 7, 2020

Based on #79851

Fixes #68405

This unfinished PR adds color indicators for dimension in xy chart.

Please don't review in depth yet, this PR is not cleaned up yet.

Feature

The indicators are shown when possible. If the color can't be determined (because "break down by" is used), the "disabled" icon is shown. For dimensions containing a color palette picker, the currently picked palette is shown in the dimension picker.

Screenshot 2020-11-05 at 10 43 41

Screenshot 2020-11-05 at 10 43 22

Screenshot 2020-11-05 at 10 42 55

The color indicator does not contain a color picker itself - to change the color you still have to open the dimension popover. As soon as the flyout dimension config PR lands, I think this is justifiable as it's just a single click away.

Implementation

This PR extends the chart config like this: https://github.com/elastic/kibana/pull/76871/files#diff-c46757b63dd572e7cff7c0aad72c3ec135b9969c39716d4db9df551fa962ce34R347-R361

When passing the accessors to the frame, it's possible to specify a color icon as well. Another option would be to provide a renderColorIndicator or something along those lines (maybe making it more than generic than being about colors) and using a separate NativeRenderer. This would give the visualization more flexibility - I thought it would add unnecessary complexity in this specific situation, but I don't hold this opinion strongly.

The logic to determine the current color of a dimension (https://github.com/elastic/kibana/pull/76871/files#diff-5dcc03dab8d34631c6ed65b6b38f8b97eed0394699532c6516111c735a8e30bfR177-R220) works like this:

  • Check whether currently rendered data is available - if not, don't show an indicator
  • Check whether current layer has a break down by dimension - if yes, show the disabled icon
  • Check whether there is an override color - if yes, show that
  • Use the same color assignment logic as the actual chart to determine the current series color

Quick note about layout: To make the color indicator clickable like the dimension trigger rendered by the datasource, the EuiLink component rendering the button is moved out of the datasource into the frame - this means the datasource only has to render the text instead of having to handle the logic to actually open the popover: https://github.com/elastic/kibana/pull/76871/files#diff-9d5c4c19a499161633fc439fb1b86a6105bf7b2af2cdf638c52cec4f2a3c4f3cL93

Other changes:

@elastic elastic deleted a comment from cchaos Nov 5, 2020
@elastic elastic deleted a comment from AlonaNadler Nov 5, 2020
@flash1293
Copy link
Contributor Author

@elasticmachine merge upstream

@mbondyra
Copy link
Contributor

mbondyra commented Nov 10, 2020

What an amazing PR 😻

From small things I noticed:

This PR changed slightly the styles for focused dimension trigger:

Opinion land:

I wonder if in the case below we want to display the the little square logo for yAxis at all... I feel like skipping it would be less confusing. Or maybe we could add a tooltip to explain what it means?

@flash1293
Copy link
Contributor Author

flash1293 commented Nov 10, 2020

Pinging @MichaelMarcialis for the style of color palettes inside of dimension triggers and Martas suggestion here: #76871 (comment)

I see the point, I was following the mocks here but I think just not showing anything for splitted y axis metrics is better.

@MichaelMarcialis
Copy link
Contributor

This is looking great, @flash1293. While comparing your screenshots to @cchaos's latest (I think) mockups for chart coloring, I noticed that there were a few places that this PR deviates from those designs, including:

  • The brush icon appears to be used, where the mockups use color.
  • The stopSlash icon appears to be used, where the latest mockups appear to use no icon when axis color indicators are removed due to a breakdown palette being added.
  • The brush icon uses $euiLinkColor, where the mockups use the default text color.
  • The color bar placement here is flush with the left/bottom/right of its container, but is padded within its container in the mockups.

Was there a reason for these deviations? Am I looking at an older mockup, or is this just the first part of a multi-PR effort (as your initial comment appears to indicate)? Thanks!

image

@MichaelMarcialis
Copy link
Contributor

This PR changed slightly the styles for focused dimension trigger:

Is there any way we can fix this so that the focus states updated as part of @mbondyra's recent reordering PR can remain intact? Figma examples of what was she implemented can be found here: https://www.figma.com/file/q61JmGHmcammPfkxupNj1g/Intradimensional-Reordering-Version-1-In-Progress?node-id=1%3A2

I wonder if in the case below we want to display the the little square logo for yAxis at all... I feel like skipping it would be less confusing. Or maybe we could add a tooltip to explain what it means?

Per my earlier comment, @cchaos's most recent mockups appear to omit this stopSlash icon altogether (unless I'm looking at an outdated file). Personally, after having seen it both ways, I tend to like the inclusion of the icon because it:

  1. Provides consistency between dimensional items, in terms of having a preceding icon, having the text aligned the same across items, etc.
  2. Is potentially helpful for users to quickly identify existing or possible areas of color control.

Regarding applying a tooltip to these stopSlash icons, I'm a bit hesitant to recommend that direction, as there's already a lot interaction already attached to each dimensional item. Most importantly, I don't wish to potentially interfere with the drag-and-drop (i.e. hovering the icon opens a tooltip, which inadvertently prevents a portion of the item from being draggable). I wonder if simply using a lower contrast icon color (such as $euiColorMediumShade) would put less of a spotlight on it and better indicate that it's a swatch chip in a disabled/empty state. Perhaps we could also explain further in the item's color field in the configuration flyout that it's being overridden. Thoughts?

@flash1293
Copy link
Contributor Author

flash1293 commented Nov 11, 2020

Thanks for the reviews. I tried to address all of the things, this is the summary:

  • Code:
    • Moved color logic into separate components/functions
    • Removed the ability to specify an accessor config as string (you are right Marta, not really necessary)
  • Behavior:
    • Using text color for brush
    • Fixing focus style
    • Using subdued color for stopSlash

@MichaelMarcialis

Personally, after having seen it both ways, I tend to like the inclusion of the icon

I left it in with a little less prominent color. No strong opinion here.

About the differences not addressed above:

The brush icon appears to be used, where the mockups use color.

I didn't find the right icon, maybe it's not released yet? If I'm using <EuiIcon type="color", I don't get an icon at all. Am I looking in the wrong place?

The color bar placement here is flush with the left/bottom/right of its container, but is padded within its container in the mockups.

I did that as a quick and dirty solution, but then I ended up liking it because it's not adding to the vertical space, preventing scrolling for a little bit longer. If you think it's not the right thing I can move to the style in Carolines mock.

Screenshot 2020-11-11 at 18 42 51

Copy link
Contributor

@MichaelMarcialis MichaelMarcialis left a comment

Choose a reason for hiding this comment

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

Hey, @flash1293. Took a deeper look at the code and left a few comments for your review.

Comment on lines +14 to +25
<EuiFlexGroup className="lnsLayerPanel__paletteContainer" gutterSize="none" alignItems="center">
{accessorConfig.palette.map((color) => (
<EuiFlexItem
key={color}
className="lnsLayerPanel__paletteColor"
grow={true}
style={{
backgroundColor: color,
}}
/>
))}
</EuiFlexGroup>
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than rolling out a custom color palette component, would it be better to use EuiColorPaletteDisplay instead (and override as necessary if needed)?

https://elastic.github.io/eui/#/forms/color-selection

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This component is very new - the version supporting it is not available in Kibana yet. I'm fine with using it once it becomes available, but #82730 has to get merged first.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good. Should I open an issue as a reminder? Or is that unnecessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't bother, I will take care of it.

@@ -86,11 +86,11 @@ export const IndexPatternDimensionTriggerComponent = function IndexPatternDimens
}
anchorClassName="eui-displayBlock"
>
<EuiLink
<EuiText
Copy link
Contributor

Choose a reason for hiding this comment

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

There are a few questions/concerns I have due to the change from EuiLink to EuiText:

  • Since this element is no longer focusable, the styles applied by @mbondyra in a previous PR no longer set the focus styles (light blue background color behind text) appropriately for the child .lnsLayerPanel__triggerLinkLabel element. Can this be corrected?
  • I believe this aria-label now no longer applies to this element. Can we move to the appropriate location?
  • Should the lnsLayerPanel__triggerLink class name be changed, since it's no longer a link?

@flash1293
Copy link
Contributor Author

Thanks for the review, @MichaelMarcialis

These are the changes I made:

  • Use eui icon for solid color indicators as well
  • Set aria labels for them
  • Didn't change palette to the EUI implementation as this component is not available in Kibana yet
  • Fixed focus styles (I hope :) ) - I moved the focus style logic to the right class
  • Renamed lnsLayerPanel__triggerLink to lnsLayerPanel__triggerText as the link part is now handled by the frame in lnsLayerPanel__dimensionLink- move aria label / title to the button element again as well

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
lens 433 435 +2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
lens 917.9KB 924.7KB +6.8KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
lens 50.7KB 52.4KB +1.7KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@MichaelMarcialis MichaelMarcialis left a comment

Choose a reason for hiding this comment

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

Thank you for addressing those suggested changes. This LGTM.

@MichaelMarcialis
Copy link
Contributor

The color bar placement here is flush with the left/bottom/right of its container, but is padded within its container in the mockups.

I did that as a quick and dirty solution, but then I ended up liking it because it's not adding to the vertical space, preventing scrolling for a little bit longer. If you think it's not the right thing I can move to the style in Carolines mock.

Personally, I like how you've positioned the palette here and can appreciate the vertical real estate savings. Was just checking to see if there was a different reason for the deviation. I say we keep it positioned as you currently have it.

@wylieconlon wylieconlon self-requested a review November 17, 2020 00:28
Copy link
Contributor

@mbondyra mbondyra left a comment

Choose a reason for hiding this comment

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

tested on Safari, works as expected. Code LGTM 🟢

@flash1293
Copy link
Contributor Author

Merging now, I will replace the custom palette code with the EUI component once it becomes available

@flash1293 flash1293 merged commit 95e44f2 into elastic:master Nov 17, 2020
flash1293 added a commit to flash1293/kibana that referenced this pull request Nov 17, 2020
gmmorris added a commit to gmmorris/kibana that referenced this pull request Nov 17, 2020
* master: (51 commits)
  [ML] Persisted URL state for the Data frame analytics jobs and models pages (elastic#83439)
  adds xpack.security.authc.selector.enabled setting (elastic#83551)
  skip flaky suite (elastic#77279)
  [ML] Improve support for script and aggregation fields in anomaly detection jobs (elastic#81923)
  [Workplace Search] Migrate SourcesLogic from ent-search (elastic#83544)
  [ML] Add UI test for feature importance features (elastic#82677)
  [Maps] Improve icons for all layer types (elastic#83503)
  Replace experimental badge with Beta (elastic#83468)
  [Fleet][EPM] Unified install and archive (elastic#83384)
  Move src/legacy/server/keystore to src/cli (elastic#83483)
  Used SO for saving the API key IDs that should be deleted (elastic#82211)
  [Uptime] Mock implementation to account for math flakiness test (elastic#83535)
  [Workplace Search] Enable check for org context based on URL (elastic#83487)
  [App Search] Added all Document related routes and logic (elastic#83324)
  [Alerting UI] Fix console error when setting connector params (elastic#83333)
  [Discover] Allow custom name for fields via index pattern field management (elastic#70039)
  [Uptime] Fix monitor list down histogram (elastic#83411)
  remove headers timeout hack, rely on nodejs timeouts (elastic#83419)
  [ML] Update console autocomplete for ML data frame evaluate API (elastic#83151)
  [Lens] Color in dimension trigger (elastic#76871)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Lens release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] Show chosen metric color in dimension trigger
6 participants