-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[ML] File datavisualizer initial commit #22828
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
Changes from 9 commits
3c008ec
57a1fd4
3c0c69c
58da202
4abbeed
ccfe844
28231d9
9bd18a7
f704f48
bfea643
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| @import 'components/index'; | ||
|
|
||
| .file-datavisualizer-container { | ||
| padding: 20px; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @import 'file_datavisualizer'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| @import 'file_datavisualizer_view/index'; | ||
| @import 'results_view/index'; | ||
| @import 'summary/index'; | ||
| @import 'fields_stats/index'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| .card-container { | ||
| display: inline-grid; | ||
| padding: 0px 10px 10px 0px; | ||
| } | ||
|
|
||
| .ml-field-data-card { | ||
| height: 408px; | ||
|
|
||
| .card-contents { | ||
| height: 378px; | ||
| line-height: 21px; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| .fields-stats { | ||
| padding: 10px; | ||
| } | ||
| .field { | ||
| margin-bottom: 10px; | ||
| } | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| @import 'fields_stats'; | ||
| @import 'field_stats_card'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| /* | ||
| * 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 React from 'react'; | ||
|
|
||
| import { | ||
| EuiSpacer, | ||
|
|
||
| } from '@elastic/eui'; | ||
|
|
||
| import { FieldTypeIcon } from '../../../components/field_type_icon'; | ||
|
|
||
| export function FieldStatsCard({ field }) { | ||
|
|
||
| const percent = Math.round(field.percent * 100) / 100; | ||
|
|
||
| let type = field.type; | ||
| if (type === 'double' || type === 'long') { | ||
| type = 'number'; | ||
| } | ||
|
|
||
| return ( | ||
| <React.Fragment> | ||
| <div className="card-container"> | ||
| <div className="ml-field-data-card"> | ||
| <div | ||
| className={`ml-field-title-bar ${type}`} | ||
| > | ||
| <FieldTypeIcon type={type} /> | ||
| <div className="field-name">{field.name}</div> | ||
| </div> | ||
|
|
||
| <div className="card-contents"> | ||
| <div className="stats"> | ||
| <div className="stat"> | ||
| <i className="fa fa-files-o" aria-hidden="true" /> {field.count} document{(field.count > 1) ? 's' : ''} ({percent}%) | ||
| </div> | ||
| <div className="stat"> | ||
| <i className="fa fa-cubes" aria-hidden="true" /> {field.cardinality} distinct value{(field.cardinality > 1) ? 's' : ''} | ||
| </div> | ||
|
|
||
| { | ||
| (field.mean_value) && | ||
| <React.Fragment> | ||
| <div> | ||
| <div className="stat min heading">min</div> | ||
| <div className="stat median heading">median</div> | ||
| <div className="stat max heading">max</div> | ||
| </div> | ||
| <div> | ||
| <div className="stat min heading">{field.min_value}</div> | ||
| <div className="stat median heading">{field.median_value}</div> | ||
| <div className="stat max heading">{field.max_value}</div> | ||
| </div> | ||
| </React.Fragment> | ||
| } | ||
| </div> | ||
|
|
||
| { | ||
| (field.top_hits) && | ||
| <React.Fragment> | ||
|
|
||
| <EuiSpacer size="s" /> | ||
|
|
||
| <div className="stats"> | ||
| <div className="stat">top values</div> | ||
| {field.top_hits.map((h) => { | ||
| const pcnt = Math.round(((h.count / field.count) * 100) * 100) / 100; | ||
| return ( | ||
| <div key={h.value} className="top-value"> | ||
| <div className="field-label">{h.value} </div> | ||
| <div className="top-value-bar-holder"> | ||
| <div | ||
| className={`top-value-bar ${type}`} | ||
| style={{ width: `${pcnt}%` }} | ||
| /> | ||
| </div> | ||
| <div className="count-label">{pcnt}%</div> | ||
| </div> | ||
| ); | ||
| } | ||
| )} | ||
| </div> | ||
| </React.Fragment> | ||
| } | ||
|
|
||
| </div> | ||
| </div> | ||
| </div> | ||
| </React.Fragment> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| /* | ||
| * 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 React, { | ||
| Component, | ||
| } from 'react'; | ||
|
|
||
| import { FieldStatsCard } from './field_stats_card'; | ||
|
|
||
| export class FieldsStats extends Component { | ||
| constructor(props) { | ||
| super(props); | ||
|
|
||
| this.fields = createFields(this.props.results); | ||
| console.log(this.fields); | ||
|
||
| } | ||
|
|
||
| render() { | ||
| return ( | ||
| <div className="fields-stats"> | ||
| { | ||
| this.fields.map(f => ( | ||
| <FieldStatsCard | ||
| field={f} | ||
| key={f.name} | ||
| /> | ||
| )) | ||
| } | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| function createFields(results) { | ||
| const { | ||
| mappings, | ||
| field_stats: fieldStats, | ||
| num_messages_analyzed: numMessagesAnalyzed, | ||
| timestamp_field: timestampField, | ||
| } = results; | ||
|
|
||
| let fields = []; | ||
|
|
||
| if (mappings && fieldStats) { | ||
| fields = Object.keys(fieldStats).map((fName) => { | ||
| const field = { name: fName }; | ||
| const f = fieldStats[fName]; | ||
| const m = mappings[fName]; | ||
|
|
||
| // sometimes the timestamp field is not in the mappings, and so our | ||
| // collection of fields will be missing a time field with a type of date | ||
| if (fName === timestampField && field.type === undefined) { | ||
| field.type = 'date'; | ||
| } | ||
|
|
||
| if (f !== undefined) { | ||
| Object.assign(field, f); | ||
| } | ||
|
|
||
| if (m !== undefined) { | ||
| field.type = m.type; | ||
| if (m.format !== undefined) { | ||
| field.format = m.format; | ||
| } | ||
| } | ||
|
|
||
| field.percent = ((field.count / numMessagesAnalyzed) * 100); | ||
|
|
||
| return field; | ||
| }); | ||
| } | ||
| return fields; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| /* | ||
| * 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 { FieldsStats } from './fields_stats'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /* | ||
| * 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 React from 'react'; | ||
|
|
||
| import { | ||
| EuiTitle, | ||
| EuiSpacer, | ||
| } from '@elastic/eui'; | ||
|
|
||
| import { MLJobEditor, EDITOR_MODE } from '../../../jobs/jobs_list/components/ml_job_editor'; | ||
|
|
||
| export function FileContents({ data, format, numberOfLines }) { | ||
| let mode = EDITOR_MODE.TEXT; | ||
| if (format === EDITOR_MODE.JSON) { | ||
| mode = EDITOR_MODE.JSON; | ||
| } | ||
|
|
||
| const formattedData = limitByNumberOfLines(data, numberOfLines); | ||
|
|
||
| return ( | ||
| <React.Fragment> | ||
| <EuiTitle size="s"> | ||
| <h3>File contents</h3> | ||
| </EuiTitle> | ||
|
|
||
| <div>First {numberOfLines} line{(numberOfLines > 1) ? 's' : ''}</div> | ||
|
|
||
| <EuiSpacer size="s" /> | ||
|
|
||
| <MLJobEditor | ||
| mode={mode} | ||
| readOnly={true} | ||
| value={formattedData} | ||
| height="200px" | ||
|
||
| /> | ||
| </React.Fragment> | ||
| ); | ||
| } | ||
|
|
||
| function limitByNumberOfLines(data, numberOfLines) { | ||
| return data.split('\n').slice(0, numberOfLines).join('\n'); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| /* | ||
| * 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 { FileContents } from './file_contents'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @import 'file_datavisualizer_view' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could any of these settings be used in the existing index based datavisualizer once that is converted to
sass? Just wondering if some of these should be moved to a higher levelscssfile?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i imagine there will be common rules which can be moved to a shared location once the big sass conversion has happened