react-d3-core
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -13,2 +13,4 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
@@ -34,6 +36,8 @@ | ||
this.state = { | ||
widthSet: this.props.width, | ||
heightSet: this.props.height, | ||
scaleSet: this.props.scale, | ||
domainSet: this.props.domain, | ||
rangeSet: this.props.range, | ||
rangeRoundBandsSet: this.props.rangeRoundBandsSet, | ||
rangeRoundBandsSet: this.props.rangeRoundBands, | ||
showAxisSet: this.props.showAxis, | ||
@@ -58,11 +62,14 @@ typeSet: this.props.type, | ||
value: function componentWillReceiveProps(nextProps) { | ||
var domain = nextProps.domain; | ||
var _this = this; | ||
// check when to rebuild axis and update states | ||
if (this.state.domainSet !== domain) { | ||
this.setState({ | ||
domainSet: domain | ||
}); | ||
this._mkAxis(); | ||
} | ||
var keys = Object.keys(this.state); | ||
keys.forEach(function (k) { | ||
var kn = k.slice(0, -3); | ||
if (_this.state[k] !== nextProps[kn]) { | ||
_this.setState(_defineProperty({}, k, kn)); | ||
_this._mkAxis(); | ||
} | ||
}); | ||
} | ||
@@ -69,0 +76,0 @@ }, { |
@@ -13,2 +13,4 @@ "use strict"; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
@@ -33,2 +35,13 @@ | ||
_get(Object.getPrototypeOf(Label.prototype), 'constructor', this).call(this, props); | ||
this.state = { | ||
widthSet: this.props.width, | ||
heightSet: this.props.height, | ||
marginsSet: this.props.margins, | ||
labelOffsetSet: this.props.labelOffset, | ||
labelTitleSet: this.props.labelTitle, | ||
labelPositionSet: this.props.labelPosition, | ||
vTransformSet: this.props.vTransform, | ||
hTransformSet: this.props.hTransform, | ||
textAnchor: this.props.textAnchor | ||
}; | ||
} | ||
@@ -39,2 +52,23 @@ | ||
value: function componentDidMount() { | ||
this._mkLabel(); | ||
} | ||
}, { | ||
key: 'componentWillReceiveProps', | ||
value: function componentWillReceiveProps(nextProps) { | ||
var _this = this; | ||
// check when to rebuild label and update states | ||
var keys = Object.keys(this.state); | ||
keys.forEach(function (k) { | ||
var kn = k.slice(0, -3); | ||
if (_this.state[k] !== nextProps[kn]) { | ||
_this.setState(_defineProperty({}, k, kn)); | ||
_this._mkLabel(); | ||
} | ||
}); | ||
} | ||
}, { | ||
key: '_mkLabel', | ||
value: function _mkLabel() { | ||
var _props = this.props; | ||
@@ -41,0 +75,0 @@ var height = _props.height; |
{ | ||
"name": "react-d3-core", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "react chart core component", | ||
@@ -8,3 +8,3 @@ "main": "./lib/index.js", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"es5": "rm -rf ./lib && babel --stage 0 src --out-dir lib" | ||
"es5": "rm -rf ./lib && babel -w --stage 0 src --out-dir lib" | ||
}, | ||
@@ -17,2 +17,3 @@ "author": "ElixirDoc team", | ||
"css-loader": "^0.18.0", | ||
"dsv-loader": "^1.0.0", | ||
"json-loader": "^0.5.3", | ||
@@ -19,0 +20,0 @@ "jsx-loader": "^0.13.2", |
@@ -19,6 +19,8 @@ "use strict"; | ||
this.state = { | ||
widthSet: this.props.width, | ||
heightSet: this.props.height, | ||
scaleSet: this.props.scale, | ||
domainSet: this.props.domain, | ||
rangeSet: this.props.range, | ||
rangeRoundBandsSet: this.props.rangeRoundBandsSet, | ||
rangeRoundBandsSet: this.props.rangeRoundBands, | ||
showAxisSet: this.props.showAxis, | ||
@@ -56,13 +58,14 @@ typeSet: this.props.type, | ||
componentWillReceiveProps(nextProps) { | ||
const { | ||
domain | ||
} = nextProps; | ||
// check when to rebuild axis and update states | ||
const keys = Object.keys(this.state); | ||
// check when to rebuild axis and update states | ||
if(this.state.domainSet !== domain) { | ||
this.setState({ | ||
domainSet: domain | ||
}); | ||
this._mkAxis(); | ||
} | ||
keys.forEach((k) => { | ||
var kn = k.slice(0,-3); | ||
if(this.state[k] !== nextProps[kn]) { | ||
this.setState({ | ||
[k]: kn | ||
}); | ||
this._mkAxis(); | ||
} | ||
}) | ||
} | ||
@@ -69,0 +72,0 @@ |
@@ -16,2 +16,13 @@ "use strict"; | ||
super(props); | ||
this.state = { | ||
widthSet: this.props.width, | ||
heightSet: this.props.height, | ||
marginsSet: this.props.margins, | ||
labelOffsetSet: this.props.labelOffset, | ||
labelTitleSet: this.props.labelTitle, | ||
labelPositionSet: this.props.labelPosition, | ||
vTransformSet: this.props.vTransform, | ||
hTransformSet: this.props.hTransform, | ||
textAnchor: this.props.textAnchor | ||
} | ||
} | ||
@@ -43,2 +54,21 @@ | ||
componentDidMount () { | ||
this._mkLabel(); | ||
} | ||
componentWillReceiveProps(nextProps) { | ||
// check when to rebuild label and update states | ||
const keys = Object.keys(this.state); | ||
keys.forEach((k) => { | ||
var kn = k.slice(0,-3); | ||
if(this.state[k] !== nextProps[kn]) { | ||
this.setState({ | ||
[k]: kn | ||
}); | ||
this._mkLabel(); | ||
} | ||
}) | ||
} | ||
_mkLabel() { | ||
const { | ||
@@ -93,4 +123,2 @@ height, | ||
} | ||
} | ||
@@ -97,0 +125,0 @@ |
@@ -48,4 +48,4 @@ import { | ||
export {Grid as Grid}; | ||
export {Axis as Axis} | ||
export {Label as Label} | ||
export {Axis as Axis}; | ||
export {Label as Label}; | ||
export {scale as scale}; |
@@ -64,3 +64,4 @@ | ||
entry: { | ||
xaxis: './example/src_es5/xaxis.jsx' | ||
xaxis: './example/src_es5/xaxis.jsx', | ||
xaxis_click: './example/src_es5/xaxis_click.jsx' | ||
}, | ||
@@ -67,0 +68,0 @@ |
4348667
975
32064
10