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

embed visualization in tooltip #14102

Closed
wants to merge 31 commits into from
Closed

embed visualization in tooltip #14102

wants to merge 31 commits into from

Conversation

nreese
Copy link
Contributor

@nreese nreese commented Sep 21, 2017

There is an open issue about tooltip aggregations. I thought it might be interesting to explore solving this issue by allowing the tooltip to contain a visualization that is further filtered by the bucket key(s) of the moused over element.

The current implementation allows for embedding visualizations in tooltips for Pie and Vertical Bar visualizations.

This is a very rough implementation to see if such a solution is possible and gauge the level of effort for a fully fleshed out solution and get feedback and determine if this is an idea worth pursuing.

tooltip

@elastic/kibana-visualizations @elastic/kibana-sharing What are your thoughts? Should more effort be put into this? Does this complement drill down links?

@thomasneirynck thomasneirynck added the Feature:Visualizations Generic visualization features (in case no more specific feature label is available) label Sep 22, 2017
@rashidkpc
Copy link
Contributor

Hah, that's super cool

@ppisljar
Copy link
Member

amazing!

@stacey-gammon
Copy link
Contributor

Really cool!

Maybe we can get a customer who was interested in this feature to take a look and give some feedback? cc @alexfrancoeur

@nreese - how much effort do you think it would take to push it across the finish line? Is it something you see being done in addition to panel groupings, or would it take the place of that feature for 6.1?

I wonder if people will end up wanting to interact with the visualization inside the tooltip.

@trevan
Copy link
Contributor

trevan commented Sep 25, 2017

I like the idea. You'll have to handle a "loading icon" or something because some visualizations can take minutes. It would be cool if if you could specify a list of visualizations you want and when you interact with the chart in someway (click?), you get the list in a context menu that lets you pick which one you want. Kind of like an in-page drill down.

@nreese
Copy link
Contributor Author

nreese commented Sep 25, 2017

@stacey-gammon I guess it would take about a week to polish things up for a review

@nreese
Copy link
Contributor Author

nreese commented Sep 25, 2017

@thomasneirynck @ppisljar In the visualize editor - should tooltip configuration be its own editor tab? I think it should be since each visualization has unique options and it would be best if configuring the tooltip was identical across all visualizations. The problem is that for some visualizations, this adds a fourth tab and now the tab headers do not fit in the provided space. What do you recommend?

Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

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

This is genuinely a great contribution 🤤

Since this is a POC, not much feedback on the code now. Also because #14146 could be something that will remove some of the boilerplate here.

But a few initial comments, in no particular order:

  • To your comment, I don't think this should be a separate tab. Rather, we could instead add this to the vislib_basic_options.html directive. It's somewhat of a goofy combination of tooltip-checkbox and legend position now, but we can format that a little better and just have two new sub-sections. Legend and Tooltip.
  • Embedding maps in the tooltip isn't very useful now, because we don't have autofit on the data. There's even a ticket for this Coordinate Maps: auto fit data bounds #2054, yikes!
  • as discussed earlier, for the map itself to use this tooltip, it would have to use Kibana's tooltip not leaflet one. That doesn't need to be part of this PR imho, we can do that separately.
  • as for @trevan's embed visualization in tooltip #14102. It's an intriguing idea to make the visualization itself toggle-able on the fly inside the toolip. But I think this is a good scope already. Multi-visualization is something we can explore later imho
  • the preset width/height is a tough one. My initial gut feeling would be to invert this, that every visualization determines the best width/height for display in tooltip. But I can see the value of having it be configurable too. Getting this in the hands of end-users will probably determine this better.
  • the reuse of the popup dom-element and vis make this actually quite snappy when hovering over chart-elements. For example, the tag-cloud doesn't completely become a pinball-machine when hovering around. nonetheless, animated visualizations, like tagcloud, are probably not the best to embed. I'd consider for example filtering out some visualizations, like tag-cloud.
  • I ran into a few issues with jitter. e.g. tooltip is hovering, and then clicking a chart-element to send a filter makes the tooltip flash.
  • cue the inception jokes, but the main visualization itself should probably be removed from the list of tooltip visualizations.

@alexfrancoeur
Copy link

alexfrancoeur commented Sep 26, 2017

What a nice surprise! What else do you have up your sleeve @nreese!?! This is a great concept. All in all, I think it's a good idea and worth exploring further but we'd need to do a lot of cleaning up. Thoughts and feedback below (in no particular order).

  • I understand this is a POC but as with anything in Kibana, we'll need to see how this scales. How does this tooltip perform when there are thousands or millions of data points in a single bucket? @trevan brought up a good point, some visualizations can take longer to load. I see the loading indicator is used at the top of Kibana but it's not specific to the tool tip visualization.
  • Should we limit to visualizations with the same index pattern? Or do we allow for the same freedom of filtering that dashboards offer? I see benefits for either approach, but the latter may be more powerful.
  • I agree that this could again conflict with drill downs to an extent. But we wouldn't be supporting external URL's or dashboard, so the scope is much smaller. But is it what users are looking for?
  • I imagine we'll begin to see users attempt to use this to see raw data points. This would be possible with a data table and top hits. However, as it's a tooltip we only have so much real estate available. We'll need to figure out how to best handle tables with multiple pages, it may even be easiest to say something along the lines of "showing first X rows". For this same use case, users may be looking to see saved searches on hover. This is another argument for custom drilldowns.
  • It looks like there are some limits to the size of the tool tip but we allow you to modify the width and height of a visualization past that. We'd likely have to limit the height and width inputs.

screen shot 2017-09-26 at 7 23 58 am

  • I seem to be getting a few courier fetch no response for request errors when loading the visualization tool tip

screen shot 2017-09-26 at 7 29 28 am

  • I think we'll run into a number of issues with the size of visualizations and the way they're handled. For example, I imagine we'll see a lot of "labels cannot be shown" issues. Tag clouds will most certainly run into this given the amount of space we're working with. Also, do we have any control over the padding?

screen shot 2017-09-26 at 7 46 24 am

  • @thomasneirynck @ppisljar This would be another argument for data labels. I have no idea what the values are in the pie chart on hover

screen shot 2017-09-26 at 7 41 44 am

  • We'd have to limit by visualization type as well, input control wouldn't make sense here.
  • Not sure if this is possible, but can we automatically place a visualization in dark mode if it's in the tool tip? Black on white doesn't look so good here.

screen shot 2017-09-26 at 7 28 08 am

@nreese
Copy link
Contributor Author

nreese commented Sep 28, 2017

@thomasneirynck

  • remove some boiler plate: PR 14146 will help remove the boiler for uiState. Unfortunately, this functionality also requires access to the savedObject's searchSource, requestHandler, and responseHandler - which the PR does not provide access to.
  • avoid separate tab, update vislibBasicOptions directive: Turns out that there were three instances were legend and show tooltip inputs were defined. I updated the vislibBasicOptions directive to include the new tooltip inputs. I updated all visualizations to use the vislibBasicOptions directive. The pie and tile_map options tabs did not use the new kui styling. Their styling had to be updated so they could use a vislibBasicOptions directive with the kui styling.
  • Embedding maps in the tooltip isn't very useful now: Filter out visualizations types that don't make sense such as tile_map and tag cloud.
  • cue the inception jokes: Embedded visualization in tooltip will force-set addTooltip to false so it will be impossible to open a tooltip of a tooltip of a tooltip...

@nreese
Copy link
Contributor Author

nreese commented Sep 28, 2017

@alexfrancoeur

  • How does this scale: The embedded tooltip just makes use of regular ES aggregations so scaling should not be an issue. The agg request is now on a debounce so quickly moving the mouse across a bar chart will only fire a single _msearch for the last bar and not an _msearch for each bar. The tooltip visualization gets loaded asynchronously so it won't block the UI. If the agg request takes a really long time for a particular dataset then maybe embedded tooltips are not appropriate for that use case and the standard tooltip should be used.
  • Should we limit to visualizations with the same index pattern: I would recommend no. Let the users decide what is best for their needs.
  • raw data points: Great enhancement that should be added after this PR to limit the initial scope.
  • limits to the size of the tool tip: Good find. The tooltip is only allowed to be 40% of screen size. I added checks to ensure that the proper value is getting used. On the configuration size - you should be able to specify a large size and then have the dimensions get scaled down accordingly to how each user's window is sized.
  • courier fetch no response for request errors: Resolved with debounce on mouseenter event to avoid creating so many aggregation requests.
  • automatically place a visualization in dark mode: Good idea - implemented
  • limit by visualization type: Input control and tag cloud visualizations now get filtered out of selection list.

@nreese nreese changed the title [WIP] embed visualization in tooltip embed visualization in tooltip Sep 28, 2017
@nreese
Copy link
Contributor Author

nreese commented Sep 28, 2017

jenkins, test this

1 similar comment
@nreese
Copy link
Contributor Author

nreese commented Sep 29, 2017

jenkins, test this

Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

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

🍷

Some minor comments mostly. Code style is for your consideration, but I would look into changing the legend-style to make a little less wide and also prevent visualizations from embedding themselves.

do {
const resp = await props.savedObjectsClient.find(findOptions);
const optionsFromPage = resp.savedObjects
.filter((savedObject) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would also filter out the visualization itself.

This only occurs if the visualization is already saved, but it shows up in the list. It doesn't really add anything.

e.g.:
image

</div>

<tooltip-options
Copy link
Contributor

Choose a reason for hiding this comment

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

imho, I'd be in favor of putting a subheader above all the tooltip options and legend position. Right now, the section kinds of blends in with the rest:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tooltip settings are now under the collapsible header Tooltip Settings

import React from 'react';
import Select from 'react-select';

const visTypeExcludeList = [
Copy link
Contributor

Choose a reason for hiding this comment

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

what are your thoughts on flipping this? Every vis must set a property isEmbeddableInTooltip to true, iso having this exclusion list. The biggest advantage of that approach is that new visualization (e.g. 3rd party plugins) won't be embeddable by default. I

height: getHeight()
});
$popup.empty();
$popup.append($visEl);
Copy link
Contributor

Choose a reason for hiding this comment

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

the default legend-width (https://github.com/thomasneirynck/kibana/blob/e91c99f2b236339c0f12819974a9ce9d9f18503f/src/ui/public/vislib/styles/_legend.less#L44-L44) makes the legend look too wide with wasted space to the right when embedded in the tooltip.

Consider overriding that rule with width: auto when inside a tooltip.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

auto will not work because then long labels will make the legend cover the entire tooltip. I shrank the value to 75px for legends embedded in tooltips. Are you ok with that solution?

return from.find(handler => handler.name === name).handler;
}

return function (parentVis) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the expansion of this type (embeddedTooltipFormatter/hierarchicalTooltipFormatter), but the implementation is very Crockfordian. imho, given we expand on it, I'd consider using the simple class syntax.

so something like:

class VisualizationTooltipFormatter {
   constructor(parentVis) {
   }
  
   formatTooltipContents(event) {
   }
  
   cleanUp(){
  }
   
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed, I opened an issue to resolve this latter

#14224

* Get content container for Tooltip.
* Tooltips with the same id share a content container.
*/
Tooltip.prototype.getContentContainer = function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I'm missing something, but do we need a new container for each tooltip type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The old implementation just concatenated a bunch of HTML strings together. Each mousemove event destroyed the existing HTML and generated new HTML.

This is no longer possible since the HTML can now be generated by asynchronous calls. Putting each tooltip in its own container helped make the implementation more straightforward.

.then(requestHandlerResponse => {
return responseHandler(vis, requestHandlerResponse);
})
.then(resp => {
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens if formatter#cleanUp is called before this handler is executed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

formatter#cleanUp is fired when there is a mouseleave event. The $popup is also removed from the DOM on mouseleave. Therefore - the if statement if (localFetchTimestamp === fetchTimestamp && $popup && $popup.length > 0) will return false and the response will be ignored.

The responseHandler is not effected by cleanUp and can process the response. The above mentioned logic will handle everything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cleanUp now sets fetchTimestamp to expired so regardless if $popup has been removed or not, the if block will return false if cleanUp is called before the response is returned

self.contentContainer.empty();
} else {
const events = self.events ? self.events.eventResponse(d, i) : d;
self.contentContainer.html(self.formatter(events));
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd consider changing this self.formatter method instead of returning a html-string, to having it return a DOM-node, or append to a DOM-node.

This will avoid having to create dynamically generate IDs and then querying the DOM for the container-node because you can just keep a reference to the node directly. (see e.g. the work-around of creating the executionId just so we can find the node in embeddedTooltipFormatter).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed, this is a good idea but should be done outside of the scope of this PR

@nreese
Copy link
Contributor Author

nreese commented Sep 29, 2017

@thomasneirynck I should have addressed all concerns highlighted by your review

@nreese
Copy link
Contributor Author

nreese commented Oct 2, 2017

jenkins, test this

1 similar comment
@nreese
Copy link
Contributor Author

nreese commented Oct 2, 2017

jenkins, test this

@alexfrancoeur
Copy link

@nreese just checked out the latest and had some additional feedback. These comments are not in any prioritized order.

We seem to be missing Timelion and TSVB visualization types. Neither visualization types show up in the drop down. Given that they are available when creating a new visualization and are timeseries specific, as a user I'd expect them to be viable options. Is there a technical limitation here?

Can we get an official loading indicator from design? I see Loading data... but believe we can provide a better experience here.

You can't interact with the legend at all. Any way to hide the collapsible button or is it more trouble than it's worth?
screen shot 2017-10-02 at 11 56 20 am

Errors are not descriptive enough - what's the min/max value for a tooltip? We are also only visualization the error with color. We'll need to provide an icon and/or text for accessibility purposes.

screen shot 2017-10-02 at 12 05 55 pm

screen shot 2017-10-02 at 12 06 14 pm

Expanding / Collapsing Tooltip options
On mouseover this doesn't look clickable in comparison to other collapsable components in the configuration
oct-02-2017 11-47-53

This option is not keyboard accessible, tabbing skips right over it.
oct-02-2017 11-58-02

The tool tip visualization does not seem to adhere to user defined intervals. I created a "scatter chart" with second interval expecting to hover and see more data points than the aggregation. However, the interval seems to be stuck with "auto" and is only providing one data point. Current behavior:
screen shot 2017-10-02 at 12 28 32 pm

Expected number of data points:
screen shot 2017-10-02 at 12 28 52 pm

There still seems to be a lot of wasted space with some visualizations
screen shot 2017-10-02 at 12 06 47 pm

Should we provide a warning for the max number of rows either when creating the visualization or on hover? Users should understand that they aren't seeing the full table if a table is used.
screen shot 2017-10-02 at 12 38 06 pm

We also seem to be cutting rows off, any way we can dynamically size as we would a chart?
screen shot 2017-10-02 at 12 40 09 pm

The X on selection seems to overlap the name of a visualization
screen shot 2017-10-02 at 12 41 12 pm

This is a bit of an after thought, but it's possible users may want to see the metric and a visualization. Thoughts?

@nreese
Copy link
Contributor Author

nreese commented Oct 2, 2017

@stacey-gammon @thomasneirynck @alexfrancoeur Should the user even be allowed to set the embedded tooltip size? Maybe the size should just always be 40% of the window size? What do you think?

@thomasneirynck
Copy link
Contributor

@nreese in hindsight, yes, I agree that we can start with defaulting %40. If people start asking for more control, we can give that control to them later. But don't feel strongly about this, so I'll agree with majority.

@alexfrancoeur imho I would hold off on showing both metrics and visualizations. could be introduced if people ask for it.

@alexfrancoeur
Copy link

I agree with @thomasneirynck, I'm comfortable with providing defaults and less options in the first iteration.

…oid refactor since same formatter instance is used even though new instance of tooltip is created
@rcrezende
Copy link

rcrezende commented Oct 25, 2017

This is awesome.
I'd ask to have an option to pin the popup so we can interact with it, because today the popup will disappear if you try to hover the popup visualization. Also, that would allow to recursively open tooltips. That would bring Kibana to a next level for a"drill-down" experience by keeping everything in-place and not losing context for the drill-down path.

@alepuccetti
Copy link

Having embedded visualizations in the tooltip is an awesome feature for business analytics dashboard. we using it on maps, but have it in any visualization would be even better.

+1

@stacey-gammon stacey-gammon removed their request for review March 8, 2018 17:05
@nreese nreese closed this Mar 29, 2018
@rcrezende
Copy link

@nreese any plan to bring this back?

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) release_note:enhancement stalled v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants