-
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
Add "Sum of series in legend" option #7970
Conversation
@ppisljar Which Kibana version is this PR targeting? Can you add the corresponding labels? Thanks! |
@@ -66,6 +66,18 @@ uiModules.get('kibana') | |||
return filters.length; | |||
}; | |||
|
|||
$scope.showLabelCount = legendData => { |
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.
Consider renaming this to showLegendCount
for consistency with vis.params.addLegendCount
.
Functionality looks great. I added a few comments about the code. |
Also, I suggest getting a 2nd reviewer for this PR who is familiar with the visualization code (Spencer?) as I'm not too familiar with it myself at the moment. |
@@ -29,6 +29,7 @@ export default function HistogramVisType(Private) { | |||
modes: ['stacked', 'percentage', 'grouped'], | |||
editor: histogramTemplate | |||
}, | |||
isLegendCountSupported: true, |
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.
While this is definitely the right file for this line to go in, I'm not 100% sure this is the right place in the object being passed to the VislibVisType
constructor. Maybe isLegendCountSupported
needs to go in params
or params.defaults
? It seems a bit hanging out on its own when other parameters are either in params
or in params.defaults
. Maybe try out either of those places and also check with Spencer as a 2nd reviewer?
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.
In fact, I just tested this PR and I'm pretty sure this is not the right place for this parameter. $scope.vis.type.isLegendCountSupported
is evaluating to undefined
.
@@ -68,7 +68,7 @@ uiModules.get('kibana') | |||
|
|||
$scope.showLegendCount = legendData => { | |||
if (!$scope.vis.params.addLegendCount) return false; | |||
if (!$scope.vis.type.isLegendCountSupported) return false; | |||
if (!$scope.vis.type.params.isLegendCountSupported) return false; | |||
return $scope.getLegendCount(legendData); |
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.
Based on the name of this function (showLegendCount
) and its usage, I expect it to return a boolean value. So consider changing the final return statement to return !!$scope.getLegendCount(legendData);
or return Boolean($scope.getLegendCount(legendData));
as $scope.getLegendCount
itself does not return a boolean value.
LGTM! Nice work @ppisljar! On to the next reviewer... |
Why does the legend count work with the bar chart but not the line and area charts? |
@spalger thats what people were mentioning in the issue ticket. Do you think it would be useful there as well ? i added the option to line and area charts as well. |
I imagine it could be useful everywhere, but I don't have any reason why. I just want to make sure that the option is only available when the visualization supports it. |
Sorry Peter, dug into this a bit more and I'm afraid this will need to change approach a bit. two issues:
possible solutions:
Either way I think we change this to have Kibana send a different legend label label to the vislib, rather than the vislib try to offer this setting. That way, Kibana can use it's awareness of the aggregation types and field formatters to produce a high quality series summaries. |
I suppose another options might be to change the option to "show sum of each series in legend" and just apply the default number formatter... That might be good enough to ship this feature. @epixa thoughts? |
ok after your live session this is much clearer |
@spalger Thanks for tagging me! @ppisljar I'm super excited that you are working on this, I think having this feature will really help folks displaying Kibana dashboards on overhead projectors and distributing them as reports, where user cannot mouse-over to see the counts. In regards to the things @spalger noted in his Aug 11 comment, I do agree there is room for improvement here. I went head and checked out the current PR in @ppisljar's branch and compared it against Kibana 3.1.3, to dig into specifics. Interestingly, Kibana 3 has followed approach (1) in @spalger's list and chose to show only document counts, even when the histogram displays max or total. We may or may not agree with this approach for Kibana 4/5, but it's interesting to note that anything above this is an improvement, or a change in functionality, depending on your perspective. So while I personally find it confusing to look at document counts when the visualization presents something else, and as a result find option (2) attractive conceptually, I wonder why @rashidkpc chose not to go down that path in Kibana 3. Conceptually it should be possible to apply the same logic the Metric vis does to arrive at a single value for all of these aggregations, with the caveat of needing to filter properly for a specific term if required. Is it too complex / computationally expensive to arrive at labels that make sense for all scenarios? If option (2) ends up being prohibitively complex in the near term, given the Kibana 3 history, if we took the more simple approach suggested in (1) in the first phase of this PR, I'd be ok with it. Though I hope we would find a better way to indicate in the UI what the counts mean, because it's not clear in Kibana 3. I'd also be ok with doing (3), starting with legend data label support for just Counts and Sum, for instance, as long as the Visualize Options UI is really clear about when the data label option is available and not (see below). The value-add of showing counts in the UI for most common scenarios where they make sense would outweigh lack of support for all aggregations for me personally. Looking at the current state of @ppisljar's PR, it appears that he's sort of headed down the path of (2), with special support for data labels when Sum and Unique Count aggregations are in play, adding up values in all buckets. Some comments:
|
We talked about this collectively and decided that option 2 would be ideal, but option 1 also works as long as it is opt-in, and labels the count with a unit of some sort ("XYZ docs", or "XYZ hits", etc.) |
@ppisljar I'm going to close this, since there's been little movement on this. Do reopen if you think it's worth continuing from here again. |
`v95.7.0` ⏩ `v95.9.0` > [!CAUTION] > This PR contains the final set of Emotion conversions for all EuiForm components. > If your plugin contains any custom CSS/styling to **EuiFormRow, EuiFormControlLayout, EuiCheckbox, EuiRadio, or EuiSwitch**,⚠️ make sure to QA your UI to ensure no visual regressions have occurred!⚠️ --- ## [`v95.9.0`](https://github.com/elastic/eui/releases/v95.9.0) - Updated `EuiSearchBar`'s optional `box.schema` prop with a new `recognizedFields` configuration. This allows specifying the phrases that will be parsed as field clauses ([#7960](elastic/eui#7960)) - Updated `EuiIcon` with a new `tokenSemanticText` glyph ([#7971](elastic/eui#7971)) - Added support for TypeScript 5 ([#7980](elastic/eui#7980)) **Bug fixes** - Fixed `EuiSelectableTemplateSitewide` styles when used within a dark-themed `EuiHeader` ([#7977](elastic/eui#7977)) ## [`v95.8.0`](https://github.com/elastic/eui/releases/v95.8.0) - Updated `EuiHeaderLinks`'s mobile menu to set a slight popover padding by default ([#7961](elastic/eui#7961)) - This can be overridden via `popoverProps.panelPaddingSize` if needed. - Updated `EuiHeaderLink` to default to a size of `s` (down from `m`) ([#7961](elastic/eui#7961)) **Accessibility** - Updated the `aria-label` attribute for the `EuiFieldSearch` clear button ([#7970](elastic/eui#7970)) **Bug fixes** - Fixed a visual bug with `<EuiDualRange showInput="inputWithPopover" />` form controls ([#7957](elastic/eui#7957)) **Deprecations** - Deprecated `EuiFormRow`'s `columnCompressedSwitch` display prop. Use `columnCompressed` instead, which will automatically account for child `EuiSwitch`es ([#7968](elastic/eui#7968)) - Deprecated `EuiFormRow`'s `rowCompressed` display prop. Use `row` instead for vertical forms, or `centerCompressed` for inline forms ([#7968](elastic/eui#7968)) - (Styling) Updated `EuiFormRow`'s `hasEmptySpaceLabel` prop to no longer attempt to automatically align its content to a vertical center. Use the `display="center"` prop for that instead ([#7968](elastic/eui#7968)) **CSS-in-JS conversions** - Converted `EuiFormControlLayout` to Emotion ([#7954](elastic/eui#7954)) - Removed `.euiFormControlLayout--*icons` classNames and `--eui-form-control-layout-icons-padding` CSS var. Use `--euiFormControlRightIconsCount` or `--euiFormControlLeftIconsCount` instead - Converted `EuiFormLayoutDelimited` to Emotion ([#7957](elastic/eui#7957)) - Fixed `cloneElementWithCss` throwing an error when used multiple times without a `key` prop ([#7957](elastic/eui#7957)) - Updated `cloneElementWithCss` utility to support a third argument that allows prepending vs. appending the cloned Emotion css className ([#7957](elastic/eui#7957)) - Removed `@euiFormControlLayoutClearIcon` Sass mixin ([#7959](elastic/eui#7959)) - Converted `EuiDescribedFormGroup` to Emotion ([#7964](elastic/eui#7964)) - Converted `EuiForm`, `EuiFormHelpText`, and `EuiFormErrorText` to Emotion ([#7966](elastic/eui#7966)) - Converted `EuiFormLabel` and `EuiFormLegend` to Emotion; Removed `@euiFormLabel` mixin ([#7967](elastic/eui#7967)) - Converted `EuiFormRow` to Emotion ([#7968](elastic/eui#7968)) - Converted `EuiCheckbox` to Emotion ([#7969](elastic/eui#7969)) - Converted `EuiRadio` to Emotion ([#7969](elastic/eui#7969)) - Converted `EuiSwitch` to Emotion ([#7969](elastic/eui#7969)) - Removed the following Sass variables: ([#7969](elastic/eui#7969)) - `$euiFormCustomControlDisabledIconColor` - `$euiFormCustomControlBorderColor` - `$euiRadioSize` - `$euiCheckBoxSize` - `$euiCheckboxBorderRadius` - `$euiSwitchHeight` (and compressed/mini variants) - `$euiSwitchWidth` (and compressed/mini variants) - `$euiSwitchThumbSize` (and compressed/mini variants) - `$euiSwitchIconHeight` - `$euiSwitchOffColor` - Removed the following Sass mixins: ([#7969](elastic/eui#7969)) - `euiIconBackground` - `euiCustomControl` - `euiCustomControlSelected` - `euiCustomControlDisabled` - `euiCustomControlFocused` --------- Co-authored-by: Marta Bondyra <4283304+mbondyra@users.noreply.github.com>
fixes #4599 - Add "Sum of series in legend" option