salad-ui.chart
Advanced tools
Comparing version 1.1.35 to 1.1.36
@@ -1,1 +0,1 @@ | ||
{"name":"salad-ui.chart","version":"1.1.35","description":"Reusable React UI Components Toolkit","main":"./salad-ui.chart.js","repository":{"type":"git","url":"https://github.com/dailymotion/salad-ui.git"},"keywords":["react","react-component","react-chart","react-graph"],"peerDependencies":{"react":"^15.0.0","react-dom":"^15.0.0","react-router":"^2.4.1"}} | ||
{"name":"salad-ui.chart","version":"1.1.36","description":"Reusable React UI Components Toolkit","main":"./salad-ui.chart.js","repository":{"type":"git","url":"https://github.com/dailymotion/salad-ui.git"},"keywords":["react","react-component","react-chart","react-graph"],"peerDependencies":{"react":"^15.0.0","react-dom":"^15.0.0","react-router":"^2.4.1"}} |
@@ -1,2 +0,2 @@ | ||
module.exports=function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return e[o].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="/dist/",t(0)}({0:function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}var n=r(206),i=o(n);e.exports=i.default},5:function(e,t){e.exports=require("react")},29:function(e,t){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(t,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?function(e){return"undefined"==typeof e?"undefined":r(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":"undefined"==typeof e?"undefined":r(e)},n=t.currencyToSymbol=function(e){switch(e){case"EUR":return"€";case"DKK":return"kr";case"GBP":return"£";case"USD":default:return"$"}},i=(t.formatCurrency=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(null!==e&&""!==e){"number"!=typeof e&&(e=parseFloat(e)),e=e.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g,"$1,");var r=n(t);switch(t){case"EUR":return""+r+e;case"DKK":return""+r+e;case"USD":default:return""+r+e}return n(t)+" "+e}},t.formatNumber=function(e){var t=e.toString(),r=t.split("."),o=r[0]+(r[1]?"."+r[1].slice(0,2):"");return o.replace(/\B(?=(\d{3})+(?!\d))/g,",")},t.numberToString=function(e){var t=parseFloat(e);return isNaN(t)?e:t>1e9?Math.round(t/1e8)/10+"B":t>1e7?Math.round(t/1e6)+"M":t>1e6?Math.round(t/1e5)/10+"M":t>1e4?Math.round(t/1e3)+"K":t>1e3?Math.round(t/100)/10+"K":Math.round(100*t)/100},t.mapList=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=t.map(function(t){return"object"===("undefined"==typeof t?"undefined":o(t))?l(e,t,r+1).value:t});if(0===n.length)return"none";var i="",a=0;for(a;a<=n.length-1;a++)i+=n[a],i+=a===n.length-1?"":a===n.length-2?" and ":", ";return i}),a=t.mapSum=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=t.map(function(t){return"object"===("undefined"==typeof t?"undefined":o(t))?l(e,t,r+1).value:t});if(0===n.length)return 0;var i=0,a=0;for(a;a<=n.length-1;a++)i+=parseFloat(n[a]);return i},l=t.readProperty=function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!t||!t[n])return{value:"_invalid_key_",iteration:n};var l="undefined"==typeof r?"undefined":o(r);if("string"===l||"number"===l);else{if(t[n]&&t[n]in r)return n<t.length-1&&"object"===o(r[t[n]])?e(t,r[t[n]],n+1):{value:r[t[n]],iteration:n};if(~["all","first","sum","mean","random"].indexOf(t[n])&&r instanceof Array)switch(t[n]){case"first":return r[0]?e(t,r[0],n+1):{value:"_invalid_array_",iteration:n};case"random":var s=r[Math.floor(Math.random()*r.length)];return e(t,s,n+1);case"all":return e(t,i(t,r,n),n);case"sum":return e(t,a(t,r,n),n);case"mean":case"avg":return e(t,a(t,r,n)/r.length,n)}}return{value:"_invalid_key_",iteration:n}};t.render=function(e,t){return e.replace(/([{}])\1|[{](.*?)(?:!(.+?))?[}]/g,function(e,r,o){var n=l(o.split("."),t).value;return"function"==typeof n?n():n})}},63:function(e,t){e.exports=require("react-dom")},101:function(e,t){e.exports=require("moment")},102:function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":l(t))&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":l(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},p=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),u=r(5),f=o(u),d=function(e){function t(){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return a(t,e),p(t,[{key:"render",value:function(){return f.default.createElement("svg",{className:"react-chart "+this.props.type,width:this.props.width,style:s({overflow:"visible",border:this.props.border},this.props.style),height:this.props.height},this.props.children)}}]),t}(u.Component);d.defaultProps={border:"none",height:400,width:600,style:{}},t.default=d},203:function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":s(t))&&"function"!=typeof t?e:t}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":s(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(t,"__esModule",{value:!0});var p="function"==typeof Symbol&&"symbol"===s(Symbol.iterator)?function(e){return"undefined"==typeof e?"undefined":s(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":"undefined"==typeof e?"undefined":s(e)},u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},f=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),d=r(5),c=o(d),h=r(63),y=(o(h),r(101)),b=o(y),m=r(29),g=r(102),v=o(g),x=function(e){function t(){var e,r,o,n;i(this,t);for(var l=arguments.length,s=Array(l),p=0;p<l;p++)s[p]=arguments[p];return r=o=a(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(s))),o.tipsData={},o.xAxisLabels=[],n=r,a(o,n)}return l(t,e),f(t,[{key:"describeLine",value:function(e,t,r,o,n,i,a){var l=this,s=0===n&&0===r;return e.map(function(e,o){return Math.max(0,(e.time-t)*i-l.props.strokeWidth)+","+(s?a:(n-(e.value-r))*a)}).join(" ")}},{key:"centerElement",value:function(e,t,r){var o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];o&&e.setAttribute("width",r);var n=t-r/2;e.setAttribute("x",n)}},{key:"showPointTip",value:function(e,t){var r=this.refs[e.ref],o=r.getElementsByClassName("tip-background")[0],n=r.getElementsByClassName("tip-text-date")[0],i=r.getElementsByClassName("tip-text-value")[0];this.centerElement(n,this.tipsData[e.ref].xBase,n.getBBox().width),this.centerElement(i,this.tipsData[e.ref].xBase,i.getBBox().width),this.centerElement(o,this.tipsData[e.ref].xBase,Math.max(n.getBBox().width,i.getBBox().width)+2*this.props.tipsPadding,!0),r.style.display="block"}},{key:"hidePointTip",value:function(e,t){this.refs[e.ref].style.display="none"}},{key:"renderTipText",value:function(e,t){if("function"==typeof e)return e(t);if("string"==typeof e)return e.replace("{{date}}",(0,b.default)(t.date).format(t.dateFormat||"YYYY-MM-DD")).replace("{{date1}}",(0,b.default)(t.date1).format(t.dateFormat||"YYYY-MM-DD")).replace("{{date2}}",(0,b.default)(t.date2).format(t.dateFormat||"YYYY-MM-DD")).replace("{{value}}",(0,m.formatNumber)(t.value));throw new Error("Invalid labelTemplate type!")}},{key:"renderTips",value:function(e,t,r,o,n,i,a){var l=this,s=void 0,p=void 0,u="{{date}}",f=void 0,d="{{value}} views",h=864e5,y=0===n&&0===r;if(0!==e.length)return s=1===e.length?0:e[1].time-e[0].time,o>365*h*7?p="YYYY":o>30*h*9?p="MMM":o>7*h?p="MMM Do":o<h&&(p="LT"),s>27*h&&s<32*h?p="MMMM":s>h?(p="MMM Do",u="{{date1}} through {{date2}}"):p=o<h?"LT":"MMM Do",e.map(function(o,h){if(0!==h&&h!==e.length-1||l.props.showFirstAndLastTip){f=e[h+1]?e[h+1].time:o.time+s,o.label||(o.label=d);var b=(o.time-t)*i,m="point_"+h+"_tooltip",g=p,v=38,x=25,P=(y?a:(n-(o.value-r))*a)-l.props.tipsPadding/2,k=25,T=10,w=[b-l.props.tipStrokeWidth-k/2+","+(P-x+9),b-l.props.tipStrokeWidth+k/2+","+(P-x+9),b-l.props.tipStrokeWidth+","+(P-x+T+9)].join(" "),S=[b-l.props.tipStrokeWidth-k/2+","+(P-x+10),b-l.props.tipStrokeWidth+k/2+","+(P-x+10),b-l.props.tipStrokeWidth+","+(P-x+T+10)].join(" ");return l.tipsData[m]={xBase:b},new Date(o.time).getFullYear()!==(new Date).getFullYear()&&(g+=" YYYY"),c.default.createElement("g",{key:"point-"+h,ref:m,style:{display:"none",position:"relative",zIndex:4},className:"value-tip"},c.default.createElement("rect",{className:"tip-background",x:(o.time-t)*i-l.props.strokeWidth-l.props.tipsWidth/2,y:P-v-x,width:l.props.tipsWidth+l.props.tipsPadding,height:v+l.props.tipsPadding,style:{stroke:l.props.tipStrokeColor,strokeWidth:l.props.tipStrokeWidth,fill:l.props.tipsFill}}),c.default.createElement("polygon",{points:S,style:{stroke:l.props.tipStrokeColor,opacity:.5,strokeWidth:l.props.tipStrokeWidth}}),c.default.createElement("polygon",{points:w,style:{fill:l.props.tipsFill}}),c.default.createElement("text",{className:"tip-text-date",x:b-l.props.tipsWidth/2+2,y:P-l.props.strokeWidth-v-x+l.props.tipsPadding+10,style:{fontSize:14,fontWeight:"light"},dangerouslySetInnerHTML:{__html:l.renderTipText(u,{dateFormat:g,date:o.time,date1:o.time,date2:f,value:o.value})}}),c.default.createElement("text",{className:"tip-text-value",x:b-l.props.tipsWidth/2+2,y:P-l.props.strokeWidth-v-x+l.props.tipsPadding+30,style:{fontSize:16,fontWeight:"bold"},dangerouslySetInnerHTML:{__html:l.renderTipText(l.props.labelTemplate,{value:o.value,date:o.time})}}))}})}},{key:"renderPoints",value:function(e,t,r,o,n,i,a){var l=this,s=0===n&&0===r;return e.map(function(o,p){if(0!==p&&p!==e.length-1||l.props.showFirstAndLastTip)return c.default.createElement("circle",{key:"point-"+p,cx:(o.time-t)*i-l.props.strokeWidth/2,cy:s?a:(n-(o.value-r))*a,r:l.props.pointsRadius,onMouseOver:l.showPointTip.bind(l,{ref:"point_"+p+"_tooltip"}),onMouseLeave:l.hidePointTip.bind(l,{ref:"point_"+p+"_tooltip"}),style:{stroke:l.props.strokeColor,strokeWidth:l.props.strokeWidth,fill:"white",cursor:"default"}})})}},{key:"renderLabel",value:function(e,t){return e.x||("right"===this.props.yLabelsPosition?e.x=this.activeWidth+(this.props.yLabelsOutside?5:-1*(20+5*(e.txt.length||1))):e.x=20),e.ref||(e.ref="label."+t+","+e.x+","+e.y),c.default.createElement("text",{key:"graph.xAxis.label."+e.ref,x:e.x,y:e.y,ref:e.ref,fill:this.props.labelColor,style:{fontSize:this.props.labelFontSize,textShadow:this.props.labelTextShadow}},e.txt)}},{key:"renderYGridLine",value:function(e,t){return c.default.createElement("line",{key:"graph.ygridLine."+t,x1:"0",y1:e.y,x2:this.activeWidth-this.props.strokeWidth,y2:e.y,fill:this.props.labelColor,style:{stroke:this.props.gridColor,strokeWidth:1}})}},{key:"describeYAxis",value:function(e,t,r){function o(e,t){return t||(t=100),e>t&&o(e,5*t),Math.ceil(e/t)*t/10}var n=o(t,t/10),i=[1,2,3,4,5,6,7,8,9],a=[0,1,2,3,4],l=0===t&&0===e;return{gridLines:i.map(function(e){return{y:l?r:(t-e*n)*r}}),labels:a.map(function(o){var i=o*n*2;return{y:l?r:(t-o*n*2)*r,txt:(0,m.formatNumber)(Math.round(i+e))}})}}},{key:"reduceData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1],r=this,o=arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:12,i=[];e.forEach(function(t,r){t.time||(e[r].time=t.id||0),i.push(t)});var a=parseFloat(t.format("x")),l=parseFloat(o.format("x"));if(i=i.filter(function(e){return e.time>=a&&e.time<=l}),!(i.length>n))return i;var s=function(){var e=i.length/n,t=[];return i.forEach(function(r,o){var n=Math.floor(o/e),i=parseFloat(r.value);t[n]?t[n].value+=i:t[n]={value:i,label:"{{value}} "+r.label,time:r.time}}),"mean"===r.props.formula?{v:t.map(function(t){return u({},t,{value:Math.round(100*t.value/e)/100})})}:{v:t}}();return"object"===("undefined"==typeof s?"undefined":p(s))?s.v:void 0}},{key:"describeXAxis",value:function(e,t,r,o){var n=this,i=[1,2,3,4,5,6,7,8,9],a=o.length/i.length,l="ddd",s=[],p=864e5;return e<1e4?{labels:[]}:(i.length>o.length&&(i=o.map(function(e,t){return t+1}),a=1),t>365*p*7?l="YYYY":t>30*p*9?l="MMM":t>7*p?l="MMM D":t<p&&(l="LT"),i.forEach(function(o,a){var p=e+o*(t/i.length);a<i.length-1&&s.push({txt:(0,b.default)(p).format(l),time:p,x:(p-e)*r,y:n.activeHeight+30,ref:"xLabel."+a})}),this.xAxisLabels=s,{labels:s})}},{key:"centerXAxisLabelMarkers",value:function(){var e=this;this.xAxisLabels.forEach(function(t){var r=e.refs[t.ref];e.centerElement(r,t.x,r.getBBox().width)})}},{key:"componentDidMount",value:function(){this.centerXAxisLabelMarkers()}},{key:"componentDidUpdate",value:function(){this.centerXAxisLabelMarkers()}},{key:"render",value:function(){var e=this,t=this.props.data;this.activeWidth=this.props.width,this.activeHeight=this.props.height-50,t.forEach(function(e,r){e.time||(t[r].time=r),e.time instanceof Date||(t[r].time=new Date(t[r].time).getTime())}),t=t.sort(function(e,t){return e.time===t.time?0:e.time>t.time?1:-1});var r=Math.max.apply(Math,n(t.map(function(e,t){return e.time})).concat([t.length])),o=Math.min.apply(Math,n(t.map(function(e,t){return e.time})));this.props.maxPoints!==-1&&(t=this.reduceData(t,(0,b.default)(o),(0,b.default)(r),this.props.maxPoints),r=Math.max.apply(Math,n(t.map(function(e,t){return e.time})).concat([t.length])));var i=Math.max.apply(Math,n(t.map(function(e){return e.value}))),a=Math.pow(10,String(Math.round(i)).length-1),l=(1+1/this.props.yPadding,Math.max(Math.ceil(i/a)*a,1)),s=this.props.useDynamicYMin?Math.min.apply(Math,n(t.map(function(e){return e.value})))-l/5:0,p=r-o,u=l-s,f=this.activeWidth/(p||1),d=this.activeHeight/(u||1),h=this.describeLine(t,o,s,p,u,f,d),y="0,"+((x?d:u*d)-this.props.strokeWidth)+" "+h+" "+((r-o)*f-this.props.strokeWidth)+","+((x?d:u*d)-this.props.strokeWidth),m=this.describeYAxis(s,u,d),g=this.describeXAxis(o,p,f,t),x=0===u&&0===s;return c.default.createElement(v.default,{width:this.props.width,height:this.props.height,type:"area"},m.gridLines.map(this.renderYGridLine.bind(this)),c.default.createElement("polygon",{points:y,style:{fill:this.props.fillColor,strokeWidth:0}}),c.default.createElement("polyline",{points:h,style:{stroke:this.props.strokeColor,strokeDasharray:this.props.strokeDasharray,strokeWidth:this.props.strokeWidth,fill:"none"}}),m.labels.map(this.renderLabel.bind(this)),g.labels.map(function(t,r){return c.default.createElement("line",{key:"graph.xAxis.label."+r,ref:t.ref+".marker",x1:t.x,x2:t.x,y1:e.activeHeight,y2:e.activeHeight+10,stroke:e.props.gridColor,strokeWidth:1})}),g.labels.map(this.renderLabel.bind(this)),this.renderPoints(t,o,s,p,u,f,d),this.renderTips(t,o,s,p,u,f,d))}}]),t}(d.Component);x.propTypes={width:c.default.PropTypes.number,height:c.default.PropTypes.number,border:c.default.PropTypes.string,strokeWidth:c.default.PropTypes.number,useDynamicYMin:c.default.PropTypes.bool,strokeColor:c.default.PropTypes.string,strokeDasharray:c.default.PropTypes.number,pointsRadius:c.default.PropTypes.number,showFirstAndLastTip:c.default.PropTypes.bool,tipsWidth:c.default.PropTypes.number,tipsHeight:c.default.PropTypes.number,tipsPadding:c.default.PropTypes.number,tipStrokeWidth:c.default.PropTypes.number,tipStrokeColor:c.default.PropTypes.string,tipsFill:c.default.PropTypes.string,gridColor:c.default.PropTypes.string,labelFontSize:c.default.PropTypes.number,labelTextShadow:c.default.PropTypes.string,labelColor:c.default.PropTypes.string,fillColor:c.default.PropTypes.string,maxOverflow:c.default.PropTypes.number,maxPoints:c.default.PropTypes.number,yLabelsOutside:c.default.PropTypes.bool,yLabelsPosition:c.default.PropTypes.string,formula:c.default.PropTypes.string,yPadding:c.default.PropTypes.number,data:c.default.PropTypes.array},x.defaultProps={width:640,height:320,border:"none",strokeWidth:2,useDynamicYMin:!1,strokeColor:"#408AE5",strokeDasharray:0,pointsRadius:5,showFirstAndLastTip:!1,tipsWidth:240,tipsHeight:22,tipsPadding:10,tipStrokeWidth:1,tipStrokeColor:"#BBBBBB",tipsFill:"white",gridColor:"rgba(230,230,230,.5)",labelFontSize:12,labelTextShadow:"1px 1px #fff",labelColor:"#555",labelTemplate:"{{value}}",fillColor:"rgba(191, 216, 246, 0.3)",maxOverflow:20,yLabelsOutside:!1,yLabelsPosition:"left",yPadding:10,maxPoints:-1,formula:"sum",data:[]},t.default=x},204:function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":l(t))&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":l(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),p=r(5),u=o(p),f=r(29),d=function(e){function t(){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return a(t,e),s(t,[{key:"formatValue",value:function(e){return"%"===this.props.metricName?Math.round(e):(0,f.formatNumber)(e)}},{key:"render",value:function(){return u.default.createElement("div",{style:{position:"relative",marginBottom:15}},u.default.createElement("div",{style:{fontSize:13,textTransform:"uppercase"}},this.props.label),u.default.createElement("div",{className:"bar-row"},u.default.createElement("div",{style:{backgroundColor:this.props.barRailColor,width:"100%",height:this.props.barHeight,display:"block",marginTop:4,position:"relative"}},u.default.createElement("div",{style:{width:this.props.percent+"%",height:this.props.barHeight,position:"absolute",backgroundColor:this.props.barColor,top:0,left:0,bottom:0,transition:"all .5s"}})),u.default.createElement("div",{style:{paddingLeft:this.props.metricPadding,fontSize:13,display:"inline-block",position:"absolute",right:0,top:0,fontWeight:"bold",color:this.props.metricColor,textAlign:"right"}},this.formatValue(this.props.value)+" "+this.props.metricName)))}}]),t}(u.default.Component);d.defaultProps={metricName:"points",value:"0",percent:100,metricPadding:15,metricColor:"#777",barHeight:7,barRailColor:"#ddd",barColor:"#408AE5",label:"N/A"},d.propTypes={metricName:u.default.PropTypes.string,percent:u.default.PropTypes.number,barWidth:u.default.PropTypes.number,barHeight:u.default.PropTypes.number,metricPadding:u.default.PropTypes.number,label:u.default.PropTypes.string,metricColor:u.default.PropTypes.string,barColor:u.default.PropTypes.string,barRailColor:u.default.PropTypes.string},t.default=d},205:function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":s(t))&&"function"!=typeof t?e:t}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":s(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(t,"__esModule",{value:!0});var p=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),u=r(5),f=o(u),d=r(29),c=function(e){function t(){return i(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return l(t,e),p(t,[{key:"formatValue",value:function(e){return"%"===this.props.metricName?Math.round(e):(0,d.formatNumber)(e)}},{key:"renderYGridLine",value:function(e,t){return f.default.createElement("line",{key:"graph.ygridLine."+t,x1:0,y1:e.y,x2:this.props.width,y2:e.y,style:{stroke:this.props.gridColor,strokeWidth:1}})}},{key:"describeYAxis",value:function(e,t,r){function o(e,t){return t||(t=100),e>t&&o(e,5*t),Math.ceil(e/t)*t/10}var n=this,i=o(t,t/10),a=[1,2,3,4,5,6,7,8,9],l=[0,1,2,3,4],s=0===t&&0===e;return{gridLines:a.map(function(e){return{y:s?r:(t-e*i)*r}}),labels:l.map(function(o){var a=o*i*2;return{y:s?r:(t-o*i*2)*r,txt:(0,d.formatNumber)(Math.round(a+e))+(n.props.isPercent?"%":"")}})}}},{key:"renderTip",value:function(e,t,r,o){var n=25,i=10,a=([r-n/2+","+o-10,r+n/2+","+o-10,r+","+(o+i)-10].join(" "),[r-n/2+","+o-10,r+n/2+","+o-10,r+","+(o+i)-10].join(" "),28),l=15;return f.default.createElement("g",{key:"point."+e,ref:"point."+e},f.default.createElement("text",{x:r-a/2,y:o-l/2,style:{fontSize:16,fontWeight:"bold"}},t))}},{key:"renderLabel",value:function(e,t){return e.x||("right"===this.props.yLabelsPosition?e.x=this.activeWidth+(this.props.yLabelsOutside?5:-1*(20+5*(e.txt.length||1))):e.x=0),e.ref||(e.ref="label."+t+","+e.x+","+e.y),f.default.createElement("text",{key:"graph.yAxis.label."+e.ref,x:e.x,y:e.y,ref:e.ref,fill:this.props.labelColor,style:{fontSize:this.props.labelFontSize,textShadow:this.props.labelTextShadow,textAlign:"center"}},e.txt)}},{key:"render",value:function(){var e=this,t=this.props.height-this.props.bottomBarHeight,r=0,o=1.25*Math.max.apply(Math,n(this.props.data.map(function(e){return e.value}))),i=o-r,a=t/(i||1),l=this.describeYAxis(r,i,a),s=this.props.width/this.props.data.length,p=this.props.barSize===-1?s:this.props.barSize;return f.default.createElement("svg",{width:this.props.width,height:this.props.height},l.gridLines.map(this.renderYGridLine.bind(this)),this.props.data.map(function(r,o){return f.default.createElement("g",{key:"bar.item."+o},f.default.createElement("rect",{fill:e.props.barColor,width:p,height:r.value*a,y:t-r.value*a,x:o*s-p/2+s/2-p/2}),e.renderTip(o,r.value+(e.props.isPercent?"%":""),o*s-p/2+s/2,t-r.value*a))}),l.labels.map(this.renderLabel.bind(this)),this.props.data.map(function(r,o){return f.default.createElement("text",{key:"graph.xAxis.label."+o,x:o*s-p/2+s/2-5,y:t+e.props.bottomBarHeight,fill:e.props.labelColor,style:{fontSize:e.props.labelFontSize,textShadow:e.props.labelTextShadow}},r.label)}))}}]),t}(f.default.Component);c.defaultProps={data:[],metricName:"points",metricColor:"#777",barSize:20,barRailColor:null,barColor:"#408AE5",gridColor:"rgba(230,230,230,.5)",label:"N/A",width:400,height:200,bottomBarHeight:20,yLabelsOutside:!0,labelFontSize:12,labelTextShadow:"1px 1px #fff",labelColor:"#555",isPercent:!1,labelTemplate:"{{value}}"},c.propTypes={metricName:f.default.PropTypes.string,barSize:f.default.PropTypes.number,label:f.default.PropTypes.string,metricColor:f.default.PropTypes.string,barColor:f.default.PropTypes.string,barRailColor:f.default.PropTypes.string},t.default=c},206:function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var n=r(203),i=o(n),a=r(205),l=o(a),s=r(207),p=o(s),u=r(204),f=o(u);t.default={Area:i.default,CirclePie:p.default,BarMetric:f.default,Bar:l.default}},207:function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":l(t))&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":l(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),p=r(5),u=o(p),f=r(102),d=o(f),c=function(e){function t(){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return a(t,e),s(t,[{key:"polarToCartesian",value:function(e,t,r,o){var n=(o-90)*Math.PI/180;return{x:e+r*Math.cos(n),y:t+r*Math.sin(n)}}},{key:"describeArc",value:function(e,t,r,o,n){e&&t||console.error("x or y missing to describeArc");var i=this.polarToCartesian(e,t,r,n),a=this.polarToCartesian(e,t,r,o),l=n-o<=180?"0":"1";return["M",i.x,i.y,"A",r,r,0,l,0,a.x,a.y].join(" ")}},{key:"render",value:function(){var e=this.props.width/2-this.props.strokeWidth/2-this.props.padding,t=e+this.props.strokeWidth/2+this.props.padding,r=0,o=3.6*this.props.percent,n=this.props.percent+"%",i=3===n.length?-.95:-.6,a=this.describeArc(t,t,e,r,o);return u.default.createElement(d.default,{width:this.props.width,style:this.props.style,height:this.props.height,border:this.props.border},u.default.createElement("circle",{cx:t,cy:t,r:e,fill:this.props.fillColor,stroke:this.props.railColor,strokeWidth:this.props.strokeWidth}),u.default.createElement("path",{fill:this.props.fillColor,stroke:this.props.strokeColor,strokeWidth:this.props.strokeWidth,d:a}),u.default.createElement("text",{x:t,y:t,dx:i+"em",dy:".35em",fill:this.props.labelColor,fontWeight:this.props.labelFontWeight,fontSize:this.props.labelFontSize},n))}}]),t}(p.Component);c.propTypes={width:u.default.PropTypes.number,height:u.default.PropTypes.number,strokeWidth:u.default.PropTypes.number,strokeColor:u.default.PropTypes.string,labelFontWeight:u.default.PropTypes.string,labelFontSize:u.default.PropTypes.string,fillColor:u.default.PropTypes.string,startAngle:u.default.PropTypes.number,endAngle:u.default.PropTypes.number,radius:u.default.PropTypes.number,style:u.default.PropTypes.object},c.defaultProps={width:150,height:150,border:"none",strokeWidth:10,style:{},labelColor:"#408AE5",labelFontSize:"1.2em",labelFontWeight:"bold",strokeColor:"#408AE5",railColor:"#f5f5f5",fillColor:"none",percent:70,padding:0},t.default=c}}); | ||
module.exports=function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return e[o].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var r={};return t.m=e,t.c=r,t.p="/dist/",t(0)}({0:function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}var n=r(206),i=o(n);e.exports=i.default},5:function(e,t){e.exports=require("react")},29:function(e,t){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(t,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?function(e){return"undefined"==typeof e?"undefined":r(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":"undefined"==typeof e?"undefined":r(e)},n=t.currencyToSymbol=function(e){switch(e){case"EUR":return"€";case"DKK":return"kr";case"GBP":return"£";case"USD":default:return"$"}},i=(t.formatCurrency=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(null!==e&&""!==e){"number"!=typeof e&&(e=parseFloat(e)),e=e.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g,"$1,");var r=n(t);switch(t){case"EUR":return""+r+e;case"DKK":return""+r+e;case"USD":default:return""+r+e}return n(t)+" "+e}},t.formatNumber=function(e){var t=e.toString(),r=t.split("."),o=r[0]+(r[1]?"."+r[1].slice(0,2):"");return o.replace(/\B(?=(\d{3})+(?!\d))/g,",")},t.numberToString=function(e){var t=parseFloat(e);return isNaN(t)?e:t>1e9?Math.round(t/1e8)/10+"B":t>1e7?Math.round(t/1e6)+"M":t>1e6?Math.round(t/1e5)/10+"M":t>1e4?Math.round(t/1e3)+"K":t>1e3?Math.round(t/100)/10+"K":Math.round(100*t)/100},t.mapList=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=t.map(function(t){return"object"===("undefined"==typeof t?"undefined":o(t))?l(e,t,r+1).value:t});if(0===n.length)return"none";var i="",a=0;for(a;a<=n.length-1;a++)i+=n[a],i+=a===n.length-1?"":a===n.length-2?" and ":", ";return i}),a=t.mapSum=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=t.map(function(t){return"object"===("undefined"==typeof t?"undefined":o(t))?l(e,t,r+1).value:t});if(0===n.length)return 0;var i=0,a=0;for(a;a<=n.length-1;a++)i+=parseFloat(n[a]);return i},l=t.readProperty=function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!t||!t[n])return{value:"_invalid_key_",iteration:n};var l="undefined"==typeof r?"undefined":o(r);if("string"===l||"number"===l);else{if(t[n]&&t[n]in r)return n<t.length-1&&"object"===o(r[t[n]])?e(t,r[t[n]],n+1):{value:r[t[n]],iteration:n};if(~["all","first","sum","mean","random"].indexOf(t[n])&&r instanceof Array)switch(t[n]){case"first":return r[0]?e(t,r[0],n+1):{value:"_invalid_array_",iteration:n};case"random":var s=r[Math.floor(Math.random()*r.length)];return e(t,s,n+1);case"all":return e(t,i(t,r,n),n);case"sum":return e(t,a(t,r,n),n);case"mean":case"avg":return e(t,a(t,r,n)/r.length,n)}}return{value:"_invalid_key_",iteration:n}};t.render=function(e,t){return e.replace(/([{}])\1|[{](.*?)(?:!(.+?))?[}]/g,function(e,r,o){var n=l(o.split("."),t).value;return"function"==typeof n?n():n})}},63:function(e,t){e.exports=require("react-dom")},101:function(e,t){e.exports=require("moment")},102:function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":l(t))&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":l(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},p=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),u=r(5),f=o(u),d=function(e){function t(){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return a(t,e),p(t,[{key:"render",value:function(){return f.default.createElement("svg",{className:"react-chart "+this.props.type,width:this.props.width,style:s({overflow:"visible",border:this.props.border},this.props.style),height:this.props.height},this.props.children)}}]),t}(u.Component);d.defaultProps={border:"none",height:400,width:600,style:{}},t.default=d},203:function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":s(t))&&"function"!=typeof t?e:t}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":s(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(t,"__esModule",{value:!0});var p="function"==typeof Symbol&&"symbol"===s(Symbol.iterator)?function(e){return"undefined"==typeof e?"undefined":s(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":"undefined"==typeof e?"undefined":s(e)},u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},f=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),d=r(5),c=o(d),h=r(63),y=(o(h),r(101)),b=o(y),m=r(29),g=r(102),v=o(g),x=function(e){function t(){var e,r,o,n;i(this,t);for(var l=arguments.length,s=Array(l),p=0;p<l;p++)s[p]=arguments[p];return r=o=a(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(s))),o.tipsData={},o.xAxisLabels=[],n=r,a(o,n)}return l(t,e),f(t,[{key:"describeLine",value:function(e,t,r,o,n,i,a){var l=this,s=0===n&&0===r;return e.map(function(e,o){return Math.max(0,(e.time-t)*i-l.props.strokeWidth)+","+(s?a:(n-(e.value-r))*a)}).join(" ")}},{key:"centerElement",value:function(e,t,r){var o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];o&&e.setAttribute("width",r);var n=t-r/2;e.setAttribute("x",n)}},{key:"showPointTip",value:function(e,t){var r=this.refs[e.ref],o=r.getElementsByClassName("tip-background")[0],n=r.getElementsByClassName("tip-text-date")[0],i=r.getElementsByClassName("tip-text-value")[0];this.centerElement(n,this.tipsData[e.ref].xBase,n.getBBox().width),this.centerElement(i,this.tipsData[e.ref].xBase,i.getBBox().width),this.centerElement(o,this.tipsData[e.ref].xBase,Math.max(n.getBBox().width,i.getBBox().width)+2*this.props.tipsPadding,!0),r.style.display="block"}},{key:"hidePointTip",value:function(e,t){this.refs[e.ref].style.display="none"}},{key:"renderTipText",value:function(e,t){if("function"==typeof e)return e(t);if("string"==typeof e)return e.replace("{{date}}",(0,b.default)(t.date).format(t.dateFormat||"YYYY-MM-DD")).replace("{{date1}}",(0,b.default)(t.date1).format(t.dateFormat||"YYYY-MM-DD")).replace("{{date2}}",(0,b.default)(t.date2).format(t.dateFormat||"YYYY-MM-DD")).replace("{{value}}",(0,m.formatNumber)(t.value));throw new Error("Invalid labelTemplate type!")}},{key:"renderTips",value:function(e,t,r,o,n,i,a){var l=this,s=void 0,p=void 0,u="{{date}}",f=void 0,d="{{value}} views",h=864e5,y=0===n&&0===r;if(0!==e.length)return s=1===e.length?0:e[1].time-e[0].time,o>365*h*7?p="YYYY":o>30*h*9?p="MMM":o>7*h?p="MMM Do":o<h&&(p="LT"),s>27*h&&s<32*h?p="MMMM":s>h?(p="MMM Do",u="{{date1}} through {{date2}}"):p=o<h?"LT":"MMM Do",e.map(function(o,h){if(0!==h&&h!==e.length-1||l.props.showFirstAndLastTip){f=e[h+1]?e[h+1].time:o.time+s,o.label||(o.label=d);var b=(o.time-t)*i,m="point_"+h+"_tooltip",g=p,v=38,x=25,P=(y?a:(n-(o.value-r))*a)-l.props.tipsPadding/2,k=25,T=10,w=[b-l.props.tipStrokeWidth-k/2+","+(P-x+9),b-l.props.tipStrokeWidth+k/2+","+(P-x+9),b-l.props.tipStrokeWidth+","+(P-x+T+9)].join(" "),S=[b-l.props.tipStrokeWidth-k/2+","+(P-x+10),b-l.props.tipStrokeWidth+k/2+","+(P-x+10),b-l.props.tipStrokeWidth+","+(P-x+T+10)].join(" ");return l.tipsData[m]={xBase:b},new Date(o.time).getFullYear()!==(new Date).getFullYear()&&(g+=" YYYY"),c.default.createElement("g",{key:"point-"+h,ref:m,style:{display:"none",position:"relative",zIndex:4},className:"value-tip"},c.default.createElement("rect",{className:"tip-background",x:(o.time-t)*i-l.props.strokeWidth-l.props.tipsWidth/2,y:P-v-x,width:l.props.tipsWidth+l.props.tipsPadding,height:v+l.props.tipsPadding,style:{stroke:l.props.tipStrokeColor,strokeWidth:l.props.tipStrokeWidth,fill:l.props.tipsFill}}),c.default.createElement("polygon",{points:S,style:{stroke:l.props.tipStrokeColor,opacity:.5,strokeWidth:l.props.tipStrokeWidth}}),c.default.createElement("polygon",{points:w,style:{fill:l.props.tipsFill}}),c.default.createElement("text",{className:"tip-text-date",x:b-l.props.tipsWidth/2+2,y:P-l.props.strokeWidth-v-x+l.props.tipsPadding+10,style:{fontSize:14,fontWeight:"light"},dangerouslySetInnerHTML:{__html:l.renderTipText(u,{dateFormat:g,date:o.time,date1:o.time,date2:f,value:o.value})}}),c.default.createElement("text",{className:"tip-text-value",x:b-l.props.tipsWidth/2+2,y:P-l.props.strokeWidth-v-x+l.props.tipsPadding+30,style:{fontSize:16,fontWeight:"bold"},dangerouslySetInnerHTML:{__html:l.renderTipText(l.props.labelTemplate,{value:o.value,date:o.time})}}))}})}},{key:"renderPoints",value:function(e,t,r,o,n,i,a){var l=this,s=0===n&&0===r;return e.map(function(o,p){if(0!==p&&p!==e.length-1||l.props.showFirstAndLastTip)return c.default.createElement("circle",{key:"point-"+p,cx:(o.time-t)*i-l.props.strokeWidth/2,cy:s?a:(n-(o.value-r))*a,r:l.props.pointsRadius,onMouseOver:l.showPointTip.bind(l,{ref:"point_"+p+"_tooltip"}),onMouseLeave:l.hidePointTip.bind(l,{ref:"point_"+p+"_tooltip"}),style:{stroke:l.props.strokeColor,strokeWidth:l.props.strokeWidth,fill:"white",cursor:"default"}})})}},{key:"renderLabel",value:function(e,t){return e.x||("right"===this.props.yLabelsPosition?e.x=this.activeWidth+(this.props.yLabelsOutside?5:-1*(20+5*(e.txt.length||1))):e.x=20),e.ref||(e.ref="label."+t+","+e.x+","+e.y),c.default.createElement("text",{key:"graph.xAxis.label."+e.ref,x:e.x,y:e.y,ref:e.ref,fill:this.props.labelColor,style:{fontSize:this.props.labelFontSize,textShadow:this.props.labelTextShadow}},e.txt)}},{key:"renderYGridLine",value:function(e,t){return c.default.createElement("line",{key:"graph.ygridLine."+t,x1:"0",y1:e.y,x2:this.activeWidth-this.props.strokeWidth,y2:e.y,fill:this.props.labelColor,style:{stroke:this.props.gridColor,strokeWidth:1}})}},{key:"describeYAxis",value:function(e,t,r){function o(e,t){return t||(t=100),e>t&&o(e,5*t),Math.ceil(e/t)*t/10}var n=o(t,t/10),i=[1,2,3,4,5,6,7,8,9],a=[0,1,2,3,4],l=0===t&&0===e;return{gridLines:i.map(function(e){return{y:l?r:(t-e*n)*r}}),labels:a.map(function(o){var i=o*n*2;return{y:l?r:(t-o*n*2)*r,txt:(0,m.formatNumber)(Math.round(i+e))}})}}},{key:"reduceData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1],r=this,o=arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:12,i=[];e.forEach(function(t,r){t.time||(e[r].time=t.id||0),i.push(t)});var a=parseFloat(t.format("x")),l=parseFloat(o.format("x"));if(i=i.filter(function(e){return e.time>=a&&e.time<=l}),!(i.length>n))return i;var s=function(){var e=i.length/n,t=[];return i.forEach(function(r,o){var n=Math.floor(o/e),i=parseFloat(r.value);t[n]?t[n].value+=i:t[n]={value:i,label:"{{value}} "+r.label,time:r.time}}),"mean"===r.props.formula?{v:t.map(function(t){return u({},t,{value:Math.round(100*t.value/e)/100})})}:{v:t}}();return"object"===("undefined"==typeof s?"undefined":p(s))?s.v:void 0}},{key:"describeXAxis",value:function(e,t,r,o){var n=this,i=[1,2,3,4,5,6,7,8,9],a=o.length/i.length,l="ddd",s=[],p=864e5;return e<1e4?{labels:[]}:(i.length>o.length&&(i=o.map(function(e,t){return t+1}),a=1),t>365*p*7?l="YYYY":t>30*p*9?l="MMM":t>7*p?l="MMM D":t<p&&(l="LT"),i.forEach(function(o,a){var p=e+o*(t/i.length);a<i.length-1&&s.push({txt:(0,b.default)(p).format(l),time:p,x:(p-e)*r,y:n.activeHeight+30,ref:"xLabel."+a})}),this.xAxisLabels=s,{labels:s})}},{key:"centerXAxisLabelMarkers",value:function(){var e=this;this.xAxisLabels.forEach(function(t){var r=e.refs[t.ref];e.centerElement(r,t.x,r.getBBox().width)})}},{key:"componentDidMount",value:function(){this.centerXAxisLabelMarkers()}},{key:"componentDidUpdate",value:function(){this.centerXAxisLabelMarkers()}},{key:"render",value:function(){var e=this,t=this.props.data;this.activeWidth=this.props.width,this.activeHeight=this.props.height-50,t.forEach(function(e,r){e.time||(t[r].time=r),e.time instanceof Date||(t[r].time=new Date(t[r].time).getTime())}),t=t.sort(function(e,t){return e.time===t.time?0:e.time>t.time?1:-1});var r=Math.max.apply(Math,n(t.map(function(e,t){return e.time})).concat([t.length])),o=Math.min.apply(Math,n(t.map(function(e,t){return e.time})));this.props.maxPoints!==-1&&(t=this.reduceData(t,(0,b.default)(o),(0,b.default)(r),this.props.maxPoints),r=Math.max.apply(Math,n(t.map(function(e,t){return e.time})).concat([t.length])));var i=Math.max.apply(Math,n(t.map(function(e){return e.value}))),a=Math.pow(10,String(Math.round(i)).length-1),l=(1+1/this.props.yPadding,Math.max(Math.ceil(i/a)*a,1)),s=this.props.useDynamicYMin?Math.min.apply(Math,n(t.map(function(e){return e.value})))-l/5:0,p=r-o,u=l-s,f=this.activeWidth/(p||1),d=this.activeHeight/(u||1),h=this.describeLine(t,o,s,p,u,f,d),y="0,"+((x?d:u*d)-this.props.strokeWidth)+" "+h+" "+((r-o)*f-this.props.strokeWidth)+","+((x?d:u*d)-this.props.strokeWidth),m=this.describeYAxis(s,u,d),g=this.describeXAxis(o,p,f,t),x=0===u&&0===s;return t&&t.length?c.default.createElement(v.default,{width:this.props.width,height:this.props.height,type:"area"},m.gridLines.map(this.renderYGridLine.bind(this)),c.default.createElement("polygon",{points:y,style:{fill:this.props.fillColor,strokeWidth:0}}),c.default.createElement("polyline",{points:h,style:{stroke:this.props.strokeColor,strokeDasharray:this.props.strokeDasharray,strokeWidth:this.props.strokeWidth,fill:"none"}}),m.labels.map(this.renderLabel.bind(this)),g.labels.map(function(t,r){return c.default.createElement("line",{key:"graph.xAxis.label."+r,ref:t.ref+".marker",x1:t.x,x2:t.x,y1:e.activeHeight,y2:e.activeHeight+10,stroke:e.props.gridColor,strokeWidth:1})}),g.labels.map(this.renderLabel.bind(this)),this.renderPoints(t,o,s,p,u,f,d),this.renderTips(t,o,s,p,u,f,d)):null}}]),t}(d.Component);x.propTypes={width:c.default.PropTypes.number,height:c.default.PropTypes.number,border:c.default.PropTypes.string,strokeWidth:c.default.PropTypes.number,useDynamicYMin:c.default.PropTypes.bool,strokeColor:c.default.PropTypes.string,strokeDasharray:c.default.PropTypes.number,pointsRadius:c.default.PropTypes.number,showFirstAndLastTip:c.default.PropTypes.bool,tipsWidth:c.default.PropTypes.number,tipsHeight:c.default.PropTypes.number,tipsPadding:c.default.PropTypes.number,tipStrokeWidth:c.default.PropTypes.number,tipStrokeColor:c.default.PropTypes.string,tipsFill:c.default.PropTypes.string,gridColor:c.default.PropTypes.string,labelFontSize:c.default.PropTypes.number,labelTextShadow:c.default.PropTypes.string,labelColor:c.default.PropTypes.string,fillColor:c.default.PropTypes.string,maxOverflow:c.default.PropTypes.number,maxPoints:c.default.PropTypes.number,yLabelsOutside:c.default.PropTypes.bool,yLabelsPosition:c.default.PropTypes.string,formula:c.default.PropTypes.string,yPadding:c.default.PropTypes.number,data:c.default.PropTypes.array},x.defaultProps={width:640,height:320,border:"none",strokeWidth:2,useDynamicYMin:!1,strokeColor:"#408AE5",strokeDasharray:0,pointsRadius:5,showFirstAndLastTip:!1,tipsWidth:240,tipsHeight:22,tipsPadding:10,tipStrokeWidth:1,tipStrokeColor:"#BBBBBB",tipsFill:"white",gridColor:"rgba(230,230,230,.5)",labelFontSize:12,labelTextShadow:"1px 1px #fff",labelColor:"#555",labelTemplate:"{{value}}",fillColor:"rgba(191, 216, 246, 0.3)",maxOverflow:20,yLabelsOutside:!1,yLabelsPosition:"left",yPadding:10,maxPoints:-1,formula:"sum",data:[]},t.default=x},204:function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":l(t))&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":l(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),p=r(5),u=o(p),f=r(29),d=function(e){function t(){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return a(t,e),s(t,[{key:"formatValue",value:function(e){return"%"===this.props.metricName?Math.round(e):(0,f.formatNumber)(e)}},{key:"render",value:function(){return u.default.createElement("div",{style:{position:"relative",marginBottom:15}},u.default.createElement("div",{style:{fontSize:13,textTransform:"uppercase"}},this.props.label),u.default.createElement("div",{className:"bar-row"},u.default.createElement("div",{style:{backgroundColor:this.props.barRailColor,width:"100%",height:this.props.barHeight,display:"block",marginTop:4,position:"relative"}},u.default.createElement("div",{style:{width:this.props.percent+"%",height:this.props.barHeight,position:"absolute",backgroundColor:this.props.barColor,top:0,left:0,bottom:0,transition:"all .5s"}})),u.default.createElement("div",{style:{paddingLeft:this.props.metricPadding,fontSize:13,display:"inline-block",position:"absolute",right:0,top:0,fontWeight:"bold",color:this.props.metricColor,textAlign:"right"}},this.formatValue(this.props.value)+" "+this.props.metricName)))}}]),t}(u.default.Component);d.defaultProps={metricName:"points",value:"0",percent:100,metricPadding:15,metricColor:"#777",barHeight:7,barRailColor:"#ddd",barColor:"#408AE5",label:"N/A"},d.propTypes={metricName:u.default.PropTypes.string,percent:u.default.PropTypes.number,barWidth:u.default.PropTypes.number,barHeight:u.default.PropTypes.number,metricPadding:u.default.PropTypes.number,label:u.default.PropTypes.string,metricColor:u.default.PropTypes.string,barColor:u.default.PropTypes.string,barRailColor:u.default.PropTypes.string},t.default=d},205:function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":s(t))&&"function"!=typeof t?e:t}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":s(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(t,"__esModule",{value:!0});var p=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),u=r(5),f=o(u),d=r(29),c=function(e){function t(){return i(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return l(t,e),p(t,[{key:"formatValue",value:function(e){return"%"===this.props.metricName?Math.round(e):(0,d.formatNumber)(e)}},{key:"renderYGridLine",value:function(e,t){return f.default.createElement("line",{key:"graph.ygridLine."+t,x1:0,y1:e.y,x2:this.props.width,y2:e.y,style:{stroke:this.props.gridColor,strokeWidth:1}})}},{key:"describeYAxis",value:function(e,t,r){function o(e,t){return t||(t=100),e>t&&o(e,5*t),Math.ceil(e/t)*t/10}var n=this,i=o(t,t/10),a=[1,2,3,4,5,6,7,8,9],l=[0,1,2,3,4],s=0===t&&0===e;return{gridLines:a.map(function(e){return{y:s?r:(t-e*i)*r}}),labels:l.map(function(o){var a=o*i*2;return{y:s?r:(t-o*i*2)*r,txt:(0,d.formatNumber)(Math.round(a+e))+(n.props.isPercent?"%":"")}})}}},{key:"renderTip",value:function(e,t,r,o){var n=25,i=10,a=([r-n/2+","+o-10,r+n/2+","+o-10,r+","+(o+i)-10].join(" "),[r-n/2+","+o-10,r+n/2+","+o-10,r+","+(o+i)-10].join(" "),28),l=15;return f.default.createElement("g",{key:"point."+e,ref:"point."+e},f.default.createElement("text",{x:r-a/2,y:o-l/2,style:{fontSize:16,fontWeight:"bold"}},t))}},{key:"renderLabel",value:function(e,t){return e.x||("right"===this.props.yLabelsPosition?e.x=this.activeWidth+(this.props.yLabelsOutside?5:-1*(20+5*(e.txt.length||1))):e.x=0),e.ref||(e.ref="label."+t+","+e.x+","+e.y),f.default.createElement("text",{key:"graph.yAxis.label."+e.ref,x:e.x,y:e.y,ref:e.ref,fill:this.props.labelColor,style:{fontSize:this.props.labelFontSize,textShadow:this.props.labelTextShadow,textAlign:"center"}},e.txt)}},{key:"render",value:function(){var e=this,t=this.props.height-this.props.bottomBarHeight,r=0,o=1.1*Math.max.apply(Math,n(this.props.data.map(function(e){return e.value}))),i=o-r,a=t/(i||1),l=this.describeYAxis(r,i,a),s=this.props.width/this.props.data.length,p=this.props.barSize===-1?s:this.props.barSize;return this.props.data&&this.props.data.length?f.default.createElement("svg",{width:this.props.width,height:this.props.height},l.gridLines.map(this.renderYGridLine.bind(this)),this.props.data.map(function(r,o){return f.default.createElement("g",{key:"bar.item."+o},f.default.createElement("rect",{fill:e.props.barColor,width:p,height:r.value*a,y:t-r.value*a,x:o*s-p/2+s/2-p/2}),e.renderTip(o,r.value+(e.props.isPercent?"%":""),o*s-p/2+s/2,t-r.value*a))}),l.labels.map(this.renderLabel.bind(this)),this.props.data.map(function(r,o){return f.default.createElement("text",{key:"graph.xAxis.label."+o,x:o*s-p/2+s/2-5,y:t+e.props.bottomBarHeight,fill:e.props.labelColor,style:{fontSize:e.props.labelFontSize,textShadow:e.props.labelTextShadow}},r.label)})):null}}]),t}(f.default.Component);c.defaultProps={data:[],metricName:"points",metricColor:"#777",barSize:20,barRailColor:null,barColor:"#408AE5",gridColor:"rgba(230,230,230,.5)",label:"N/A",width:400,height:200,bottomBarHeight:20,yLabelsOutside:!0,labelFontSize:12,labelTextShadow:"1px 1px #fff",labelColor:"#555",isPercent:!1,labelTemplate:"{{value}}"},c.propTypes={metricName:f.default.PropTypes.string,barSize:f.default.PropTypes.number,label:f.default.PropTypes.string,metricColor:f.default.PropTypes.string,barColor:f.default.PropTypes.string,barRailColor:f.default.PropTypes.string},t.default=c},206:function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var n=r(203),i=o(n),a=r(205),l=o(a),s=r(207),p=o(s),u=r(204),f=o(u);t.default={Area:i.default,CirclePie:p.default,BarMetric:f.default,Bar:l.default}},207:function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==("undefined"==typeof t?"undefined":l(t))&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+("undefined"==typeof t?"undefined":l(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),p=r(5),u=o(p),f=r(102),d=o(f),c=function(e){function t(){return n(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return a(t,e),s(t,[{key:"polarToCartesian",value:function(e,t,r,o){var n=(o-90)*Math.PI/180;return{x:e+r*Math.cos(n),y:t+r*Math.sin(n)}}},{key:"describeArc",value:function(e,t,r,o,n){e&&t||console.error("x or y missing to describeArc");var i=this.polarToCartesian(e,t,r,n),a=this.polarToCartesian(e,t,r,o),l=n-o<=180?"0":"1";return["M",i.x,i.y,"A",r,r,0,l,0,a.x,a.y].join(" ")}},{key:"render",value:function(){var e=this.props.width/2-this.props.strokeWidth/2-this.props.padding,t=e+this.props.strokeWidth/2+this.props.padding,r=0,o=3.6*this.props.percent,n=this.props.percent+"%",i=3===n.length?-.95:-.6,a=this.describeArc(t,t,e,r,o);return u.default.createElement(d.default,{width:this.props.width,style:this.props.style,height:this.props.height,border:this.props.border},u.default.createElement("circle",{cx:t,cy:t,r:e,fill:this.props.fillColor,stroke:this.props.railColor,strokeWidth:this.props.strokeWidth}),u.default.createElement("path",{fill:this.props.fillColor,stroke:this.props.strokeColor,strokeWidth:this.props.strokeWidth,d:a}),u.default.createElement("text",{x:t,y:t,dx:i+"em",dy:".35em",fill:this.props.labelColor,fontWeight:this.props.labelFontWeight,fontSize:this.props.labelFontSize},n))}}]),t}(p.Component);c.propTypes={width:u.default.PropTypes.number,height:u.default.PropTypes.number,strokeWidth:u.default.PropTypes.number,strokeColor:u.default.PropTypes.string,labelFontWeight:u.default.PropTypes.string,labelFontSize:u.default.PropTypes.string,fillColor:u.default.PropTypes.string,startAngle:u.default.PropTypes.number,endAngle:u.default.PropTypes.number,radius:u.default.PropTypes.number,style:u.default.PropTypes.object},c.defaultProps={width:150,height:150,border:"none",strokeWidth:10,style:{},labelColor:"#408AE5",labelFontSize:"1.2em",labelFontWeight:"bold",strokeColor:"#408AE5",railColor:"#f5f5f5",fillColor:"none",percent:70,padding:0},t.default=c}}); | ||
//# sourceMappingURL=salad-ui.chart.js.map |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
181746