-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
De-angularize vis tooltips #54954
Conversation
Add `kbn_vislib_vis_types` to sass lint Co-Authored-By: Caroline Horn <[email protected]>
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.
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'; |
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.
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?
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.
Ya I wasn't sure what to do with these either.
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.
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 ?
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.
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.
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.
Joe I'll update the types and components is another pr
id="visTypeVislib.vislib.tooltip.valueLabel" | ||
defaultMessage="value" | ||
/> | ||
<th scope="col">{/* {metricCol.label} */}</th> |
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.
Why is this commented out? Seems like this is used.
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.
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
?
kibana/src/legacy/ui/public/vis/components/tooltip/_hierarchical_tooltip_formatter.js
Lines 29 to 64 in 56482ab
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(' ', 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; | |
}; | |
}; | |
} |
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.
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) { |
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 we do a proper check here?
let percent = undefined;
// ...
if (percent !== null) {
This makes me nervous :)
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.
Same -- I was just replicating the existing logic. I'll update it.
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.
Sass changes LGTM
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* 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
Summary
vis/tooltip
tooltip
fromvis
tovis_type_vislib
Fix existing tooltip display
0
value issue (38a0fd7)Before
Notice the
Flight delay minutes
value is0
and therefore is filtered out.After
Flight delay minutes
value of0
now shows in tooltipChecklist
For maintainers