From cce639f13f3ae16b17a2ddc611c10a91a13a585b Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Tue, 25 Sep 2018 17:09:02 +0200 Subject: [PATCH 01/19] [ML] Tweak Explorer Chart labels. --- .../explorer_charts_container.test.js.snap | 27 ++++----- .../explorer_charts_container.js | 56 ++++++++++++++----- .../styles/explorer_charts_container.less | 4 ++ 3 files changed, 58 insertions(+), 29 deletions(-) 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 index 087558cfa4ed4..c58d2325cd6d1 100644 --- 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 @@ -4,21 +4,18 @@ 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 - -
+ `${d.fieldName} ${d.fieldValue}`).join(' ').length; +} + +function ChartLabelBadge({ entity }) { + return ( + + {entity.fieldName} {entity.fieldValue} + + ); +} + +function ChartLabel({ detectorLabel, entityFields }) { + let labelSeparator = ' - '; + if (getLabelCharLength(detectorLabel, entityFields) > LABEL_SPLIT_THRESHOLD) { + labelSeparator =
; + } + + return ( +
+ {(detectorLabel.length > 0 && entityFields.length > 0) && ( + {detectorLabel} {labelSeparator} + )} + {(detectorLabel.length > 0 && entityFields.length === 0) && ( + {detectorLabel} + )} + {entityFields.map((entity, j) => { + return ( + + ); + })} +
+ ); +} + export function ExplorerChartsContainer({ seriesToPlot, layoutCellsPerChart, @@ -36,19 +76,7 @@ export function ExplorerChartsContainer({ return (
-
- {(detectorLabel.length > 0 && entityFields.length > 0) && ( - {detectorLabel} - - )} - {(detectorLabel.length > 0 && entityFields.length === 0) && ( - {detectorLabel} - )} - {entityFields.map((entity, j) => { - return ( - {entity.fieldName} {entity.fieldValue} - ); - })} -
+ } position="left" size="s" /> {tooManyBuckets && ( Date: Wed, 26 Sep 2018 09:58:13 +0200 Subject: [PATCH 02/19] [ML] Wrap all chart labels if one is too long. --- .../explorer_charts_container.js | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/explorer_charts_container.js b/x-pack/plugins/ml/public/explorer/explorer_charts/explorer_charts_container.js index 5c3241e75f789..c602978cb0068 100644 --- a/x-pack/plugins/ml/public/explorer/explorer_charts/explorer_charts_container.js +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/explorer_charts_container.js @@ -17,9 +17,9 @@ import { ExplorerChart } from './explorer_chart'; import { ExplorerChartTooltip } from './explorer_chart_tooltip'; const LABEL_SPLIT_THRESHOLD = 100; - -function getLabelCharLength(detectorLabel, entityFields) { - return detectorLabel.length + entityFields.map(d => `${d.fieldName} ${d.fieldValue}`).join(' ').length; +function isLabelLengthAboveThreshold({ detectorLabel, entityFields }) { + const labelLength = (detectorLabel.length + entityFields.map(d => `${d.fieldName} ${d.fieldValue}`).join(' ').length); + return (labelLength > LABEL_SPLIT_THRESHOLD); } function ChartLabelBadge({ entity }) { @@ -30,11 +30,8 @@ function ChartLabelBadge({ entity }) { ); } -function ChartLabel({ detectorLabel, entityFields }) { - let labelSeparator = ' - '; - if (getLabelCharLength(detectorLabel, entityFields) > LABEL_SPLIT_THRESHOLD) { - labelSeparator =
; - } +function ChartLabel({ detectorLabel, entityFields, wrapLabel }) { + const labelSeparator = (wrapLabel === true) ?
: ' - '; return (
@@ -59,6 +56,8 @@ export function ExplorerChartsContainer({ tooManyBuckets, mlSelectSeverityService }) { + const wrapLabel = seriesToPlot.some((series) => isLabelLengthAboveThreshold(series)); + return (
{(seriesToPlot.length > 0) && @@ -76,7 +75,11 @@ export function ExplorerChartsContainer({ return (
- + } position="left" size="s" /> {tooManyBuckets && ( Date: Wed, 26 Sep 2018 10:21:07 +0200 Subject: [PATCH 03/19] [ML] Split up components into their own files. --- .../explorer_chart_label.js | 36 ++++++++++++++++ .../explorer_chart_label_badge.js | 26 +++++++++++ .../components/explorer_chart_label/index.js | 7 +++ .../explorer_charts_container.js | 43 +++---------------- x-pack/plugins/ml/public/util/chart_utils.js | 9 ++++ 5 files changed, 84 insertions(+), 37 deletions(-) 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_badge.js create mode 100644 x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/index.js diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label.js b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label.js new file mode 100644 index 0000000000000..dfe58562c0c73 --- /dev/null +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label.js @@ -0,0 +1,36 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import PropTypes from 'prop-types'; +import React from 'react'; + +import { ExplorerChartLabelBadge } from './explorer_chart_label_badge'; + +export function ExplorerChartLabel({ detectorLabel, entityFields, wrapLabel }) { + const labelSeparator = (wrapLabel === true) ?
: ' - '; + + return ( +
+ {(detectorLabel.length > 0 && entityFields.length > 0) && ( + {detectorLabel} {labelSeparator} + )} + {(detectorLabel.length > 0 && entityFields.length === 0) && ( + {detectorLabel} + )} + {entityFields.map((entity, j) => { + return ( + + ); + })} +
+ ); +} +ExplorerChartLabel.propTypes = { + series: PropTypes.shape({ + detectorLabel: PropTypes.string.isRequired, + entityFields: PropTypes.array.isRequired + }) +}; diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label_badge.js b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label_badge.js new file mode 100644 index 0000000000000..7f866643aea04 --- /dev/null +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label_badge.js @@ -0,0 +1,26 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import PropTypes from 'prop-types'; +import React from 'react'; + +import { + EuiBadge +} from '@elastic/eui'; + +export function ExplorerChartLabelBadge({ entity }) { + return ( + + {entity.fieldName} {entity.fieldValue} + + ); +} +ExplorerChartLabelBadge.propTypes = { + entity: PropTypes.shape({ + fieldName: PropTypes.string.isRequired, + fieldValue: PropTypes.string.isRequired + }) +}; diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/index.js b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/index.js new file mode 100644 index 0000000000000..0cfc2b8463ef8 --- /dev/null +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/index.js @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export * from './explorer_chart_label'; diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/explorer_charts_container.js b/x-pack/plugins/ml/public/explorer/explorer_charts/explorer_charts_container.js index c602978cb0068..5d28dfea2e0e3 100644 --- a/x-pack/plugins/ml/public/explorer/explorer_charts/explorer_charts_container.js +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/explorer_charts_container.js @@ -8,47 +8,16 @@ import PropTypes from 'prop-types'; import React from 'react'; import { - EuiBadge, EuiIconTip } from '@elastic/eui'; -import { getExploreSeriesLink } from '../../util/chart_utils'; +import { + getExploreSeriesLink, + isLabelLengthAboveThreshold +} from '../../util/chart_utils'; import { ExplorerChart } from './explorer_chart'; import { ExplorerChartTooltip } from './explorer_chart_tooltip'; - -const LABEL_SPLIT_THRESHOLD = 100; -function isLabelLengthAboveThreshold({ detectorLabel, entityFields }) { - const labelLength = (detectorLabel.length + entityFields.map(d => `${d.fieldName} ${d.fieldValue}`).join(' ').length); - return (labelLength > LABEL_SPLIT_THRESHOLD); -} - -function ChartLabelBadge({ entity }) { - return ( - - {entity.fieldName} {entity.fieldValue} - - ); -} - -function ChartLabel({ detectorLabel, entityFields, wrapLabel }) { - const labelSeparator = (wrapLabel === true) ?
: ' - '; - - return ( -
- {(detectorLabel.length > 0 && entityFields.length > 0) && ( - {detectorLabel} {labelSeparator} - )} - {(detectorLabel.length > 0 && entityFields.length === 0) && ( - {detectorLabel} - )} - {entityFields.map((entity, j) => { - return ( - - ); - })} -
- ); -} +import { ExplorerChartLabel } from './components/explorer_chart_label'; export function ExplorerChartsContainer({ seriesToPlot, @@ -75,7 +44,7 @@ export function ExplorerChartsContainer({ return (
- `${d.fieldName} ${d.fieldValue}`).join(' ').length); + return (labelLength > LABEL_WRAP_THRESHOLD); +} + // This removes overlapping x-axis labels by starting off from a specific label // that is required/wanted to show up. The code then traverses to both sides along the axis // and decides which labels to keep or remove. All vertical tick lines will be kept visible, From c80911e44ab53a346374edff2bfe95e7e0140ad3 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 26 Sep 2018 10:47:27 +0200 Subject: [PATCH 04/19] [ML] Adds jest tests. --- .../explorer_charts_container.test.js.snap | 3 +- .../explorer_chart_label.test.js.snap | 28 +++++++++++++++++ .../explorer_chart_label_badge.test.js.snap | 15 ++++++++++ .../explorer_chart_label.test.js | 30 +++++++++++++++++++ .../explorer_chart_label_badge.js | 4 ++- .../explorer_chart_label_badge.test.js | 24 +++++++++++++++ .../styles/explorer_chart_label_badge.less | 9 ++++++ .../styles/explorer_charts_container.less | 4 --- .../ml/public/util/chart_utils.test.js | 18 +++++++++++ 9 files changed, 129 insertions(+), 6 deletions(-) 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.test.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/styles/explorer_chart_label_badge.less 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 index c58d2325cd6d1..752855df9ea3d 100644 --- 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 @@ -4,7 +4,7 @@ exports[`ExplorerChartsContainer Initialization with chart data 1`] = `
- + + high_sum(nginx.access.body_sent.bytes) over nginx.access.remote_ip (population-03) + +
+ +
+ + + + +
+`; diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/__snapshots__/explorer_chart_label_badge.test.js.snap b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/__snapshots__/explorer_chart_label_badge.test.js.snap new file mode 100644 index 0000000000000..8e61b8626b731 --- /dev/null +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/__snapshots__/explorer_chart_label_badge.test.js.snap @@ -0,0 +1,15 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ExplorerChartLabelBadge Render entity label badge. 1`] = ` + + nginx.access.remote_ip + + + 72.57.0.53 + + +`; diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label.test.js b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label.test.js new file mode 100644 index 0000000000000..77781048b4cf8 --- /dev/null +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label.test.js @@ -0,0 +1,30 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import seriesConfig from '../../__mocks__/mock_series_config_filebeat.json'; + +import { shallow } from 'enzyme'; +import React from 'react'; + +import { ExplorerChartLabel } from './explorer_chart_label'; + + +describe('ExplorerChartLabelBadge', () => { + + test('Render the chart label.', () => { + + const wrapper = shallow( + + ); + expect(wrapper).toMatchSnapshot(); + + }); + +}); diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label_badge.js b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label_badge.js index 7f866643aea04..8b71afa7230fa 100644 --- a/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label_badge.js +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label_badge.js @@ -4,6 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ +import './styles/explorer_chart_label_badge.less'; + import PropTypes from 'prop-types'; import React from 'react'; @@ -13,7 +15,7 @@ import { export function ExplorerChartLabelBadge({ entity }) { return ( - + {entity.fieldName} {entity.fieldValue} ); diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label_badge.test.js b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label_badge.test.js new file mode 100644 index 0000000000000..e1f84d625c224 --- /dev/null +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label_badge.test.js @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import seriesConfig from '../../__mocks__/mock_series_config_filebeat.json'; + +import { shallow } from 'enzyme'; +import React from 'react'; + +import { ExplorerChartLabelBadge } from './explorer_chart_label_badge'; + + +describe('ExplorerChartLabelBadge', () => { + + test('Render entity label badge.', () => { + + const wrapper = shallow(); + expect(wrapper).toMatchSnapshot(); + + }); + +}); diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/styles/explorer_chart_label_badge.less b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/styles/explorer_chart_label_badge.less new file mode 100644 index 0000000000000..f67c3645f39c6 --- /dev/null +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/styles/explorer_chart_label_badge.less @@ -0,0 +1,9 @@ +/* + Resets the badge's default strong font-weight so it's possible + to put custom emphasis inside the badge only on a part of it. + Used in the Explorer Chart label badge to display an entity's + field_name as `normal` and field_value as `strong`. +*/ +.ml-explorer-chart-label-badge { + font-weight: normal; +} diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/styles/explorer_charts_container.less b/x-pack/plugins/ml/public/explorer/explorer_charts/styles/explorer_charts_container.less index 8b0fcc3869a5b..9d1f205f9b224 100644 --- a/x-pack/plugins/ml/public/explorer/explorer_charts/styles/explorer_charts_container.less +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/styles/explorer_charts_container.less @@ -105,10 +105,6 @@ font-size: 13px; font-weight: normal; - .ml-chart-label-badge { - font-weight: normal; - } - .explorer-chart-label-fields { vertical-align: top; /* account 80px for the "View" link */ diff --git a/x-pack/plugins/ml/public/util/chart_utils.test.js b/x-pack/plugins/ml/public/util/chart_utils.test.js index d4beee8484b9b..a23bf6066d7db 100644 --- a/x-pack/plugins/ml/public/util/chart_utils.test.js +++ b/x-pack/plugins/ml/public/util/chart_utils.test.js @@ -47,6 +47,7 @@ import { timefilter } from 'ui/timefilter'; import { getExploreSeriesLink, getTickValues, + isLabelLengthAboveThreshold, removeLabelOverlap } from './chart_utils'; @@ -133,6 +134,23 @@ describe('getTickValues', () => { }); }); +describe('isLabelLengthAboveThreshold', () => { + + test('short label', () => { + const isLongLabel = isLabelLengthAboveThreshold({ + detectorLabel: 'count', + entityFields: seriesConfig.entityFields + }); + expect(isLongLabel).toBeFalsy(); + }); + + test('long label', () => { + const isLongLabel = isLabelLengthAboveThreshold(seriesConfig); + expect(isLongLabel).toBeTruthy(); + }); + +}); + describe('removeLabelOverlap', () => { const originalGetBBox = SVGElement.prototype.getBBox; From b0e14a9c8c893df67352a32bdbfee10ec53b08d1 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 26 Sep 2018 12:13:49 +0200 Subject: [PATCH 05/19] [ML] Use same icon as in jobs list for single series viewer button. --- .../plugins/ml/public/explorer/explorer.html | 2 + .../explorer_chart_label.js | 6 ++- .../styles/explorer_chart_label.less | 15 ++++++ .../explorer_charts/explorer_chart.js | 6 ++- .../explorer_charts_container.js | 50 ++++++++++++++----- .../styles/explorer_chart.less | 6 ++- .../styles/explorer_charts_container.less | 40 ++++----------- 7 files changed, 76 insertions(+), 49 deletions(-) create mode 100644 x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/styles/explorer_chart_label.less diff --git a/x-pack/plugins/ml/public/explorer/explorer.html b/x-pack/plugins/ml/public/explorer/explorer.html index 81f2b2e76985f..2d15e2ee4606f 100644 --- a/x-pack/plugins/ml/public/explorer/explorer.html +++ b/x-pack/plugins/ml/public/explorer/explorer.html @@ -145,6 +145,8 @@

No {{swimlaneViewByFieldName}} influencers

+
+
diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label.js b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label.js index dfe58562c0c73..38ac39de68f08 100644 --- a/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label.js +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/explorer_chart_label.js @@ -4,6 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ +import './styles/explorer_chart_label_badge.less'; + import PropTypes from 'prop-types'; import React from 'react'; @@ -13,7 +15,7 @@ export function ExplorerChartLabel({ detectorLabel, entityFields, wrapLabel }) { const labelSeparator = (wrapLabel === true) ?
: ' - '; return ( -
+ {(detectorLabel.length > 0 && entityFields.length > 0) && ( {detectorLabel} {labelSeparator} )} @@ -25,7 +27,7 @@ export function ExplorerChartLabel({ detectorLabel, entityFields, wrapLabel }) { ); })} -
+ ); } ExplorerChartLabel.propTypes = { diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/styles/explorer_chart_label.less b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/styles/explorer_chart_label.less new file mode 100644 index 0000000000000..32cc45cb1af6b --- /dev/null +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/components/explorer_chart_label/styles/explorer_chart_label.less @@ -0,0 +1,15 @@ +.ml-explorer-chart-label { + display: block; + font-size: 13px; + font-weight: normal; +} + +.ml-explorer-chart-label-fields { + vertical-align: middle; + /* account 80px for the "View" link */ + max-width: calc(~"100% - 80px"); + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + display: inline-block; +} diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/explorer_chart.js b/x-pack/plugins/ml/public/explorer/explorer_charts/explorer_chart.js index 8687579d9349e..6f1950e8c09c3 100644 --- a/x-pack/plugins/ml/public/explorer/explorer_charts/explorer_chart.js +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/explorer_chart.js @@ -36,6 +36,7 @@ import { mlFieldFormatService } from '../../services/field_format_service'; import { mlChartTooltipService } from '../../components/chart_tooltip/chart_tooltip_service'; const CONTENT_WRAPPER_HEIGHT = 215; +const CONTENT_WRAPPER_CLASS = 'ml-explorer-chart-content-wrapper'; export class ExplorerChart extends React.Component { static propTypes = { @@ -92,13 +93,14 @@ export class ExplorerChart extends React.Component { // Clear any existing elements from the visualization, // then build the svg elements for the chart. - const chartElement = d3.select(element).select('.content-wrapper'); + const chartElement = d3.select(element).select(`.${CONTENT_WRAPPER_CLASS}`); chartElement.select('svg').remove(); const svgWidth = $el.width(); const svgHeight = chartHeight + margin.top + margin.bottom; const svg = chartElement.append('svg') + .classed('ml-explorer-chart-svg', true) .attr('width', svgWidth) .attr('height', svgHeight); @@ -382,7 +384,7 @@ export class ExplorerChart extends React.Component { )} {!isLoading && ( -
+
)}
); diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/explorer_charts_container.js b/x-pack/plugins/ml/public/explorer/explorer_charts/explorer_charts_container.js index 5d28dfea2e0e3..f96486854bf4d 100644 --- a/x-pack/plugins/ml/public/explorer/explorer_charts/explorer_charts_container.js +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/explorer_charts_container.js @@ -8,7 +8,9 @@ import PropTypes from 'prop-types'; import React from 'react'; import { - EuiIconTip + EuiButtonIcon, + EuiIconTip, + EuiToolTip } from '@elastic/eui'; import { @@ -19,6 +21,10 @@ import { ExplorerChart } from './explorer_chart'; import { ExplorerChartTooltip } from './explorer_chart_tooltip'; import { ExplorerChartLabel } from './components/explorer_chart_label'; +const textTooManyBuckets = 'This selection contains too many buckets to be displayed.' + + 'The dashboard is best viewed over a shorter time range.'; +const textViewButton = 'Open in Single Metric Viewer'; + export function ExplorerChartsContainer({ seriesToPlot, layoutCellsPerChart, @@ -43,26 +49,44 @@ export function ExplorerChartsContainer({ return (
-
+ + {wrapLabel && (
)} + {tooManyBuckets && ( + + + + )} + + + +
+
- } position="left" size="s" /> - {tooManyBuckets && ( + } + position="top" size="s" - type="alert" - color="warning" /> - )} - window.open(getExploreSeriesLink(series), '_blank')}> - View