-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathchartpie.jsx
73 lines (62 loc) · 1.25 KB
/
chartpie.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"use strict";
import {
default as React,
Component,
PropTypes,
} from 'react';
import {
scale,
xDomainCount,
yDomainCount
} from 'react-d3-core';
import CommonProps from './commonProps';
export default class ChartSvg extends Component {
constructor(props) {
super (props);
}
static defaultProps = {
svgClassName: 'react-d3-core__container_svg',
...CommonProps
}
static propTypes = {
id: PropTypes.string,
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
margins: PropTypes.object.isRequired,
svgClassName: PropTypes.string.isRequired,
}
render() {
var {
height,
width,
margins,
data,
svgClassName,
id,
name,
value
} = this.props;
var children = React.Children.map(this.props.children, (el) => {
if(el)
return React.cloneElement(el, this.props)
else
return null
});
var t = `translate(${margins.left}, ${margins.top})`;
return (
<svg
height = {height}
width = {width}
className = {svgClassName}
id = {id}
ref = "svgContainer"
>
<g
transform = {t}
>
{children}
</g>
</svg>
)
}
}