-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from markov00/eui-bar-types
EUI Barchart and Histogram refactoring
- Loading branch information
Showing
134 changed files
with
21,658 additions
and
21,979 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import React, { Fragment, Component } from 'react'; | ||
|
||
import { | ||
EuiText, | ||
EuiCodeBlock, | ||
EuiSpacer, | ||
EuiXYChart, | ||
EuiBarSeries, | ||
EuiAreaSeries, | ||
EuiLineSeries, | ||
} from '../../../../src/components'; | ||
|
||
const barSeries = []; | ||
for (let i = 0; i < 2; i++) { | ||
const data = new Array(20).fill(0).map((d, i) => ({ x: i, y: Number((Math.random() * 4).toFixed(2)) })); | ||
barSeries.push(data); | ||
} | ||
const lineData = new Array(20).fill(0).map((d, i) => ({ x: i, y: Number((Math.random() * 4).toFixed(2)) })); | ||
const areaData = new Array(20).fill(0).map((d, i) => ({ x: i, y: Number((Math.random() * 4).toFixed(2)) })); | ||
|
||
export default class ComplexDemo extends Component { | ||
state = { | ||
json: 'Please drag your mouse to select an area or click on an element' | ||
} | ||
handleSelectionBrushEnd = (area) => { | ||
this.setState(() => ({ | ||
eventName: 'onSelectionBrushEnd', | ||
json: JSON.stringify(area, null, 2), | ||
})); | ||
} | ||
handleOnValueClick = (data) => { | ||
this.setState(() => ({ | ||
eventName: 'onValueClick', | ||
json: JSON.stringify(data, null, 2), | ||
})); | ||
} | ||
handleOnSeriesClick = (series) => () => { | ||
this.setState(() => ({ | ||
eventName: 'onSeriesClick', | ||
json: JSON.stringify({ name: series }), | ||
})); | ||
} | ||
render() { | ||
const { eventName, json } = this.state | ||
return ( | ||
<Fragment> | ||
<EuiXYChart | ||
enableSelectionBrush={true} | ||
onSelectionBrushEnd={this.handleSelectionBrushEnd} | ||
width={600} | ||
height={200} | ||
> | ||
<EuiAreaSeries | ||
name="Quitters" | ||
curve="curveMonotoneX" | ||
data={areaData} | ||
onSeriesClick={this.handleOnSeriesClick('EuiAreaSeries')} | ||
/> | ||
{barSeries | ||
.map((data, index) => ( | ||
<EuiBarSeries | ||
key={index} | ||
name={`User-${index}`} | ||
data={data} | ||
onValueClick={this.handleOnValueClick} | ||
/> | ||
))} | ||
<EuiLineSeries | ||
name="Avg Winners" | ||
data={lineData} | ||
curve="curveMonotoneX" | ||
onSeriesClick={this.handleOnSeriesClick('EuiLineSeries')} | ||
/> | ||
</EuiXYChart> | ||
<EuiSpacer size="xl"/> | ||
{ eventName && ( | ||
<EuiText grow={false}> | ||
<p>Event: <em>{ eventName }</em></p> | ||
</EuiText> | ||
)} | ||
<EuiCodeBlock language="json"> | ||
{ json } | ||
</EuiCodeBlock> | ||
</Fragment> | ||
); | ||
} | ||
}; |
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,42 @@ | ||
import React from 'react'; | ||
|
||
import { EuiSpacer, EuiXYChart, EuiBarSeries } from '../../../../src/components'; | ||
|
||
// eslint-disable-next-line | ||
export class ExampleCrosshair extends React.Component { | ||
state = { | ||
crosshairValue: 2, | ||
}; | ||
_updateCrosshairLocation = crosshairValue => { | ||
this.setState({ crosshairValue }); | ||
}; | ||
render() { | ||
return ( | ||
<div> | ||
<EuiXYChart | ||
onCrosshairUpdate={this._updateCrosshairLocation} | ||
crosshairValue={this.state.crosshairValue} | ||
width={600} | ||
height={200} | ||
> | ||
<EuiBarSeries | ||
name="Users" | ||
data={[{ x: 0, y: 1 }, { x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: 1 }, { x: 5, y: 2 }]} | ||
/> | ||
</EuiXYChart> | ||
<EuiSpacer size="xl" /> | ||
<EuiXYChart | ||
onCrosshairUpdate={this._updateCrosshairLocation} | ||
crosshairValue={this.state.crosshairValue} | ||
width={600} | ||
height={200} | ||
> | ||
<EuiBarSeries | ||
name="Users" | ||
data={[{ x: 0, y: 1 }, { x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: 1 }, { x: 5, y: 2 }]} | ||
/> | ||
</EuiXYChart> | ||
</div> | ||
); | ||
} | ||
} |
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,5 @@ | ||
import React from 'react'; | ||
|
||
import { EuiXYChart } from '../../../../src/components'; | ||
|
||
export default () => <EuiXYChart width={600} height={200} statusText="Missing data"/>; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
EuiXYChart, | ||
EuiAreaSeries, | ||
EuiLineSeries, | ||
EuiXYChartUtils, | ||
} from '../../../../src/components'; | ||
const { ORIENTATION } = EuiXYChartUtils; | ||
|
||
const data = new Array(80).fill(0).map((d, i) => { | ||
const data = { | ||
y: i, | ||
y0: i, | ||
x: Number((Math.random() * 4 +4).toFixed(2)), | ||
x0: 0, | ||
} | ||
return data | ||
}); | ||
|
||
export default function() { | ||
return ( | ||
<EuiXYChart | ||
width={600} | ||
height={600} | ||
orientation={ORIENTATION.HORIZONTAL} | ||
animateData={false} | ||
> | ||
<EuiAreaSeries | ||
name="Quitters" | ||
data={data} | ||
/> | ||
<EuiLineSeries | ||
name="Quitters" | ||
data={data} | ||
/> | ||
</EuiXYChart> | ||
); | ||
}; |
Oops, something went wrong.