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

De-angularize vis tooltips #54954

Merged
merged 50 commits into from
Jan 21, 2020
Merged

Conversation

nickofthyme
Copy link
Contributor

@nickofthyme nickofthyme commented Jan 15, 2020

Summary

  • Remove angular from vis/tooltip
  • Move tooltip from vis to vis_type_vislib
  • Fix errors from vislib and tests due to changes

Fix existing tooltip display 0 value issue (38a0fd7)

Before

Notice the Flight delay minutes value is 0 and therefore is filtered out.

Screen Recording 2020-01-17 at 01 17 PM

After

Flight delay minutes value of 0 now shows in tooltip

Screen Recording 2020-01-17 at 01 16 PM

Checklist

For maintainers

nickofthyme and others added 30 commits December 18, 2019 14:03
Add `kbn_vislib_vis_types` to sass lint

Co-Authored-By: Caroline Horn <[email protected]>
@nickofthyme nickofthyme requested a review from a team January 16, 2020 02:56
@nickofthyme nickofthyme marked this pull request as ready for review January 16, 2020 02:57
@nickofthyme nickofthyme requested a review from a team as a code owner January 16, 2020 02:57
Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Looks good go to me once green, left a few comments to look into. I didn't look into the test failures, but seems like something isn't mocked correctly there.

@@ -22,7 +22,7 @@ import { EuiPanel } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import { VisOptionsProps } from 'ui/vis/editors/default';
import { RangeOption, SwitchOption } from '../../vis_type_vislib/public/components';
import { RangeOption, SwitchOption } from '../../vis_type_vislib/public';
Copy link
Contributor

Choose a reason for hiding this comment

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

Just realized these visualization types depend on vislib (at least for static code) - we should put them in a central place so visualizations don't depend on each other (not necessarily in this PR though). I probably missed this in the vislib shimming PR.

I saw RangeOption, SwitchOption, ColorModes, Labels, Styles and NumberInputOption.

Looks like RangeOption, SwitchOption and NumberInputOption are a thin layer on top of eui form components. @streamich Would they fit into kibana_react? They are not really chart specific.

ColorModes, Labels and Styles are types - I would say they don't really have to be shared, but if they are shared I think they should go into visualizations @ppisljar what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya I wasn't sure what to do with these either.

Copy link
Member

Choose a reason for hiding this comment

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

ColorModes is a setting specific to metric visualization ... not sure about Labels and Styles, but i am guessing its also settings limited to just a few visualizations ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's duplicate the types and make them internal to the plugins they are used in.

For the components it seems like they do not really fit into kibana_react - let's make them a part of the new "charts" plugin for now (doesn't have to happen in this PR) - it's a bit of a different beast, but these forms are also useful for all chart types to make the forms consistent, so it's the best home for them now - they are slightly too complex to just duplicate them IMHO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Joe I'll update the types and components is another pr

id="visTypeVislib.vislib.tooltip.valueLabel"
defaultMessage="value"
/>
<th scope="col">{/* {metricCol.label} */}</th>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this commented out? Seems like this is used.

Copy link
Contributor Author

@nickofthyme nickofthyme Jan 17, 2020

Choose a reason for hiding this comment

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

Yeah I couldn't tell where it was coming from. It was in the angular template but there was no metricCol property that was set on the $scope. Nor was there any other reference to metricCol in all of kibana. Is it possible to be coming from $rootScope?

export function HierarchicalTooltipFormatterProvider($rootScope, $compile, $sce) {
const $tooltip = $(template);
const $tooltipScope = $rootScope.$new();
$compile($tooltip)($tooltipScope);
return function(metricFieldFormatter) {
return function(event) {
const datum = event.datum;
// Collect the current leaf and parents into an array of values
$tooltipScope.rows = collectBranch(datum);
// Map those values to what the tooltipSource.rows format.
_.forEachRight($tooltipScope.rows, function(row) {
row.spacer = $sce.trustAsHtml(_.repeat('&nbsp;', row.depth));
let percent;
if (row.item.percentOfGroup != null) {
percent = row.item.percentOfGroup;
}
row.metric = metricFieldFormatter ? metricFieldFormatter.convert(row.metric) : row.metric;
if (percent != null) {
row.metric += ' (' + numeral(percent).format('0.[00]%') + ')';
}
return row;
});
$tooltipScope.$apply();
return $tooltip[0].outerHTML;
};
};
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like a leftover to me - it should be safe to remove it completely


row.metric = metricFieldFormatter ? metricFieldFormatter.convert(row.metric) : row.metric;

if (percent != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we do a proper check here?

      let percent = undefined;
// ...
if (percent !== null) {

This makes me nervous :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same -- I was just replicating the existing logic. I'll update it.

Copy link
Contributor

@andreadelrio andreadelrio left a comment

Choose a reason for hiding this comment

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

Sass changes LGTM

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@nickofthyme nickofthyme merged commit ce2930e into elastic:master Jan 21, 2020
@nickofthyme nickofthyme deleted the kpm/de-ang-tooltips branch January 21, 2020 16:47
nickofthyme added a commit that referenced this pull request Jan 21, 2020
* Remove angular dependencey from vis/tooltip
* Move tooltip logic into vislib
* Remove and fix all ngMock refs in vislib tests
* Add numeral to renovate config
* Add vis_type_vislib to codeowners
* Move vis_legend into vislib and fix errors
* vis_type_vislib/public imports to be only top-level
@nickofthyme nickofthyme added release_note:breaking release_note:skip Skip the PR/issue when compiling release notes and removed release_note:skip Skip the PR/issue when compiling release notes release_note:breaking labels Jan 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:New Platform Feature:Vislib Vislib chart implementation release_note:skip Skip the PR/issue when compiling release notes v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants