-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a breakdown by ticket type and project to the completed heatmap
- Loading branch information
1 parent
5234e0e
commit fc5034e
Showing
6 changed files
with
210 additions
and
58 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
This file was deleted.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
ui/src/components/Charts/Nivo/RoadmapTooltip/DataBreakdown.tsx
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,78 @@ | ||
import React, { Component } from 'react'; // let's also import Component | ||
import { Theme, createStyles, withStyles } from '@material-ui/core/styles'; | ||
import Chart from 'chart.js'; | ||
import randomColor from 'randomcolor'; | ||
import ChartDataLabels from 'chartjs-plugin-datalabels'; | ||
|
||
const styles = (theme: Theme) => | ||
createStyles({ | ||
root: { | ||
// height: 200 | ||
} | ||
}); | ||
|
||
class DataBreakdown extends Component<any, any> { | ||
chartRef: any = React.createRef(); | ||
chart: any = {}; | ||
allowClick: boolean = true; | ||
|
||
componentDidMount() { | ||
this.buildChart(); | ||
} | ||
|
||
componentDidUpdate() { | ||
this.buildChart(); | ||
} | ||
|
||
resetAllowClick = () => { | ||
this.allowClick = true; | ||
}; | ||
|
||
buildChart = () => { | ||
const { dataset, defaultPoints } = this.props; | ||
const myChartRef = this.chartRef.current.getContext('2d'); | ||
let metric = 'points'; | ||
if (!defaultPoints) { | ||
metric = 'issues'; | ||
} | ||
|
||
if (this.chart.destroy !== undefined) { | ||
this.chart.destroy(); | ||
} | ||
this.chart = new Chart(myChartRef, { | ||
type: 'pie', | ||
plugins: [ChartDataLabels], | ||
data: { | ||
datasets: [ | ||
{ | ||
data: dataset.map((value: any) => value[metric].count), | ||
backgroundColor: dataset.map((value: any) => | ||
randomColor({ seed: value.name }) | ||
) | ||
} | ||
], | ||
labels: dataset.map((value: any) => value.name) | ||
}, | ||
options: { | ||
responsive: true, | ||
legend: { | ||
position: 'left' | ||
}, | ||
animation: { | ||
animateRotate: false | ||
} | ||
} | ||
}); | ||
}; | ||
|
||
render() { | ||
const { classes } = this.props; | ||
return ( | ||
<div className={classes.root}> | ||
<canvas id='myChart' ref={this.chartRef} height='200' /> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default withStyles(styles)(DataBreakdown); |
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,123 @@ | ||
import React from 'react'; | ||
import Grid from '@material-ui/core/Grid'; | ||
import _ from 'lodash'; | ||
|
||
import { getCellDataInitiatives } from '../utils'; | ||
|
||
import Table from '@material-ui/core/Table'; | ||
import TableBody from '@material-ui/core/TableBody'; | ||
import TableCell from '@material-ui/core/TableCell'; | ||
import TableHead from '@material-ui/core/TableHead'; | ||
import TableRow from '@material-ui/core/TableRow'; | ||
import Typography from '@material-ui/core/Typography'; | ||
|
||
import DataBreakdown from './DataBreakdown'; | ||
|
||
export interface TooltipProps { | ||
data: any; | ||
roadmap: any; | ||
completionWeeks: any; | ||
defaultPoints: boolean; | ||
} | ||
|
||
export default function RoadmapTooltip(props: TooltipProps) { | ||
const { data, roadmap, completionWeeks, defaultPoints } = props; | ||
const initiatives = getCellDataInitiatives( | ||
data.yKey, | ||
data.xKey, | ||
roadmap, | ||
completionWeeks | ||
); | ||
|
||
const typesGroup = _.groupBy(initiatives, (value: any) => { | ||
if (value.fields.issuetype !== undefined) { | ||
return value.fields.issuetype.name; | ||
} else { | ||
return null; | ||
} | ||
}); | ||
|
||
const types: any = []; | ||
Object.keys(typesGroup).forEach((key: any) => { | ||
types.push({ | ||
name: key, | ||
list: typesGroup[key], | ||
issues: { | ||
count: typesGroup[key].length | ||
}, | ||
points: { | ||
count: typesGroup[key] | ||
.map(issue => issue.points) | ||
.reduce((acc, count) => acc + count, 0) | ||
} | ||
}); | ||
}); | ||
|
||
const projectsGroup = _.groupBy(initiatives, value => | ||
value.key.replace(/[^a-z+]+/gi, '') | ||
); | ||
const projects: any = []; | ||
Object.keys(projectsGroup).forEach((key: any) => { | ||
projects.push({ | ||
name: key, | ||
list: projectsGroup[key], | ||
issues: { | ||
count: projectsGroup[key].length | ||
}, | ||
points: { | ||
count: projectsGroup[key] | ||
.map((issue: any) => { | ||
return issue.points; | ||
}) | ||
.reduce((acc: number, count: number) => acc + count, 0) | ||
} | ||
}); | ||
}); | ||
return ( | ||
<React.Fragment> | ||
<Table size='small'> | ||
<TableHead> | ||
<TableRow> | ||
<TableCell>Key</TableCell> | ||
<TableCell align='right'>Summary</TableCell> | ||
<TableCell align='right'>Points</TableCell> | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{initiatives.slice(0, 5).map((i: any) => ( | ||
<TableRow key={i.key}> | ||
<TableCell component='th' scope='row'> | ||
{i.key} | ||
</TableCell> | ||
<TableCell align='right'>{i.fields.summary}</TableCell> | ||
<TableCell align='right'>{i.points}</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
{initiatives.length > 5 && ( | ||
<span> | ||
<b>Caution:</b>{' '} | ||
<i> | ||
This table only displays the first 5 results (out of{' '} | ||
{initiatives.length}). | ||
</i> | ||
</span> | ||
)} | ||
<Grid container direction='row' justify='center' alignItems='center'> | ||
<Grid item xs={6}> | ||
<Typography variant='h6' component='h6'> | ||
Projects | ||
</Typography> | ||
<DataBreakdown dataset={projects} defaultPoints={defaultPoints} /> | ||
</Grid> | ||
<Grid item xs={6}> | ||
<Typography variant='h6' component='h6'> | ||
Types | ||
</Typography> | ||
<DataBreakdown dataset={types} defaultPoints={defaultPoints} /> | ||
</Grid> | ||
</Grid> | ||
</React.Fragment> | ||
); | ||
} |