0f9159a63e77b7bd542b082508a1be04.json
16.3 KB
{"ast":null,"code":"var _interopRequireWildcard=require(\"@babel/runtime/helpers/interopRequireWildcard\");var _interopRequireDefault=require(\"@babel/runtime/helpers/interopRequireDefault\");Object.defineProperty(exports,\"__esModule\",{value:true});exports.default=void 0;var _extends2=_interopRequireDefault(require(\"@babel/runtime/helpers/extends\"));var _classCallCheck2=_interopRequireDefault(require(\"@babel/runtime/helpers/classCallCheck\"));var _createClass2=_interopRequireDefault(require(\"@babel/runtime/helpers/createClass\"));var _possibleConstructorReturn2=_interopRequireDefault(require(\"@babel/runtime/helpers/possibleConstructorReturn\"));var _getPrototypeOf3=_interopRequireDefault(require(\"@babel/runtime/helpers/getPrototypeOf\"));var _inherits2=_interopRequireDefault(require(\"@babel/runtime/helpers/inherits\"));var _react=_interopRequireWildcard(require(\"react\"));var _propTypes=_interopRequireDefault(require(\"prop-types\"));var _Text=_interopRequireDefault(require(\"react-native-web/dist/exports/Text\"));var _View=_interopRequireDefault(require(\"react-native-web/dist/exports/View\"));var _reactNativeSvg=require(\"react-native-svg\");var d3Scale=_interopRequireWildcard(require(\"d3-scale\"));var array=_interopRequireWildcard(require(\"d3-array\"));var YAxis=function(_PureComponent){(0,_inherits2.default)(YAxis,_PureComponent);function YAxis(){var _getPrototypeOf2;var _this;(0,_classCallCheck2.default)(this,YAxis);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=(0,_possibleConstructorReturn2.default)(this,(_getPrototypeOf2=(0,_getPrototypeOf3.default)(YAxis)).call.apply(_getPrototypeOf2,[this].concat(args)));_this.state={height:0,width:0};return _this;}(0,_createClass2.default)(YAxis,[{key:\"_onLayout\",value:function _onLayout(event){var _event$nativeEvent$la=event.nativeEvent.layout,height=_event$nativeEvent$la.height,width=_event$nativeEvent$la.width;this.setState({height:height,width:width});}},{key:\"getY\",value:function getY(domain){var _this$props=this.props,scale=_this$props.scale,spacingInner=_this$props.spacingInner,spacingOuter=_this$props.spacingOuter,_this$props$contentIn=_this$props.contentInset,_this$props$contentIn2=_this$props$contentIn.top,top=_this$props$contentIn2===void 0?0:_this$props$contentIn2,_this$props$contentIn3=_this$props$contentIn.bottom,bottom=_this$props$contentIn3===void 0?0:_this$props$contentIn3;var height=this.state.height;var y=scale().domain(domain).range([height-bottom,top]);if(scale===d3Scale.scaleBand){y.range([top,height-bottom]).paddingInner([spacingInner]).paddingOuter([spacingOuter]);return function(value){return y(value)+y.bandwidth()/2;};}return y;}},{key:\"render\",value:function render(){var _this2=this;var _this$props2=this.props,style=_this$props2.style,data=_this$props2.data,scale=_this$props2.scale,yAccessor=_this$props2.yAccessor,numberOfTicks=_this$props2.numberOfTicks,formatLabel=_this$props2.formatLabel,svg=_this$props2.svg,children=_this$props2.children;var _this$state=this.state,height=_this$state.height,width=_this$state.width;if(data.length===0){return _react.default.createElement(_View.default,{style:style});}var values=data.map(function(item,index){return yAccessor({item:item,index:index});});var extent=array.extent(values);var _this$props3=this.props,_this$props3$min=_this$props3.min,min=_this$props3$min===void 0?extent[0]:_this$props3$min,_this$props3$max=_this$props3.max,max=_this$props3$max===void 0?extent[1]:_this$props3$max;var domain=scale===d3Scale.scaleBand?values:[min,max];var y=this.getY(domain);var ticks=scale===d3Scale.scaleBand?values:y.ticks(numberOfTicks);var longestValue=ticks.map(function(value,index){return formatLabel(value,index);}).reduce(function(prev,curr){return prev.toString().length>curr.toString().length?prev:curr;},0);var extraProps={y:y,ticks:ticks,width:width,height:height,formatLabel:formatLabel};return _react.default.createElement(_View.default,{style:[style]},_react.default.createElement(_View.default,{style:{flexGrow:1},onLayout:function onLayout(event){return _this2._onLayout(event);}},_react.default.createElement(_Text.default,{style:{opacity:0,fontSize:svg.fontSize}},longestValue),height>0&&width>0&&_react.default.createElement(_reactNativeSvg.Svg,{style:{position:'absolute',top:0,left:0,height:height,width:width}},_react.default.createElement(_reactNativeSvg.G,null,_react.default.Children.map(children,function(child){return _react.default.cloneElement(child,extraProps);}),height>0&&ticks.map(function(value,index){return _react.default.createElement(_reactNativeSvg.Text,(0,_extends2.default)({originY:y(value),textAnchor:'middle',x:'50%',alignmentBaseline:'middle'},svg,{key:y(value),y:y(value)}),formatLabel(value,index,ticks.length));})))));}}]);return YAxis;}(_react.PureComponent);YAxis.propTypes={data:_propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.object),_propTypes.default.arrayOf(_propTypes.default.number)]).isRequired,svg:_propTypes.default.object,style:_propTypes.default.any,numberOfTicks:_propTypes.default.number,formatLabel:_propTypes.default.func,contentInset:_propTypes.default.shape({top:_propTypes.default.number,bottom:_propTypes.default.number}),min:_propTypes.default.number,max:_propTypes.default.number,yAccessor:_propTypes.default.func,scale:_propTypes.default.func,spacingInner:_propTypes.default.number,spacingOuter:_propTypes.default.number};YAxis.defaultProps={numberOfTicks:10,spacingInner:0.05,spacingOuter:0.05,contentInset:{},svg:{},scale:d3Scale.scaleLinear,formatLabel:function formatLabel(value){return value&&value.toString();},yAccessor:function yAccessor(_ref){var item=_ref.item;return item;}};var _default=YAxis;exports.default=_default;","map":{"version":3,"sources":["C:/Users/bluej/Desktop/2_2/searchGuide/searchGuide/node_modules/react-native-svg-charts/src/y-axis.js"],"names":["YAxis","state","height","width","event","nativeEvent","layout","setState","domain","props","scale","spacingInner","spacingOuter","contentInset","top","bottom","y","range","d3Scale","scaleBand","paddingInner","paddingOuter","value","bandwidth","style","data","yAccessor","numberOfTicks","formatLabel","svg","children","length","values","map","item","index","extent","array","min","max","getY","ticks","longestValue","reduce","prev","curr","toString","extraProps","flexGrow","_onLayout","opacity","fontSize","position","left","React","Children","child","cloneElement","PureComponent","propTypes","PropTypes","oneOfType","arrayOf","object","number","isRequired","any","func","shape","defaultProps","scaleLinear"],"mappings":"kyBAAA,qDACA,6D,gKAEA,gDACA,yDACA,uD,GAEMA,CAAAA,K,0aACFC,K,CAAQ,CACJC,MAAM,CAAE,CADJ,CAEJC,KAAK,CAAE,CAFH,C,0FAKEC,K,CAAO,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IAAH,OAAcA,CAAAA,IAAd,EARM,CAArB,C,aAWelC,K","sourcesContent":["import React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\nimport { Text, View } from 'react-native'\nimport { Svg, G, Text as SVGText } from 'react-native-svg'\nimport * as d3Scale from 'd3-scale'\nimport * as array from 'd3-array'\n\nclass YAxis extends PureComponent {\n state = {\n height: 0,\n width: 0,\n }\n\n _onLayout(event) {\n const {\n nativeEvent: {\n layout: { height, width },\n },\n } = event\n this.setState({ height, width })\n }\n\n getY(domain) {\n const {\n scale,\n spacingInner,\n spacingOuter,\n contentInset: { top = 0, bottom = 0 },\n } = this.props\n\n const { height } = this.state\n\n const y = scale()\n .domain(domain)\n .range([height - bottom, top])\n\n if (scale === d3Scale.scaleBand) {\n // use index as domain identifier instead of value since\n // same value can occur at several places in dataPoints\n y\n // set range top to bottom - we are not sorting on values in scaleBand\n .range([top, height - bottom])\n .paddingInner([spacingInner])\n .paddingOuter([spacingOuter])\n\n //add half a bar to center label\n return (value) => y(value) + y.bandwidth() / 2\n }\n\n return y\n }\n\n render() {\n const { style, data, scale, yAccessor, numberOfTicks, formatLabel, svg, children } = this.props\n\n const { height, width } = this.state\n\n if (data.length === 0) {\n return <View style={style} />\n }\n\n const values = data.map((item, index) => yAccessor({ item, index }))\n\n const extent = array.extent(values)\n\n const { min = extent[0], max = extent[1] } = this.props\n\n const domain = scale === d3Scale.scaleBand ? values : [min, max]\n\n //invert range to support svg coordinate system\n const y = this.getY(domain)\n\n const ticks = scale === d3Scale.scaleBand ? values : y.ticks(numberOfTicks)\n\n const longestValue = ticks\n .map((value, index) => formatLabel(value, index))\n .reduce((prev, curr) => (prev.toString().length > curr.toString().length ? prev : curr), 0)\n\n const extraProps = {\n y,\n ticks,\n width,\n height,\n formatLabel,\n }\n\n return (\n <View style={[style]}>\n <View style={{ flexGrow: 1 }} onLayout={(event) => this._onLayout(event)}>\n {/*invisible text to allow for parent resizing*/}\n <Text style={{ opacity: 0, fontSize: svg.fontSize }}>{longestValue}</Text>\n {height > 0 && width > 0 && (\n <Svg\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n height,\n width,\n }}\n >\n <G>\n {React.Children.map(children, (child) => {\n return React.cloneElement(child, extraProps)\n })}\n {// don't render labels if width isn't measured yet,\n // causes rendering issues\n height > 0 &&\n ticks.map((value, index) => {\n return (\n <SVGText\n originY={y(value)}\n textAnchor={'middle'}\n x={'50%'}\n alignmentBaseline={'middle'}\n {...svg}\n key={y(value)}\n y={y(value)}\n >\n {formatLabel(value, index, ticks.length)}\n </SVGText>\n )\n })}\n </G>\n </Svg>\n )}\n </View>\n </View>\n )\n }\n}\n\nYAxis.propTypes = {\n data: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.arrayOf(PropTypes.number)]).isRequired,\n svg: PropTypes.object,\n style: PropTypes.any,\n numberOfTicks: PropTypes.number,\n formatLabel: PropTypes.func,\n contentInset: PropTypes.shape({\n top: PropTypes.number,\n bottom: PropTypes.number,\n }),\n min: PropTypes.number,\n max: PropTypes.number,\n yAccessor: PropTypes.func,\n scale: PropTypes.func,\n spacingInner: PropTypes.number,\n spacingOuter: PropTypes.number,\n}\n\nYAxis.defaultProps = {\n numberOfTicks: 10,\n spacingInner: 0.05,\n spacingOuter: 0.05,\n contentInset: {},\n svg: {},\n scale: d3Scale.scaleLinear,\n formatLabel: (value) => value && value.toString(),\n yAccessor: ({ item }) => item,\n}\n\nexport default YAxis\n"]},"metadata":{},"sourceType":"script"}