UNPKG

react-vis

Version:

Data visualization library based on React and d3.

520 lines (519 loc) 22.3 kB
<!doctype html> <html lang="en"> <head> <title>Code coverage report for dist/lib/make-vis-flexible.js</title> <meta charset="utf-8" /> <link rel="stylesheet" href="../../prettify.css" /> <link rel="stylesheet" href="../../base.css" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <style type='text/css'> .coverage-summary .sorter { background-image: url(../../sort-arrow-sprite.png); } </style> </head> <body> <div class='wrapper'> <div class='pad1'> <h1> <a href="../../index.html">all files</a> / <a href="index.html">dist/lib/</a> make-vis-flexible.js </h1> <div class='clearfix'> <div class='fl pad1y space-right2'> <span class="strong">25.56% </span> <span class="quiet">Statements</span> <span class='fraction'>23/90</span> </div> <div class='fl pad1y space-right2'> <span class="strong">24.07% </span> <span class="quiet">Branches</span> <span class='fraction'>13/54</span> </div> <div class='fl pad1y space-right2'> <span class="strong">19.05% </span> <span class="quiet">Functions</span> <span class='fraction'>4/21</span> </div> <div class='fl pad1y space-right2'> <span class="strong">36.73% </span> <span class="quiet">Lines</span> <span class='fraction'>18/49</span> </div> <div class='fl pad1y'> <span class="strong">2 statements, 2 functions, 6 branches</span> <span class="quiet">Ignored</span> &nbsp;&nbsp;&nbsp;&nbsp; </div> </div> </div> <div class='status-line low'></div> <pre><table class="coverage"> <tr><td class="line-count quiet">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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151</td><td class="line-coverage quiet"><span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-no">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">'use strict'; &nbsp; Object.defineProperty(exports, "__esModule", { value: true }); &nbsp; v</span>ar _extends = Object.assign || <span class="fstat-no" title="function not covered" ><span class="branch-1 cbranch-no" title="branch not covered" >function (target) {</span> for (<span class="cstat-no" title="statement not covered" >var i = 1; i &lt; arguments.length; i++) { var <span class="cstat-no" title="statement not covered" >source = arguments[i]; <span class="cstat-no" title="statement not covered" >f</span>or (var key in source) { if (<span class="cstat-no" title="statement not covered" >Object.prototype.hasOwnProperty.call(source, key)) { target[<span class="cstat-no" title="statement not covered" >key] = source[key]; } } } <span class="cstat-no" title="statement not covered" >r</span>eturn target; };</span></span></span></span> &nbsp; var _createClass = function () { function <span class="fstat-no" title="function not covered" >defineProperties(target, props) {</span> for (<span class="cstat-no" title="statement not covered" >var i = 0; i &lt; props.length; i++) { var <span class="cstat-no" title="statement not covered" >descriptor = props[i]; <span class="cstat-no" title="statement not covered" >d</span>escriptor.enumerable = descriptor.enumerable || false; <span class="cstat-no" title="statement not covered" >d</span>escriptor.configurable = true; <span class="cstat-no" title="statement not covered" >i</span>f ("value" in descriptor) <span class="cstat-no" title="statement not covered" >descriptor.writable = true; <span class="cstat-no" title="statement not covered" >O</span></span>bject.defineProperty(target, descriptor.key, descriptor); } } return <span class="fstat-no" title="function not covered" >function (Constructor, protoProps, staticProps) {</span> if (<span class="cstat-no" title="statement not covered" >protoProps) <span class="cstat-no" title="statement not covered" >defineProperties(Constructor.prototype, protoProps); <span class="cstat-no" title="statement not covered" >i</span></span>f (staticProps) <span class="cstat-no" title="statement not covered" >defineProperties(Constructor, staticProps); <span class="cstat-no" title="statement not covered" >r</span></span>eturn Constructor; }; }();</span></span></span> &nbsp; exports.default = makeVisFlexible; &nbsp; var _react = require('react'); &nbsp; var _react2 = _interopRequireDefault(_react); &nbsp; var _reactUtils = require('./utils/react-utils'); &nbsp; var _window = require('global/window'); &nbsp; var _window2 = _interopRequireDefault(_window); &nbsp; function _interopRequireDefault(obj) { return o</span>bj &amp;&amp; obj.__esModule ? <span class="branch-0 cbranch-no" title="branch not covered" >obj : { default: obj }; } &nbsp; <span class="fstat-no" title="function not covered" >function _objectWithoutProperties(obj, keys) {</span> var <span class="cstat-no" title="statement not covered" >target = {}; <span class="cstat-no" title="statement not covered" >f</span>or (var i in obj) { if (<span class="cstat-no" title="statement not covered" >keys.indexOf(i) &gt;= 0) <span class="cstat-no" title="statement not covered" >continue; <span class="cstat-no" title="statement not covered" >i</span></span>f (!Object.prototype.hasOwnProperty.call(obj, i)) <span class="cstat-no" title="statement not covered" >continue; <span class="cstat-no" title="statement not covered" >t</span></span>arget[i] = obj[i]; } <span class="cstat-no" title="statement not covered" >r</span>eturn target; }</span></span> &nbsp; <span class="fstat-no" title="function not covered" >function _classCallCheck(instance, Constructor) {</span> if (<span class="cstat-no" title="statement not covered" >!(instance instanceof Constructor)) { throw <span class="cstat-no" title="statement not covered" >new TypeError("Cannot call a class as a function"); } }</span></span> &nbsp; <span class="fstat-no" title="function not covered" >function _possibleConstructorReturn(self, call) {</span> if (<span class="cstat-no" title="statement not covered" >!self) { throw <span class="cstat-no" title="statement not covered" >new ReferenceError("this hasn't been initialised - super() hasn't been called"); } <span class="cstat-no" title="statement not covered" >r</span>eturn call &amp;&amp; (typeof call === "object" || typeof call === "function") ? call : self; }</span></span> &nbsp; <span class="fstat-no" title="function not covered" >function _inherits(subClass, superClass) {</span> if (<span class="cstat-no" title="statement not covered" >typeof superClass !== "function" &amp;&amp; superClass !== null) { throw <span class="cstat-no" title="statement not covered" >new TypeError("Super expression must either be null or a function, not " + typeof superClass); } <span class="cstat-no" title="statement not covered" >s</span>ubClass.prototype = Object.create(superClass &amp;&amp; superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); <span class="cstat-no" title="statement not covered" >i</span>f (superClass) <span class="cstat-no" title="statement not covered" >Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Copyright (c) 2016 Uber Technologies, Inc.</span></span></span> // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. &nbsp; var CONTAINER_REF = 'container'; &nbsp; /** * Add the ability to stretch the visualization on window resize. * @param {*} Component React class for the child component. * @returns {*} Flexible component. */ <span class="fstat-no" title="function not covered" >function makeVisFlexible(Component) {</span> &nbsp; var <span class="cstat-no" title="statement not covered" >ResultClass = <span class="fstat-no" title="function not covered" >function (_React$Component) {</span></span> _inherits(<span class="cstat-no" title="statement not covered" >ResultClass, _React$Component);</span> &nbsp; _createClass(<span class="cstat-no" title="statement not covered" >ResultClass, null, [{</span> key: 'propTypes', get: <span class="fstat-no" title="function not covered" >function get() {</span> var <span class="cstat-no" title="statement not covered" >_Component$propTypes = Component.propTypes;</span> var <span class="cstat-no" title="statement not covered" >width = _Component$propTypes.width;</span> &nbsp; var <span class="cstat-no" title="statement not covered" >otherPropTypes = _objectWithoutProperties(_Component$propTypes, ['width']);</span> &nbsp; return <span class="cstat-no" title="statement not covered" >otherPropTypes;</span> } }]); &nbsp; function <span class="fstat-no" title="function not covered" >ResultClass(props) {</span> _classCallCheck(<span class="cstat-no" title="statement not covered" >this, ResultClass);</span> &nbsp; var <span class="cstat-no" title="statement not covered" >_this = _possibleConstructorReturn(this, Object.getPrototypeOf(ResultClass).call(this, props));</span> &nbsp; _this.<span class="cstat-no" title="statement not covered" >state = {</span> width: 0 }; _this.<span class="cstat-no" title="statement not covered" >_resizeTimeout = null;</span> _this.<span class="cstat-no" title="statement not covered" >_onResize = _this._onResize.bind(_this);</span> _this.<span class="cstat-no" title="statement not covered" >_onResizeDebounced = _this._onResizeDebounced.bind(_this);</span> return <span class="cstat-no" title="statement not covered" >_this;</span> } &nbsp; /** * Get the width of the container and assign the width. * @private */ &nbsp; &nbsp; _createClass(<span class="cstat-no" title="statement not covered" >ResultClass, [{</span> key: '_onResize', value: <span class="fstat-no" title="function not covered" >function _onResize() {</span> var <span class="cstat-no" title="statement not covered" >containerElement = (0, _reactUtils.getDOMNode)(this.refs[CONTAINER_REF]);</span> var <span class="cstat-no" title="statement not covered" >offsetWidth = containerElement.offsetWidth;</span> if (<span class="cstat-no" title="statement not covered" >this.state.width !== offsetWidth) {</span> this.<span class="cstat-no" title="statement not covered" >setState({</span> width: offsetWidth }); } } }, { key: '_onResizeDebounced', value: <span class="fstat-no" title="function not covered" >function _onResizeDebounced() {</span> _window2.<span class="cstat-no" title="statement not covered" >default.clearTimeout(this._resizeTimeout);</span> this.<span class="cstat-no" title="statement not covered" >_resizeTimeout = _window2.default.setTimeout(this._onResize, 100);</span> } }, { key: 'componentDidMount', value: <span class="fstat-no" title="function not covered" >function componentDidMount() {</span> this.<span class="cstat-no" title="statement not covered" >_onResize();</span> _window2.<span class="cstat-no" title="statement not covered" >default.addEventListener('resize', this._onResizeDebounced);</span> } }, { key: 'componentWillReceiveProps', value: <span class="fstat-no" title="function not covered" >function componentWillReceiveProps() {</span> this.<span class="cstat-no" title="statement not covered" >_onResize();</span> } }, { key: 'componentWillUnmount', value: <span class="fstat-no" title="function not covered" >function componentWillUnmount() {</span> _window2.<span class="cstat-no" title="statement not covered" >default.clearTimeout(this._resizeTimeout);</span> _window2.<span class="cstat-no" title="statement not covered" >default.removeEventListener('resize', this._onResizeDebounced);</span> } }, { key: 'render', value: <span class="fstat-no" title="function not covered" >function render() {</span> var <span class="cstat-no" title="statement not covered" >width = this.state.width;</span> &nbsp; return <span class="cstat-no" title="statement not covered" >_react2.default.createElement(</span> 'div', { ref: CONTAINER_REF }, _react2.default.createElement(Component, _extends({ width: width }, this.props)) ); } }]); &nbsp; return <span class="cstat-no" title="statement not covered" >ResultClass;</span> }(_react2.default.Component); &nbsp; ResultClass.<span class="cstat-no" title="statement not covered" >displayName = 'Flexible' + Component.displayName;</span> &nbsp; return <span class="cstat-no" title="statement not covered" >ResultClass;</span> }</pre></td></tr> </table></pre> <div class='push'></div><!-- for sticky footer --> </div><!-- /wrapper --> <div class='footer quiet pad2 space-top1 center small'> Code coverage generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri May 20 2016 11:46:43 GMT-0700 (PDT) </div> </div> <script src="../../prettify.js"></script> <script> window.onload = function () { if (typeof prettyPrint === 'function') { prettyPrint(); } }; </script> <script src="../../sorter.js"></script> </body> </html>