react-vis
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -104,13 +104,13 @@ 'use strict'; | ||
var _index = require('./treemap/index'); | ||
var _treemap = require('./treemap'); | ||
var _index2 = _interopRequireDefault(_index); | ||
var _treemap2 = _interopRequireDefault(_treemap); | ||
var _index3 = require('./radial-chart/index'); | ||
var _radialChart = require('./radial-chart'); | ||
var _index4 = _interopRequireDefault(_index3); | ||
var _radialChart2 = _interopRequireDefault(_radialChart); | ||
var _index5 = require('./sankey/index'); | ||
var _sankey = require('./sankey'); | ||
var _index6 = _interopRequireDefault(_index5); | ||
var _sankey2 = _interopRequireDefault(_sankey); | ||
@@ -174,7 +174,7 @@ var _makeVisFlexible = require('./make-vis-flexible'); | ||
exports.ContinuousSizeLegend = _continuousSizeLegend2.default; | ||
exports.Treemap = _index2.default; | ||
exports.RadialChart = _index4.default; | ||
exports.Sankey = _index6.default; | ||
exports.Treemap = _treemap2.default; | ||
exports.RadialChart = _radialChart2.default; | ||
exports.Sankey = _sankey2.default; | ||
exports.makeWidthFlexible = _makeVisFlexible2.default; | ||
exports.AxisUtils = _axisUtils2.default; | ||
exports.ScaleUtils = _scalesUtils2.default; |
@@ -186,2 +186,4 @@ 'use strict'; | ||
var props = _extends({}, this.props, { animation: width === 0 ? null : this.props.animation }); | ||
return _react2.default.createElement( | ||
@@ -193,3 +195,3 @@ 'div', | ||
width: width | ||
}, this.props)) | ||
}, props)) | ||
); | ||
@@ -196,0 +198,0 @@ } |
@@ -65,7 +65,8 @@ 'use strict'; | ||
_createClass(BarSeries, [{ | ||
key: '_getScackParams', | ||
value: function _getScackParams() { | ||
key: '_getStackParams', | ||
value: function _getStackParams() { | ||
var _props = this.props, | ||
_stackBy = _props._stackBy, | ||
valuePosAttr = _props.valuePosAttr; | ||
valuePosAttr = _props.valuePosAttr, | ||
cluster = _props.cluster; | ||
var _props2 = this.props, | ||
@@ -77,3 +78,6 @@ _props2$sameTypeTotal = _props2.sameTypeTotal, | ||
if (_stackBy === valuePosAttr) { | ||
// If bars are stacked, but not clustering, override `sameTypeTotal` and | ||
// `sameTypeIndex` such that bars are stacked and not staggered. | ||
if (_stackBy === valuePosAttr && !cluster) { | ||
sameTypeTotal = 1; | ||
@@ -113,5 +117,5 @@ sameTypeIndex = 0; | ||
var _getScackParams2 = this._getScackParams(), | ||
sameTypeTotal = _getScackParams2.sameTypeTotal, | ||
sameTypeIndex = _getScackParams2.sameTypeIndex; | ||
var _getStackParams2 = this._getStackParams(), | ||
sameTypeTotal = _getStackParams2.sameTypeTotal, | ||
sameTypeIndex = _getStackParams2.sameTypeIndex; | ||
@@ -160,3 +164,4 @@ var distance = this._getScaleDistance(linePosAttr); | ||
lineSizeAttr: _react2.default.PropTypes.string, | ||
valueSizeAttr: _react2.default.PropTypes.string | ||
valueSizeAttr: _react2.default.PropTypes.string, | ||
cluster: _react2.default.PropTypes.string | ||
}); | ||
@@ -163,0 +168,0 @@ } |
@@ -134,4 +134,6 @@ 'use strict'; | ||
HeatmapSeries.propTypes = _extends({}, _abstractSeries2.default.propTypes); | ||
HeatmapSeries.displayName = 'HeatmapSeries'; | ||
exports.default = HeatmapSeries; |
@@ -7,4 +7,2 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
@@ -497,6 +495,7 @@ | ||
if (domain.length > 1) { | ||
scaleObject.distance = scaleFn(domain[1]) - scaleFn(domain[0]); | ||
scaleObject.distance = Math.abs(scaleFn(domain[1]) - scaleFn(domain[0])); | ||
} else { | ||
scaleObject.distance = range[1] - range[0]; | ||
scaleObject.distance = Math.abs(range[1] - range[0]); | ||
} | ||
return scaleObject; | ||
@@ -571,12 +570,6 @@ } | ||
if (scaleObject) { | ||
var _ret = function () { | ||
var scaleFn = _getScaleFnFromScaleObject(scaleObject); | ||
return { | ||
v: function v(d) { | ||
return scaleFn(_getAttrValue(d, attr)); | ||
} | ||
}; | ||
}(); | ||
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; | ||
var scaleFn = _getScaleFnFromScaleObject(scaleObject); | ||
return function (d) { | ||
return scaleFn(_getAttrValue(d, attr)); | ||
}; | ||
} | ||
@@ -597,18 +590,12 @@ return null; | ||
if (scaleObject) { | ||
var _ret2 = function () { | ||
var attr0 = attr + '0'; | ||
var domain = scaleObject.domain; | ||
var _scaleObject$baseValu = scaleObject.baseValue, | ||
baseValue = _scaleObject$baseValu === undefined ? domain[0] : _scaleObject$baseValu; | ||
var attr0 = attr + '0'; | ||
var domain = scaleObject.domain; | ||
var _scaleObject$baseValu = scaleObject.baseValue, | ||
baseValue = _scaleObject$baseValu === undefined ? domain[0] : _scaleObject$baseValu; | ||
var scaleFn = _getScaleFnFromScaleObject(scaleObject); | ||
return { | ||
v: function v(d) { | ||
var value = _getAttrValue(d, attr0); | ||
return scaleFn(_isDefined(value) ? value : baseValue); | ||
} | ||
}; | ||
}(); | ||
if ((typeof _ret2 === 'undefined' ? 'undefined' : _typeof(_ret2)) === "object") return _ret2.v; | ||
var scaleFn = _getScaleFnFromScaleObject(scaleObject); | ||
return function (d) { | ||
var value = _getAttrValue(d, attr0); | ||
return scaleFn(_isDefined(value) ? value : baseValue); | ||
}; | ||
} | ||
@@ -615,0 +602,0 @@ return null; |
@@ -79,2 +79,3 @@ 'use strict'; | ||
var displayName = child.type.displayName; | ||
var cluster = child.props.cluster; | ||
@@ -84,5 +85,7 @@ if (!result[displayName]) { | ||
sameTypeTotal: 0, | ||
sameTypeIndex: 0 | ||
sameTypeIndex: 0, | ||
clusters: new Set() | ||
}; | ||
} | ||
result[displayName].clusters.add(cluster); | ||
result[displayName].sameTypeTotal++; | ||
@@ -100,36 +103,44 @@ }); | ||
* @param {Array} children Array of children. | ||
* @param {string} attr Attribute. | ||
* @param {string} attr Attribute to stack by. | ||
* @returns {Array} New array of children for the series. | ||
*/ | ||
function getStackedData(children, attr) { | ||
var childData = []; | ||
var prevIndex = -1; | ||
children.forEach(function (child, childIndex) { | ||
return children.reduce(function (accumulator, series, seriesIndex) { | ||
// Skip the children that are not series (e.g. don't have any data). | ||
if (!child) { | ||
childData.push(null); | ||
return; | ||
if (!series) { | ||
accumulator.result.push(null); | ||
return accumulator; | ||
} | ||
var data = child.props.data; | ||
var _series$props = series.props, | ||
data = _series$props.data, | ||
_series$props$cluster = _series$props.cluster, | ||
cluster = _series$props$cluster === undefined ? 'default' : _series$props$cluster; | ||
if (!attr || !data || !data.length) { | ||
childData.push(data); | ||
return; | ||
accumulator.result.push(data); | ||
return accumulator; | ||
} | ||
var attr0 = attr + '0'; | ||
childData.push(data.map(function (d, dIndex) { | ||
accumulator.result.push(data.map(function (d, dIndex) { | ||
var _extends2; | ||
// In case if it's the first series don't try to override any values. | ||
if (prevIndex < 0) { | ||
if (!accumulator.seriesPointers[cluster]) { | ||
return _extends({}, d); | ||
} | ||
// In case if the series is not the first, try to get the attr0 values | ||
// from the previous series. | ||
var prevD = childData[prevIndex][dIndex]; | ||
// get the previous series in this cluster | ||
var prevSeries = accumulator.seriesPointers[cluster].slice().pop(); | ||
// get the previous data point in that series | ||
var prevD = accumulator.result[prevSeries][dIndex]; | ||
return _extends({}, d, (_extends2 = {}, _defineProperty(_extends2, attr0, prevD[attr]), _defineProperty(_extends2, attr, prevD[attr] + d[attr] - (d[attr0] || 0)), _extends2)); | ||
})); | ||
prevIndex = childIndex; | ||
}); | ||
return childData; | ||
accumulator.seriesPointers[cluster] = (accumulator.seriesPointers[cluster] || []).concat([seriesIndex]); | ||
return accumulator; | ||
}, { | ||
result: [], | ||
seriesPointers: {} | ||
}).result; | ||
} | ||
@@ -161,2 +172,9 @@ | ||
seriesIndex++; | ||
if (child.props.cluster) { | ||
props.cluster = child.props.cluster; | ||
// Using Array.from() so we can use .indexOf | ||
props.clusters = Array.from(seriesTypeInfo.clusters); | ||
props.sameTypeTotal = props.clusters.length; | ||
props.sameTypeIndex = props.clusters.indexOf(child.props.cluster); | ||
} | ||
} | ||
@@ -163,0 +181,0 @@ result.push(props); |
{ | ||
"name": "react-vis", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"license": "MIT", | ||
@@ -21,6 +21,7 @@ "author": "Visualization Team <visualization@uber.com>", | ||
"docs": "(cd showcase && npm run build && cp bundle.* .. && cd .. && git checkout gh-pages && git commit -am 'Upgrade docs' && git push && git checkout master)", | ||
"new-docs": "./deploy-docs.sh", | ||
"start": "(cd showcase && command -v yarn >/dev/null && yarn && npm start || npm install && npm start)", | ||
"clean": "rm -rf dist bundle.* index.html && mkdir dist", | ||
"build": "npm run clean && babel src -d dist --copy-files && node-sass src/main.scss dist/style.css --output-style compressed", | ||
"lint": "eslint src tests showcase --ignore-pattern node_modules --ignore-pattern bundle.js", | ||
"lint": "eslint src tests showcase docs --ignore-pattern node_modules --ignore-pattern bundle.js", | ||
"lint-styles": "stylelint src/styles/*.scss --syntax scss", | ||
@@ -27,0 +28,0 @@ "test": "babel-node tests/index.js", |
@@ -23,3 +23,3 @@ <p align="right"> | ||
![demo](docs/assets/react-vis.gif?raw=true) | ||
![demo](docs/markdown/assets/react-vis.gif?raw=true) | ||
@@ -99,9 +99,10 @@ ## Overview | ||
- Common concepts: | ||
* [Scales and Data](docs/scales-and-data.md) about how the attributes can be adjusted. | ||
* [Animations](docs/animation.md) about how to tweak animations in the library. | ||
* [Scales and Data](docs/markdown/scales-and-data.md) about how the attributes can be adjusted. | ||
* [Animations](docs/markdown/animation.md) about how to tweak animations in the library. | ||
- Components: | ||
* [XYPlot](docs/xy-plot.md) about orthogonal charts. | ||
* [RadialChart](docs/radial-chart.md) about radial charts. | ||
* [Treemap](docs/treemap.md) about making tree maps. | ||
* [Legends](docs/legends.md) about the legends. | ||
* [XYPlot](docs/markdown/xy-plot.md) about orthogonal charts. | ||
* [RadialChart](docs/markdown/radial-chart.md) about radial charts. | ||
* [Treemap](docs/markdown/treemap.md) about making tree maps. | ||
* [Sankey](docs/markdown/sankey.md) about making sankey diagrams. | ||
* [Legends](docs/markdown/legends.md) about the legends. | ||
@@ -108,0 +109,0 @@ ## Development |
Sorry, the diff of this file is not supported yet
314946
6029
119