From d4f23e6769206f34d9d5792d33629c6b3f9c2f18 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 27 Sep 2018 21:10:11 +0200 Subject: [PATCH] [ML] Improve Explorer Chart labels. (#23494) Improves the display of the Explorer Chart labels to fix the following issues: - Long chart labels could be cut off, so it's not possible to tell what entity fields a chart is referring to. A workaround is to hover the info icon tooltip but that's really slow and cumbersome if you have to do it for every chart. - The list of entity fields and its values is an unformatted text blob which makes it hard to read and tell which values refer to which field. Changes: - If any of the chart labels is longer than 60 chars, the entity fields will wrap to a new line (for all charts to a achieve a consistent look). - Entity fields use EuiBadge and some custom formatting to make it easier to see field/value pairs. - If the detector description is too long, it still uses ellipsis for text-overflow: - If the entity badges are too long, they will be just cut off to the right. There's no simple CSS fix for that, we cannot use ellipsis and we don't want to wrap those badges again because then multiple charts could have different heights. I experimented with gradients but that turned out to be somewhat unreliable. I still consider this a good enough improvement compare to the previous version and would like to leave a tweak for that to a follow up PR. - If there are mixed detectors with and without entity fields and the existing one wrap, multiple charts are aligned considered the height of the entity fields on display: - Additionally, this changes the link to the single series viewer from custom code using a Font Awesome icon to use EuiButtonEmpty with the same EUI based icon and a tooltip. --- .../plugins/ml/public/explorer/explorer.html | 2 + .../explorer_charts_container.test.js.snap | 54 -------- .../explorer_chart_label.test.js.snap | 120 ++++++++++++++++++ .../explorer_chart_label_badge.test.js.snap | 18 +++ .../explorer_chart_label.js | 75 +++++++++++ .../explorer_chart_label.test.js | 45 +++++++ .../explorer_chart_label_badge.js | 30 +++++ .../explorer_chart_label_badge.test.js | 24 ++++ .../components/explorer_chart_label/index.js | 7 + .../styles/explorer_chart_label.less | 33 +++++ .../styles/explorer_chart_label_badge.less | 10 ++ .../explorer_charts/explorer_chart.js | 6 +- .../explorer_charts_container.js | 74 ++++++----- .../explorer_charts_container.test.js | 39 +++++- .../styles/explorer_chart.less | 6 +- .../styles/explorer_charts_container.less | 39 ++---- x-pack/plugins/ml/public/util/chart_utils.js | 9 ++ .../ml/public/util/chart_utils.test.js | 21 +++ 18 files changed, 492 insertions(+), 120 deletions(-) delete mode 100644 x-pack/plugins/ml/public/explorer/explorer_charts/__snapshots__/explorer_charts_container.test.js.snap create mode 100644 x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/__snapshots__/explorer_chart_label.test.js.snap create mode 100644 x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/__snapshots__/explorer_chart_label_badge.test.js.snap create mode 100644 x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label.js create mode 100644 x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label.test.js create mode 100644 x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label_badge.js create mode 100644 x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label_badge.test.js create mode 100644 x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/index.js create mode 100644 x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/styles/explorer_chart_label.less create mode 100644 x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/styles/explorer_chart_label_badge.less diff --git a/x-pack/plugins/ml/public/explorer/explorer.html b/x-pack/plugins/ml/public/explorer/explorer.html index 857a3755a7771..d94296e3ad6a4 100644 --- a/x-pack/plugins/ml/public/explorer/explorer.html +++ b/x-pack/plugins/ml/public/explorer/explorer.html @@ -131,6 +131,8 @@

No {{swimlaneViewByFieldName}} influencers +
+
diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/__snapshots__/explorer_charts_container.test.js.snap b/x-pack/plugins/ml/public/explorer/explorer_charts/__snapshots__/explorer_charts_container.test.js.snap deleted file mode 100644 index 087558cfa4ed4..0000000000000 --- a/x-pack/plugins/ml/public/explorer/explorer_charts/__snapshots__/explorer_charts_container.test.js.snap +++ /dev/null @@ -1,54 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ExplorerChartsContainer Initialization with chart data 1`] = ` -
-
- - high_sum(nginx.access.body_sent.bytes) over nginx.access.remote_ip (population-03) - - - - - nginx.access.remote_ip - - 72.57.0.53 - -
- - } - position="left" - size="s" - type="questionInCircle" - /> - - View -