Skip to content
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

[SIEM] Replace Eui chart with elastic charts for siem kpis #36660

Merged
merged 8 commits into from
May 29, 2019

Conversation

angorayc
Copy link
Contributor

@angorayc angorayc commented May 19, 2019

Summary

This PR is to isolate charts from stat items component and replace Eui-chart with elastic-charts for siem kpis. (https://github.com/elastic/ingest-dev/issues/445)

Currently with Elastic Charts:
Screenshot 2019-05-23 at 01 10 02

With Win8 IE11
VirtualBox_IE11 - Win81_25_05_2019_04_31_20

Previously with EUI chart:
Screenshot 2019-05-20 at 04 06 17

Known issue:

  1. Unable to customise the ticks atm but will be able to configure the number of tick we are going to show.
  2. The value in tooltip is not formatted and no abbreviation for y axis of barcharts as currently they share the same formatter, but will be able to specify separate formatter for both.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

- [ ] This was checked for cross-browser compatibility, including a check against IE11
- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
- [ ] Documentation was added for features that require explanation or tutorials

For maintainers

- [ ] This was checked for breaking API changes and was labeled appropriately
- [ ] This includes a feature addition or change that requires a release note and was labeled appropriately

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@angorayc angorayc self-assigned this May 21, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/secops

@elasticmachine
Copy link
Contributor

💔 Build Failed

it('should render a customized y-asix', () => {
expect(wrapper.find('EuiYAxis')).toHaveLength(1);
it('should render Chart', () => {
expect(wrapper.find('Chart')).toHaveLength(1);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing further testing for charts' detail here because

  1. It is render by canvas so not able to be tested from outside of the library. - Make the chart testable from outside elastic-charts#215
  2. Most of the cases have been tested inside elastic-charts.

LINE = 'line',
}

export const getSeriesStyle = (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

return value.toLocaleString && value.toLocaleString();
};

export enum SeriesType {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Align with the seriesType mentioned in elastic-charts overview

@angorayc angorayc marked this pull request as ready for review May 22, 2019 17:12
@angorayc angorayc changed the title replace Eui chart with elastic charts for siem kpis Replace Eui chart with elastic charts for siem kpis May 22, 2019
@elasticmachine
Copy link
Contributor

💔 Build Failed

@angorayc
Copy link
Contributor Author

reset please

@angorayc
Copy link
Contributor Author

retest this

1 similar comment
@angorayc
Copy link
Contributor Author

retest this

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💔 Build Failed

@angorayc
Copy link
Contributor Author

reset this

1 similar comment
@angorayc
Copy link
Contributor Author

reset this

@spong spong added the release_note:skip Skip the PR/issue when compiling release notes label May 23, 2019
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@angorayc
Copy link
Contributor Author

angorayc commented May 23, 2019

Temporary close this as a problem was found on IE crashes the app.

@angorayc angorayc closed this May 23, 2019
@angorayc
Copy link
Contributor Author

Reopening this PR as the problem has been fixed in @elastic-charts 4.2.6:
#36753

@angorayc angorayc reopened this May 24, 2019
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

package.json Outdated
@@ -434,4 +434,4 @@
"node": "10.15.2",
"yarn": "^1.10.1"
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

new line here. That's weird your IDE didn't auto-add it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Somehow it allowed a new line for all the files but this one (It was not only not adding it, but removing it if I added) lol. Thanks for notice, just upgrade my VSCode and added a rule for it :D

)}
</AutoSizer>
)
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Really clean and great code! For these pure functions I would recommend changing them to use React.Memo like so:

export const AreaChart = React.memo<{ areaChart: AreaChartData[] | null | undefined }>(
  ({ areaChart }) => (
    <AutoSizer detectAnyWindowResize={false} content>
      {({ measureRef, content: { height, width } }) => (
        <WrappedByAutoSizer innerRef={measureRef}>
          <AreaChartWithCustomPrompt data={areaChart} height={height} width={width} />
        </WrappedByAutoSizer>
      )}
    </AutoSizer>
  )
);

For new code moving forward I think we can remove our usage of recompose and just utilize React when we write new code which is pretty awesome.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing, thanks! I am happy to move away from pure component. I'll have another PR for enhancing kpi network, and do the cleanup for it as well.

<FlexGroup justifyContent="center" alignItems="center">
<EuiFlexItem grow={false}>
<EuiText size="s" textAlign="center" color="subdued">
Chart Data Not Available
Copy link
Contributor

Choose a reason for hiding this comment

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

You will need a i18n key here for Chart Data Not Available. It doesn't have to be a new separate file if you don't want it to be. Some people prefer to use i18n inline within their files and I think that's fine.

@@ -49,28 +36,10 @@ export interface StatItem {
description?: string;
value: number | undefined | null;
color?: string;
icon?: 'storage' | 'cross' | 'check' | 'visMapCoordinate';
icon?: 'storage' | 'cross' | 'check' | 'visMapCoordinate' | 'globe';
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this just be better as the exported Icon Type from EUI?:

import { IconType } from '@elastic/eui';
icon?: IconType

Then you don't have to retype it for each new icon you want to add here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, that makes the code much easier to maintain! Thanks!

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@@ -349,7 +349,7 @@
"dedent": "^0.7.0",
"delete-empty": "^2.0.0",
"enzyme": "^3.7.0",
"enzyme-adapter-react-16": "^1.9.0",
"enzyme-adapter-react-16": "^1.10.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Upgrade enzyme-adapter-react-16 to support React.memo
enzymejs/enzyme#1914

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@angorayc angorayc changed the title Replace Eui chart with elastic charts for siem kpis [SIEM] Replace Eui chart with elastic charts for siem kpis May 28, 2019
Copy link
Contributor

@FrankHassanabad FrankHassanabad left a comment

Choose a reason for hiding this comment

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

Checked it out, played with it, and really appreciate the upgrade for enzyme for everyone so we can use Rect.memo.

Looks great to me!

@angorayc angorayc merged commit ac3eb85 into elastic:master May 29, 2019
angorayc added a commit to angorayc/kibana that referenced this pull request May 29, 2019
…6660)

* move charts to separate components

* replace areachart

* apply custom styles

* customize barchart color

* customize color for areachart

* move reusable functions into common

* exchange x & y value in barchart dataset

* replace pure component with react memo and upgrade enzyme adapter
angorayc added a commit that referenced this pull request May 29, 2019
…37317)

* move charts to separate components

* replace areachart

* apply custom styles

* customize barchart color

* customize color for areachart

* move reusable functions into common

* exchange x & y value in barchart dataset

* replace pure component with react memo and upgrade enzyme adapter
jkakavas pushed a commit to jkakavas/kibana that referenced this pull request May 30, 2019
…6660)

* move charts to separate components

* replace areachart

* apply custom styles

* customize barchart color

* customize color for areachart

* move reusable functions into common

* exchange x & y value in barchart dataset

* replace pure component with react memo and upgrade enzyme adapter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:SIEM v7.3.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants