react-svg-radar-chart
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -1,2 +0,2 @@ | ||
!function(e,t){if("object"===typeof exports&&"object"===typeof module)module.exports=t(require("react"));else if("function"===typeof define&&define.amd)define(["react"],t);else{var n=t("object"===typeof exports?require("react"):e.react);for(var r in n)("object"===typeof exports?exports:e)[r]=n[r]}}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(t,n){t.exports=e},function(e,t,n){e.exports=n(2)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3);t.default=r.a},function(e,t,n){"use strict";var r=n(0),o=n.n(r),a=n(4),i=(n.n(a),n(5)),s=function(e){for(var t="M"+e[0][0].toFixed(4)+","+e[0][1].toFixed(4),n=1;n<e.length;n++)t+="L"+e[n][0].toFixed(4)+","+e[n][1].toFixed(4);return t+"z"},c=function(e){return"-"+e.captionMargin+" 0 "+(e.size+2*e.captionMargin)+" "+e.size},u={size:300,axes:!0,scales:3,captions:!0,dots:!1,zoomDistance:1.2,smoothing:s,captionMargin:10,setViewBox:c,axisProps:function(){return{className:"axis"}},scaleProps:function(){return{className:"scale",fill:"none"}},shapeProps:function(){return{className:"shape"}},dotProps:function(){return{className:"dot"}},captionProps:function(){return{className:"caption",textAnchor:"middle",fontSize:10,fontFamily:"sans-serif"}},rotation:0},l=function(e){var t=e.data,n=e.captions,r=e.options,a=e.size,s=void 0===a?u.size:a,c=e.id,l=Object.assign({},u,r,{size:s}),f=l.setViewBox,p=Object(i.a)(n,t,l);return o.a.createElement("svg",{version:"1",xmlns:"http://www.w3.org/2000/svg",width:s,height:s,viewBox:f(l),id:c},p)};t.a=l},function(e,t){},function(e,t,n){"use strict";var r=n(0),o=n.n(r),a="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},i=function(e,t){return Math.cos(e-Math.PI/2)*t},s=function(e,t){return Math.sin(e-Math.PI/2)*t},c=function(e){return e.map(function(e){return e[0].toFixed(4)+","+e[1].toFixed(4)}).join(" ")},u=function(e){return function(t,n){return o.a.createElement("polyline",Object.assign({key:"poly-axis-"+n,points:c([[0,0],[i(t.angle,e.chartSize/2),s(t.angle,e.chartSize/2)]])},e.axisProps(t)))}},l=function(e,t){return function(n,r){var a=n.data,c=n.meta||{},u=t.dotProps(c),l={},f=function(){},p=function(){};return u.mouseEnter&&(f=u.mouseEnter),u.mouseLeave&&(p=u.mouseLeave),u.r&&(l.r=u.r),u.fill&&(l.fill=u.fill),u.stoke&&(l.stroke=u.stroke),u.stokeWidth&&(l.strokeWidth=u.strokeWidth),e.map(function(e){var n=a[e.key];if("number"!==typeof n)throw new Error("Data set "+r+" is invalid.");return o.a.createElement("circle",Object.assign({key:"dot-"+e.key+"-"+n,cx:i(e.angle,n*t.chartSize/2),cy:s(e.angle,n*t.chartSize/2),className:[u.className,c.class].join(" "),onMouseEnter:function(){return f({key:e.key,value:n,idx:r})},onMouseLeave:function(){return p({})}},l))})}},f=function(e,t){return function(n,r){var a=n.data,c=n.meta||{},u=t.shapeProps(c),l={};return c.fill||(c.fill=c.color),c.strokeWidth&&(l.strokeWidth=c.strokeWidth),c.strokeDasharray&&(l.strokeDasharray=c.strokeDasharray),c.strokeLinecap&&(l.strokeLinecap=c.strokeLinecap),o.a.createElement("path",Object.assign({key:"shape-"+r,d:t.smoothing(e.map(function(e){var n=a[e.key];if("number"!==typeof n)throw new Error("Data set "+r+" is invalid.");return[i(e.angle,n*t.chartSize/2),s(e.angle,n*t.chartSize/2)]}))},u,l,{stroke:c.color,fill:c.fill,className:[u.className,c.class].join(" ")}))}},p=function(e,t){return o.a.createElement("circle",Object.assign({key:"circle-"+t,cx:0,cy:0,r:t*e.chartSize/2},e.scaleProps(t)))},y=function(e){return function(t){return o.a.createElement("text",Object.assign({key:"caption-of-"+t.key,x:i(t.angle,e.size/2*.95).toFixed(4),y:s(t.angle,e.size/2*.95).toFixed(4),dy:(e.captionProps(t).fontSize||10)/2},e.captionProps(t)),t.caption)}},m=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("object"!==("undefined"===typeof e?"undefined":a(e))||Array.isArray(e))throw new Error("caption must be an object");if(!Array.isArray(t))throw new Error("data must be an array");n.chartSize=n.size/n.zoomDistance;var r=n.rotation,i=void 0===r?0:r,s=Object.keys(e).map(function(t,n,r){var o=2*Math.PI*n/r.length+i*(Math.PI/180);return{key:t,caption:e[t],angle:o}}),c=[o.a.createElement("g",{key:"g-groups}"},t.map(f(s,n)))];if(n.captions&&c.push(o.a.createElement("g",{key:"poly-captions"},s.map(y(n)))),n.dots&&c.push(o.a.createElement("g",{key:"g-dots"},t.map(l(s,n)))),n.axes&&c.unshift(o.a.createElement("g",{key:"group-axes"},s.map(u(n)))),n.scales>0){for(var m=[],d=n.scales;d>0;d--)m.push(p(n,d/n.scales));c.unshift(o.a.createElement("g",{key:"poly-scales"},m))}var h=(n.size/2).toFixed(4);return o.a.createElement("g",{transform:"translate("+h+","+h+")"},c)};t.a=m}])}); | ||
!function(e,t){if("object"===typeof exports&&"object"===typeof module)module.exports=t(require("react"));else if("function"===typeof define&&define.amd)define(["react"],t);else{var n=t("object"===typeof exports?require("react"):e.react);for(var r in n)("object"===typeof exports?exports:e)[r]=n[r]}}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(t,n){t.exports=e},function(e,t,n){e.exports=n(2)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3);t.default=r.a},function(e,t,n){"use strict";var r=n(0),o=n.n(r),a=n(4),i=(n.n(a),n(5)),s=function(e){for(var t="M"+e[0][0].toFixed(4)+","+e[0][1].toFixed(4),n=1;n<e.length;n++)t+="L"+e[n][0].toFixed(4)+","+e[n][1].toFixed(4);return t+"z"},c=function(e){return"-"+e.captionMargin+" 0 "+(e.size+2*e.captionMargin)+" "+e.size},u={size:300,axes:!0,scales:3,captions:!0,dots:!1,zoomDistance:1.2,smoothing:s,captionMargin:10,setViewBox:c,axisProps:function(){return{className:"axis"}},scaleProps:function(){return{className:"scale",fill:"none"}},shapeProps:function(){return{className:"shape"}},dotProps:function(){return{className:"dot"}},captionProps:function(){return{className:"caption",textAnchor:"middle",fontSize:10,fontFamily:"sans-serif"}},rotation:0,wrapCaptionAt:15,captionLineHeight:20},l=function(e){var t=e.data,n=e.captions,r=e.options,a=e.size,s=void 0===a?u.size:a,c=e.id,l=Object.assign({},u,r,{size:s}),p=l.setViewBox,f=Object(i.a)(n,t,l);return o.a.createElement("svg",{version:"1",xmlns:"http://www.w3.org/2000/svg",width:s,height:s,viewBox:p(l),id:c},f)};t.a=l},function(e,t){},function(e,t,n){"use strict";var r=n(0),o=n.n(r),a="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},i=function(e,t){return Math.cos(e-Math.PI/2)*t},s=function(e,t){return Math.sin(e-Math.PI/2)*t},c=function(e){return e.map(function(e){return e[0].toFixed(4)+","+e[1].toFixed(4)}).join(" ")},u=function(e){return function(t,n){return o.a.createElement("polyline",Object.assign({key:"poly-axis-"+n,points:c([[0,0],[i(t.angle,e.chartSize/2),s(t.angle,e.chartSize/2)]])},e.axisProps(t)))}},l=function(e,t){return function(n,r){var a=n.data,c=n.meta||{},u=t.dotProps(c),l={},p=function(){},f=function(){};return u.mouseEnter&&(p=u.mouseEnter),u.mouseLeave&&(f=u.mouseLeave),u.r&&(l.r=u.r),u.fill&&(l.fill=u.fill),u.stoke&&(l.stroke=u.stroke),u.stokeWidth&&(l.strokeWidth=u.strokeWidth),e.map(function(e){var n=a[e.key];if("number"!==typeof n)throw new Error("Data set "+r+" is invalid.");return o.a.createElement("circle",Object.assign({key:"dot-"+e.key+"-"+n,cx:i(e.angle,n*t.chartSize/2),cy:s(e.angle,n*t.chartSize/2),className:[u.className,c.class].join(" "),onMouseEnter:function(){return p({key:e.key,value:n,idx:r})},onMouseLeave:function(){return f({})}},l))})}},p=function(e,t){return function(n,r){var a=n.data,c=n.meta||{},u=t.shapeProps(c),l={};return c.fill||(c.fill=c.color),c.strokeWidth&&(l.strokeWidth=c.strokeWidth),c.strokeDasharray&&(l.strokeDasharray=c.strokeDasharray),c.strokeLinecap&&(l.strokeLinecap=c.strokeLinecap),o.a.createElement("path",Object.assign({key:"shape-"+r,d:t.smoothing(e.map(function(e){var n=a[e.key];if("number"!==typeof n)throw new Error("Data set "+r+" is invalid.");return[i(e.angle,n*t.chartSize/2),s(e.angle,n*t.chartSize/2)]}))},u,l,{stroke:c.color,fill:c.fill,className:[u.className,c.class].join(" ")}))}},f=function(e,t){return o.a.createElement("circle",Object.assign({key:"circle-"+t,cx:0,cy:0,r:t*e.chartSize/2},e.scaleProps(t)))},y=function(e){return function(t){var n=1;t.caption.length>e.wrapCaptionAt&&(n=Math.round(t.caption.length/e.wrapCaptionAt));var r=(e.captionProps(t).fontSize||12)/2;return new Array(n).fill().map(function(n,a){return o.a.createElement("text",Object.assign({key:"caption-of-"+t.key+"-"+a,x:i(t.angle,e.size/2*.95).toFixed(4),y:(s(t.angle,e.size/2*.95)+e.captionLineHeight*a).toFixed(4),dy:r},e.captionProps(t)),t.caption.substring(a*e.wrapCaptionAt,(a+1)*e.wrapCaptionAt))})}},m=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("object"!==("undefined"===typeof e?"undefined":a(e))||Array.isArray(e))throw new Error("caption must be an object");if(!Array.isArray(t))throw new Error("data must be an array");n.chartSize=n.size/n.zoomDistance;var r=n.rotation,i=void 0===r?0:r,s=Object.keys(e).map(function(t,n,r){var o=2*Math.PI*n/r.length+i*(Math.PI/180);return{key:t,caption:e[t],angle:o}}),c=[o.a.createElement("g",{key:"g-groups}"},t.map(p(s,n)))];if(n.captions&&c.push(o.a.createElement("g",{key:"poly-captions"},s.map(y(n)))),n.dots&&c.push(o.a.createElement("g",{key:"g-dots"},t.map(l(s,n)))),n.axes&&c.unshift(o.a.createElement("g",{key:"group-axes"},s.map(u(n)))),n.scales>0){for(var m=[],d=n.scales;d>0;d--)m.push(f(n,d/n.scales));c.unshift(o.a.createElement("g",{key:"poly-scales"},m))}var h=(n.size/2).toFixed(4);return o.a.createElement("g",{transform:"translate("+h+","+h+")"},c)};t.a=m}])}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "react-svg-radar-chart", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "A reusable radar chart in SVG.", | ||
@@ -28,3 +28,3 @@ "main": "build/index.js", | ||
"author": "https://github.com/Spyna", | ||
"homepage": "https://github.com/Spyna/react-svg-radar-chart/#readme", | ||
"homepage": "https://spyna.github.io/react-svg-radar-chart/", | ||
"bugs": { | ||
@@ -31,0 +31,0 @@ "url": "https://github.com/Spyna/react-svg-radar-chart/issues" |
@@ -307,2 +307,3 @@ | ||
| rotation | default `0`: The rotation (clockwise) in degrees. A number that indicates the rotation of the shape and captions. It must be beetween 0 and 360. Eg: `180` makes the chart upside down. `90` rotates the chart of 90 degrees. | | ||
| wrapCaptionAt | default `15`: The max length of the caption before it is wrapped in a new line | | ||
| captionLineHeight | default `20`: The height of the line of a caption when it is wrapped in a new line | |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50943
8
24