-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Chart info tooltips include a descriptive text for rare and popu…
…lation charts.
- Loading branch information
Showing
7 changed files
with
126 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...explorer/explorer_charts/components/explorer_chart_label/styles/explorer_chart_label.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.ml-explorer-chart-eui-icon-tip { | ||
max-width: none; | ||
} |
81 changes: 81 additions & 0 deletions
81
x-pack/plugins/ml/public/explorer/explorer_charts/explorer_chart_info_tooltip.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* 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 './styles/explorer_chart_info_tooltip.less'; | ||
|
||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
|
||
import { CHART_TYPE } from '../explorer_constants'; | ||
|
||
const CHART_DESCRIPTION = { | ||
[CHART_TYPE.EVENT_DISTRIBUTION]: 'The gray dots depict the distribution of occurences over time for a sample of by_field_values with \ | ||
more frequent event types at the top and more rare ones at the bottom.', | ||
[CHART_TYPE.POPULATION_DISTRIBUTION]: 'The gray dots depict the distribution of values over time for a sample of over_field_values.' | ||
}; | ||
|
||
function TooltipDefinitionList({ toolTipData }) { | ||
return ( | ||
<dl className="mlDescriptionList"> | ||
{toolTipData.map(({ title, description }) => { | ||
return ( | ||
<React.Fragment> | ||
<dt className="mlDescriptionList__title">{title}</dt> | ||
<dd className="mlDescriptionList__description">{description}</dd> | ||
</React.Fragment> | ||
); | ||
})} | ||
</dl> | ||
); | ||
} | ||
|
||
export function ExplorerChartInfoTooltip({ | ||
jobId, | ||
aggregationInterval, | ||
chartFunction, | ||
chartType, | ||
entityFields = [], | ||
}) { | ||
const chartDescription = CHART_DESCRIPTION[chartType]; | ||
|
||
const toolTipData = [ | ||
{ | ||
title: 'job ID', | ||
description: jobId, | ||
}, | ||
{ | ||
title: 'aggregation interval', | ||
description: aggregationInterval, | ||
}, | ||
{ | ||
title: 'chart function', | ||
description: chartFunction, | ||
}, | ||
]; | ||
|
||
entityFields.forEach((entityField) => { | ||
toolTipData.push({ | ||
title: entityField.fieldName, | ||
description: entityField.fieldValue | ||
}); | ||
}); | ||
|
||
return ( | ||
<div className="ml-explorer-chart-info-tooltip"> | ||
<TooltipDefinitionList toolTipData={toolTipData} /> | ||
{chartDescription && ( | ||
<span className="ml-explorer-chart-description">{chartDescription}</span> | ||
)} | ||
</div> | ||
); | ||
} | ||
ExplorerChartInfoTooltip.propTypes = { | ||
jobId: PropTypes.string.isRequired, | ||
aggregationInterval: PropTypes.string, | ||
chartFunction: PropTypes.string, | ||
entityFields: PropTypes.array | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
x-pack/plugins/ml/public/explorer/explorer_charts/explorer_chart_tooltip.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
x-pack/plugins/ml/public/explorer/explorer_charts/styles/explorer_chart_info_tooltip.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
.ml-explorer-chart-info-tooltip { | ||
max-width: 384px; | ||
} | ||
|
||
.ml-explorer-chart-description { | ||
font-size: 12px; | ||
font-style: italic; | ||
} | ||
|
||
.ml-explorer-chart-info-tooltip .mlDescriptionList > * { | ||
margin-top: 3px; | ||
} | ||
|
||
.ml-explorer-chart-info-tooltip .mlDescriptionList { | ||
display: grid; | ||
grid-template-columns: max-content auto; | ||
|
||
.mlDescriptionList__title { | ||
color: #fff; | ||
font-size: 12px; | ||
font-weight: normal; | ||
white-space: nowrap; | ||
grid-column-start: 1; | ||
} | ||
|
||
.mlDescriptionList__description { | ||
color: #fff; | ||
font-size: 12px; | ||
font-weight: bold; | ||
padding-left: 8px; | ||
max-width: 256px; | ||
grid-column-start: 2; | ||
} | ||
} |