diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-08-04 17:53:08 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-08-10 17:11:54 +0200 |
commit | cc871d7b8c4af1f66234830719d27e45d4136334 (patch) | |
tree | 4a0e191441ba2fcd706853a74d6288436640bc85 /server/sonar-web/src/main/js/apps/overview/helpers/donut.jsx | |
parent | a3df8c53bec6e8e61cac61a41c8e7489b5bfb098 (diff) | |
download | sonarqube-cc871d7b8c4af1f66234830719d27e45d4136334.tar.gz sonarqube-cc871d7b8c4af1f66234830719d27e45d4136334.zip |
SONAR-6331 add project overview
Diffstat (limited to 'server/sonar-web/src/main/js/apps/overview/helpers/donut.jsx')
-rw-r--r-- | server/sonar-web/src/main/js/apps/overview/helpers/donut.jsx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/apps/overview/helpers/donut.jsx b/server/sonar-web/src/main/js/apps/overview/helpers/donut.jsx new file mode 100644 index 00000000000..58ba8a36736 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/overview/helpers/donut.jsx @@ -0,0 +1,41 @@ +import React from 'react'; + +const Sector = React.createClass({ + render() { + const arc = d3.svg.arc() + .outerRadius(this.props.radius) + .innerRadius(this.props.radius - this.props.thickness); + return <path d={arc(this.props.data)} style={{ fill: this.props.fill }}></path>; + } +}); + +export default React.createClass({ + getDefaultProps() { + return { + size: 30, + thickness: 6 + }; + }, + + render() { + const radius = this.props.size / 2; + const pie = d3.layout.pie().sort(null) + .value(d => { + return d.value + }); + const data = this.props.data; + const sectors = pie(data).map((d, i) => { + return <Sector + key={i} + data={d} + fill={data[i].fill} + radius={radius} + thickness={this.props.thickness}/>; + }); + return ( + <svg width={this.props.size} height={this.props.size}> + <g transform={`translate(${radius}, ${radius})`}>{sectors}</g> + </svg> + ); + } +}); |