react-d3-core
Advanced tools
Comparing version 0.0.10 to 0.0.11
{ | ||
"name": "react-d3-core", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "react chart core component", | ||
@@ -5,0 +5,0 @@ "main": "./index.jsx", |
@@ -40,12 +40,31 @@ # react-d3-core | ||
- Chart | ||
- Axis | ||
- Xaxis | ||
- Yaxis | ||
- Label | ||
- Legend | ||
- Grid | ||
#### Container | ||
- [Chart](./docs/container.md) | ||
- [Svg](./docs/svg.md) | ||
- [Title](./docs/title.md) | ||
#### Axis | ||
- [Axis](./docs/axis.md) | ||
- [Xaxis](./docs/xaxis.md) | ||
- [Yaxis](./docs/yaxis.md) | ||
#### Grid | ||
- [xGrid](./docs/xgrid.md) | ||
- [yGrid](./docs/ygrid.md) | ||
#### Label | ||
- [Label](./docs/label.md) | ||
#### Legend | ||
- [Legend](./docs/legend.md) | ||
## License | ||
Apache 2.0 |
@@ -6,2 +6,3 @@ "use strict"; | ||
Component, | ||
PropTypes | ||
} from 'react'; | ||
@@ -15,3 +16,14 @@ | ||
this.state = { | ||
domain: this.props.domain | ||
scaleSet: this.props.scale, | ||
domainSet: this.props.domain, | ||
rangeSet: this.props.range, | ||
rangeRoundBandsSet: this.props.rangeRoundBandsSet, | ||
showAxisSet: this.props.showAxis, | ||
typeSet: this.props.type, | ||
tickOrientSet: this.props.tickOrient, | ||
tickFormatSet: this.props.tickFormat, | ||
tickPaddingSet: this.props.tickPadding, | ||
innerTickSizeSet: this.props.innerTickSize, | ||
outerTickSizeSet: this.props.outerTickSize, | ||
ticksSet: this.props.ticks, | ||
} | ||
@@ -29,2 +41,9 @@ } | ||
static PropTypes = { | ||
showAxis: PropTypes.bool, | ||
type: PropTypes.string, | ||
orient: PropTypes.oneOf(['top', 'bottom', 'left', 'right']), | ||
tickOrient: PropTypes.oneOf(['top', 'bottom', 'left', 'right']), | ||
} | ||
componentDidMount() { | ||
@@ -34,4 +53,21 @@ this._mkAxis(); | ||
componentWillReceiveProps(nextProps) { | ||
const { | ||
domain | ||
} = nextProps; | ||
// check when to rebuild axis and update states | ||
if(this.state.domainSet !== domain) { | ||
this.setState({ | ||
domainSet: domain | ||
}); | ||
this._mkAxis(); | ||
} | ||
} | ||
_mkAxis() { | ||
const {showAxis, type} = this.props; | ||
const { | ||
showAxis, | ||
type | ||
} = this.props; | ||
@@ -57,3 +93,2 @@ var axisDom = d3.select(React.findDOMNode(this.refs.axisGroup)) | ||
type, | ||
orient, | ||
tickOrient, | ||
@@ -65,5 +100,2 @@ tickFormat, | ||
ticks, | ||
height, | ||
width, | ||
margins | ||
} = this.props; | ||
@@ -101,3 +133,2 @@ | ||
scale, | ||
newDomain | ||
} = this.props; | ||
@@ -167,18 +198,10 @@ | ||
componentWillReceiveProps(nextProps) { | ||
const { | ||
type, | ||
domain | ||
} = nextProps; | ||
if(this.state.domain !== domain) { | ||
this.setState({ | ||
domain: domain | ||
}); | ||
this._mkAxis(); | ||
} | ||
} | ||
render () { | ||
const {gridAxisClassName, axisClassName, t, type} = this.props; | ||
const { | ||
gridAxisClassName, | ||
axisClassName, | ||
type | ||
} = this.props; | ||
@@ -185,0 +208,0 @@ if(type === 'x') |
@@ -63,3 +63,2 @@ "use strict" | ||
xDomain, | ||
xDomainSet, | ||
xRange, | ||
@@ -116,3 +115,2 @@ xRangeRoundBands, | ||
domain = {xDomain} | ||
newDomain = {xDomainSet} | ||
range = {xRange} | ||
@@ -119,0 +117,0 @@ scale = {xScale} |
@@ -29,3 +29,2 @@ "use strict" | ||
yDomain, | ||
yDomainSet, | ||
yRange, | ||
@@ -83,3 +82,2 @@ yRangeRoundBands, | ||
domain = {yDomain} | ||
newDomain = {yDomainSet} | ||
range = {yRange} | ||
@@ -86,0 +84,0 @@ scale = {yScale} |
@@ -20,6 +20,2 @@ "use strict"; | ||
super(props); | ||
this.state = { | ||
xDomainSet: this.props.xDomain, | ||
yDomainSet: this.props.yDomain | ||
} | ||
} | ||
@@ -51,20 +47,3 @@ | ||
componentWillReceiveProps(nextProps) { | ||
const { | ||
xDomainSet, | ||
} = nextProps; | ||
// when xDomainSet is update, xScaleSet is not update yet. | ||
if(this.state.xDomainSet !== xDomainSet) { | ||
this.setState({ | ||
xDomainSet: xDomainSet | ||
}); | ||
} | ||
} | ||
render() { | ||
const { | ||
xDomainSet, | ||
yDomainSet | ||
} = this.state; | ||
@@ -112,4 +91,3 @@ const { | ||
proxy = {x} | ||
domain = {xDomainSet} | ||
newDomain = {xDomainSet} | ||
domain = {xDomain} | ||
range = {xRange} | ||
@@ -139,4 +117,3 @@ scale = {xScale} | ||
scale = {yScale} | ||
domain = {yDomainSet} | ||
newDomain = {yDomainSet} | ||
domain = {yDomain} | ||
range = {yRange} | ||
@@ -143,0 +120,0 @@ /> |
@@ -61,5 +61,6 @@ | ||
entry: { | ||
blankchart: './example/src/components.jsx', | ||
blank_chart: './example/src/components.jsx', | ||
legend: './example/src/legend.jsx', | ||
container: './example/src/container.jsx', | ||
container_update: './example/src/container_update.jsx', | ||
grid: './example/src/grid.jsx', | ||
@@ -66,0 +67,0 @@ label: './example/src/label.jsx', |
Sorry, the diff of this file is too big to display
4292789
32
30922
70