Skip to content

[timelion] highlight series on legend mouseover - #15229

Merged
nreese merged 4 commits into
elastic:masterfrom
nreese:highlight_series_on_mouseover
Dec 13, 2017
Merged

nreese merged 4 commits into
elastic:masterfrom
nreese:highlight_series_on_mouseover

Conversation

@nreese

@nreese nreese commented Nov 29, 2017

Copy link
Copy Markdown
Contributor

fixes #9845

highlight a series (by dimming the others) when hovering over the legend.... the way other Kibana visualizations work.

highlight

@nreese nreese added Feature:Timelion Timelion app and visualization Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:enhancement v6.1.0 v7.0.0 labels Nov 29, 2017
@nreese nreese removed the v6.1.0 label Nov 30, 2017

@thomasneirynck thomasneirynck left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I like the improvement, since it is aligning functionality, but also a little ambivalent, not in the context of this single change, but the direction we want to go with Kibana-charts as a whole.

imo, this issue is a good candidate that illustrates the problem with having different line-charts implementations across the product.

I think we really need to have a single XY-chart implementation, that wraps the common functionality (brushing, highlighting, click-handling, ...) in one place. We've talked about this a couple times, most recently in the context of trying to bring TSVB out of experimental.

The above is tentative now, and we're still trying to figure out space for it, but I do see us progressing in this direction, hopefully sooner than later.

So if we do this enhancement for Timelion, there's a good chance we'll end up replace it.

@timroes we talked about this earlier too. What do you think, is it worthwhile expanding the chart-capabilities if there is a change we'll end up replacing this in the (undetermined) future

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

good rename :)

@thomasneirynck thomasneirynck left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Really neat improvement, users will like it!

I added some comments. Maybe I'm missing something obvious, but I'm thinking we could simplify the coloring in the highlighting-handlers a little. Otherwise lgtm, but wanted your thoughts on it first.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this related?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes. Without the <br>, then the legend jumps (the x-axis value disappears) when you enter it. The jumping makes the mouseover target not very user friendly. By putting a <br> into the caption when empty, then the legend is always the same height and does not move around on the user

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could you add a little explanation like that in the code?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

seems somewhat arbitrary. I'd use null instead.

@thomasneirynck thomasneirynck Dec 4, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This algorithm does a clean sweep with restoreColors, and then reapplies the colors. It uses a temp-property, _originalColor on the series object to keep track of older state. Is there a way we can simplify this, without the need for sweeping past the data twice and having to maintain that temp-property in-sync?

Would this work, using a Map? Maybe I'm forgetting something obvious.

patch.txt

This is the relevant part:

        const originalColorMap = new Map();
        $scope.chart.forEach((series, seriesIndex) => {
          if (!series.color) {
            const colorIndex = seriesIndex % defaultOptions.colors.length;
            series.color = defaultOptions.colors[colorIndex];
            originalColorMap.set(series, series.color);
          }
        });

        const HIGHLIGHT_NOT_SET = -1;
        let hightlightedSeries = HIGHLIGHT_NOT_SET;

        function unhighlightSeries() {
          if (hightlightedSeries === HIGHLIGHT_NOT_SET) {
            return;
          }
          hightlightedSeries = HIGHLIGHT_NOT_SET;
          $scope.chart.forEach((series, seriesIndex) => {
              series.color = originalColorMap.get(series); //just reset the colors
          });
          drawPlot($scope.chart);
        }
        
        $scope.highlightSeries = _.debounce(function (id) {
          if (hightlightedSeries === id) {
            return;
          }

          hightlightedSeries = id;
          $scope.chart.forEach((series, seriesIndex) => {
            if (seriesIndex !== id) {
              series.color = 'rgba(128,128,128,0.1)';//mark as grey
            } else {
              series.color = originalColorMap.get(series);//color it like it was
            }
          });
          drawPlot($scope.chart);
        }, DEBOUNCE_DELAY);

@nreese
nreese force-pushed the highlight_series_on_mouseover branch from 1f59095 to 2936bdb Compare December 5, 2017 01:28
@timroes

timroes commented Dec 12, 2017

Copy link
Copy Markdown
Contributor

The legends are currently focusable. I would really like to see the series highlight also when the legend receives focus, so that you can also highlight series via keyboard (keyword: accessibility :D).

@nreese
nreese force-pushed the highlight_series_on_mouseover branch from e9f9ca3 to e62b69d Compare December 12, 2017 16:43

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

focusedSeries || focusedSeries === 0 otherwise we loose the focus when focusing the first element, because 0 == false.

@nreese
nreese force-pushed the highlight_series_on_mouseover branch from 2e473b1 to a3e8f35 Compare December 13, 2017 19:58
@nreese
nreese merged commit 87498c4 into elastic:master Dec 13, 2017
nreese added a commit to nreese/kibana that referenced this pull request Dec 13, 2017
* highlight series on mouseover

* thomasneirynck review items

* make highlighting keyboard accessible

* add check for zero to focus if block
nreese added a commit that referenced this pull request Dec 13, 2017
* highlight series on mouseover

* thomasneirynck review items

* make highlighting keyboard accessible

* add check for zero to focus if block
nyurik pushed a commit to nyurik/kibana that referenced this pull request Dec 15, 2017
* highlight series on mouseover

* thomasneirynck review items

* make highlighting keyboard accessible

* add check for zero to focus if block
patrykkopycinski pushed a commit to patrykkopycinski/kibana that referenced this pull request May 6, 2026
* highlight series on mouseover

* thomasneirynck review items

* make highlighting keyboard accessible

* add check for zero to focus if block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:Timelion Timelion app and visualization Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:enhancement v6.2.0 v7.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Highlighting series in Timelion (by hovering on legend)

3 participants