-
Notifications
You must be signed in to change notification settings - Fork 843
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make EUIXYChart responsive using ResizeObserver (#1041)
This drops the use of native react-vis makeVisFlexible in favour of ResizeObserver to support resizing of the chart container as in kibana dashboard. * Rename observable callback to a meaningful one * Add responsive example * Remove unnecessary margin from example demos * Re-enable overflow:hidden on chart after introducing static margins * Fix typos in example text
- Loading branch information
Showing
27 changed files
with
257 additions
and
99 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
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
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,84 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
EuiXYChart, | ||
EuiLineSeries, | ||
} from '../../../../src/experimental'; | ||
import { | ||
EuiButton, | ||
EuiPage, | ||
EuiPageBody, | ||
EuiPageContent, | ||
EuiPageContentBody, | ||
EuiPageContentHeader, | ||
EuiPageContentHeaderSection, | ||
EuiPageHeader, | ||
EuiPageHeaderSection, | ||
EuiPageSideBar, | ||
EuiTitle, | ||
} from '../../../../src/components'; | ||
|
||
const DATA_A = [ | ||
{ x: 0, y: 1 }, | ||
{ x: 1, y: 1 }, | ||
{ x: 2, y: 2 }, | ||
{ x: 3, y: -1 }, | ||
{ x: 4, y: 3 }, | ||
{ x: 5, y: 2 }, | ||
]; | ||
|
||
export default class Example extends React.Component { | ||
state = { | ||
sideBarVisible: true, | ||
} | ||
onClick = () => { | ||
this.setState((prevState) => ({ sideBarVisible: !prevState.sideBarVisible })); | ||
} | ||
render() { | ||
const { sideBarVisible } = this.state; | ||
return ( | ||
<EuiPage> | ||
{ | ||
sideBarVisible && ( | ||
<EuiPageSideBar> | ||
Side bar | ||
</EuiPageSideBar> | ||
) | ||
} | ||
<EuiPageBody> | ||
<EuiPageHeader> | ||
<EuiPageHeaderSection> | ||
<EuiTitle size="l"> | ||
<h1>Page title</h1> | ||
</EuiTitle> | ||
</EuiPageHeaderSection> | ||
<EuiPageHeaderSection> | ||
<EuiButton | ||
onClick={this.onClick} | ||
> | ||
Toggle Sidebar | ||
</EuiButton> | ||
</EuiPageHeaderSection> | ||
</EuiPageHeader> | ||
<EuiPageContent> | ||
<EuiPageContentHeader> | ||
<EuiPageContentHeaderSection> | ||
<EuiTitle> | ||
<h2>Chart title</h2> | ||
</EuiTitle> | ||
</EuiPageContentHeaderSection> | ||
<EuiPageContentHeaderSection> | ||
Chart abilities | ||
</EuiPageContentHeaderSection> | ||
</EuiPageContentHeader> | ||
<EuiPageContentBody style={{ height: '300px' }}> | ||
<EuiXYChart showDefaultAxis={false} margins={0}> | ||
<EuiLineSeries name="Total Bytes" data={DATA_A} /> | ||
</EuiXYChart> | ||
</EuiPageContentBody> | ||
</EuiPageContent> | ||
</EuiPageBody> | ||
</EuiPage> | ||
); | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.