This repository has been archived by the owner on Apr 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd5a8e1
commit 9b998ca
Showing
5 changed files
with
163 additions
and
79 deletions.
There are no files selected for viewing
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,77 @@ | ||
import * as React from 'react'; | ||
import { StackedBarChart } from 'patternfly-react'; | ||
|
||
type InOutRateChartPropType = { | ||
percent2xxIn: number; | ||
percent3xxIn: number; | ||
percent4xxIn: number; | ||
percent5xxIn: number; | ||
percent2xxOut: number; | ||
percent3xxOut: number; | ||
percent4xxOut: number; | ||
percent5xxOut: number; | ||
width?: number; | ||
height?: number; | ||
showLegend?: boolean; | ||
legendPos?: string; // e.g. right, left | ||
}; | ||
|
||
export default class InOutRateChart extends React.Component<InOutRateChartPropType> { | ||
static defaultProps: InOutRateChartPropType = { | ||
percent2xxIn: 0, | ||
percent3xxIn: 0, | ||
percent4xxIn: 0, | ||
percent5xxIn: 0, | ||
percent2xxOut: 0, | ||
percent3xxOut: 0, | ||
percent4xxOut: 0, | ||
percent5xxOut: 0, | ||
height: 150, | ||
showLegend: true, | ||
legendPos: 'bottom' | ||
}; | ||
|
||
constructor(props: InOutRateChartPropType) { | ||
super(props); | ||
} | ||
|
||
render() { | ||
return ( | ||
<StackedBarChart | ||
size={{ height: this.props.height }} | ||
legend={{ show: this.props.showLegend, position: this.props.legendPos }} | ||
grid={{ | ||
x: { | ||
show: false | ||
}, | ||
y: { | ||
show: false | ||
} | ||
}} | ||
axis={{ | ||
rotated: true, | ||
x: { | ||
categories: ['In', 'Out'], | ||
type: 'category' | ||
} | ||
}} | ||
data={{ | ||
groups: [['OK', '3xx', '4xx', '5xx']], | ||
columns: [ | ||
['OK', this.props.percent2xxIn, this.props.percent2xxOut], | ||
['3xx', this.props.percent3xxIn, this.props.percent3xxOut], | ||
['4xx', this.props.percent4xxIn, this.props.percent4xxOut], | ||
['5xx', this.props.percent5xxIn, this.props.percent5xxOut] | ||
], | ||
// order: 'asc', | ||
colors: { | ||
'OK': '#0088ce', // pf-blue-400 | ||
'3xx': '#3f9c35', // pf-green-400 | ||
'4xx': '#ec7a08', // pf-orange-400 | ||
'5xx': '#cc0000' // pf-red-100 | ||
} | ||
}} | ||
/> | ||
); | ||
} | ||
} |
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,69 @@ | ||
import * as React from 'react'; | ||
import { StackedBarChart } from 'patternfly-react'; | ||
|
||
type RateChartPropType = { | ||
percent2xx: number; | ||
percent3xx: number; | ||
percent4xx: number; | ||
percent5xx: number; | ||
width?: number; | ||
height?: number; | ||
showLegend?: boolean; | ||
legendPos?: string; // e.g. right, left | ||
}; | ||
|
||
export default class RateChart extends React.Component<RateChartPropType> { | ||
static defaultProps: RateChartPropType = { | ||
percent2xx: 0, | ||
percent3xx: 0, | ||
percent4xx: 0, | ||
percent5xx: 0, | ||
height: 100, | ||
showLegend: true, | ||
legendPos: 'bottom' | ||
}; | ||
|
||
constructor(props: RateChartPropType) { | ||
super(props); | ||
} | ||
|
||
render() { | ||
return ( | ||
<StackedBarChart | ||
size={{ height: this.props.height }} | ||
legend={{ show: this.props.showLegend, position: this.props.legendPos }} | ||
grid={{ | ||
x: { | ||
show: false | ||
}, | ||
y: { | ||
show: false | ||
} | ||
}} | ||
axis={{ | ||
rotated: true, | ||
x: { | ||
categories: [''], | ||
type: 'category' | ||
} | ||
}} | ||
data={{ | ||
groups: [['OK', '3xx', '4xx', '5xx']], | ||
columns: [ | ||
['OK', this.props.percent2xx], | ||
['3xx', this.props.percent3xx], | ||
['4xx', this.props.percent4xx], | ||
['5xx', this.props.percent5xx] | ||
], | ||
// order: 'asc', | ||
colors: { | ||
'OK': '#0088ce', // pf-blue-400 | ||
'3xx': '#3f9c35', // pf-green-400 | ||
'4xx': '#ec7a08', // pf-orange-400 | ||
'5xx': '#cc0000' // pf-red-100 | ||
} | ||
}} | ||
/> | ||
); | ||
} | ||
} |
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