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

Add "Sum of series in legend" option #7970

Closed
wants to merge 14 commits into from
Closed

Conversation

ppisljar
Copy link
Member

@ppisljar ppisljar commented Aug 10, 2016

fixes #4599 - Add "Sum of series in legend" option

  • counts can be enabled by checking Show Sum of Series option

legendcount

@ycombinator
Copy link
Contributor

@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 => {
Copy link
Contributor

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.

@ycombinator
Copy link
Contributor

Functionality looks great. I added a few comments about the code.

@ycombinator
Copy link
Contributor

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,
Copy link
Contributor

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?

Copy link
Contributor

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

@ycombinator ycombinator Aug 10, 2016

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.

@ycombinator
Copy link
Contributor

LGTM! Nice work @ppisljar!

On to the next reviewer...

@ycombinator ycombinator removed their assignment Aug 10, 2016
@spalger
Copy link
Contributor

spalger commented Aug 10, 2016

I'm able to choose the "Show Legend Counts" option on the Line chart

image

@spalger
Copy link
Contributor

spalger commented Aug 10, 2016

Why does the legend count work with the bar chart but not the line and area charts?

@spalger spalger assigned ppisljar and unassigned spalger Aug 10, 2016
@ppisljar
Copy link
Member Author

@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.

@spalger
Copy link
Contributor

spalger commented Aug 11, 2016

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.

@spalger
Copy link
Contributor

spalger commented Aug 11, 2016

Sorry Peter, dug into this a bit more and I'm afraid this will need to change approach a bit.

two issues:

  1. the value in the legend isn't using a field formatter
  2. the value isn't a count unless the first metric aggregation is a count

possible solutions:

  1. Always show count, not the sum of the series values, by reading the doc_count property of the agg response
  2. Move the option into each aggregation, change it to "Summarize in the legend" or something, and allow some/all of the aggregations to be summarized (ie. average summerizes differently than count)
  3. Only show the summary if their is a count aggregation in the metric list

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.

@spalger
Copy link
Contributor

spalger commented Aug 11, 2016

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?

@ppisljar
Copy link
Member Author

ppisljar commented Aug 12, 2016

ok after your live session this is much clearer

@tbragin
Copy link
Contributor

tbragin commented Sep 12, 2016

@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:

  • Option to provide data labels exists in Options even if it has no impact on the selected aggregation (e.g. Bar vis, Metric: Average, Bucket: Date Histogram).
  • I'm not sure why we call the option "Show Sum of Series" even when we're dealing with other data summaries. Can we just call it "Show data label in legend"?
  • Label seems to be missing completely, when bar diagram has no terms (see screenshot).
  • I like the way the Sum aggregation is treated across visualizations, it seems consistent. But I'm not really sure how we are doing the "unique count" labels in date histograms and why the resulting counts exceed the total numbers of unique users in the Metric vis, looking side-by-side at results from the Pie chart, date histogram, and metric vis. I think simply adding up unique counts across buckets is misleading.

screen shot 2016-09-12 at 2 12 37 pm

screen shot 2016-09-12 at 2 50 15 pm

@ppisljar ppisljar added v5.1.0 and removed v5.0.0 labels Oct 3, 2016
@epixa epixa added the discuss label Oct 8, 2016
@spalger
Copy link
Contributor

spalger commented Oct 17, 2016

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.)

@spalger spalger removed the discuss label Oct 17, 2016
@spalger spalger added v6.0.0 and removed review labels Oct 24, 2016
@spalger spalger removed their assignment Oct 27, 2016
@tbragin tbragin added the Feature:Visualizations Generic visualization features (in case no more specific feature label is available) label Nov 12, 2016
@ppisljar ppisljar removed the v5.1.0 label Nov 14, 2016
@thomasneirynck
Copy link
Contributor

@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.

Ikuni17 pushed a commit that referenced this pull request Aug 31, 2024
`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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Visualizations Generic visualization features (in case no more specific feature label is available) stalled v6.0.0-rc1 v6.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optional data labels on charts or legends
7 participants