Socket
Socket
Sign inDemoInstall

vue-css-donut-chart

Package Overview
Dependencies
10
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 1.1.3

8

CHANGELOG.md

@@ -5,2 +5,10 @@ # Changelog

## [1.1.3]
### Fixed
- 1.1.2 broke the usage of `%` unit (#10). That's fixed now.
- Font size is now recalculated only when the chart has rendered.
## [1.1.2]

@@ -7,0 +15,0 @@

19

dist/vcdonut.common.js

@@ -163,3 +163,3 @@ module.exports =

// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"40566109-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Donut.vue?vue&type=template&id=1754f022&
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"40566109-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Donut.vue?vue&type=template&id=651bd70d&
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"cdc-container",style:(_vm.placementStyles.container)},[_c('div',{ref:"donut",staticClass:"cdc",style:(_vm.donutStyles)},[_c('DonutSections',{attrs:{"sections":_vm.donutSections,"start-angle":_vm.startAngle},on:{"section-click":_vm.emitSectionClick}}),_c('div',{staticClass:"cdc-overlay",style:(_vm.overlayStyles)},[_c('div',{staticClass:"cdc-text",style:(_vm.donutTextStyles)},[_vm._t("default",[_vm._v(_vm._s(_vm.text))])],2)])],1),_vm._t("legend",[(_vm.hasLegend)?_c('div',{staticClass:"cdc-legend",style:(_vm.placementStyles.legend)},_vm._l((_vm.legend),function(item,idx){return _c('span',{key:idx,staticClass:"cdc-legend-item",attrs:{"title":item.percent}},[_c('span',{staticClass:"cdc-legend-item-color",style:(item.styles)}),_c('span',[_vm._v(_vm._s(item.label))])])}),0):_vm._e()])],2)}

@@ -169,3 +169,3 @@ var staticRenderFns = []

// CONCATENATED MODULE: ./src/components/Donut.vue?vue&type=template&id=1754f022&
// CONCATENATED MODULE: ./src/components/Donut.vue?vue&type=template&id=651bd70d&

@@ -650,4 +650,4 @@ // CONCATENATED MODULE: ./src/utils/colors.js

var styles = {
height: size,
width: size,
paddingBottom: size,
backgroundColor: this.foreground

@@ -679,10 +679,13 @@ };

recalcFontSize: function recalcFontSize() {
var _this3 = this;
var scaleDownBy = 0.08;
var widthInPx = this.size;
this.$nextTick(function () {
if (_this3.unit !== 'px') {
if (_this3.donutEl) widthInPx = _this3.donutEl.clientWidth;else widthInPx = null;
}
if (this.unit !== 'px') {
if (this.donutEl) widthInPx = this.donutEl.clientWidth;else widthInPx = null;
}
this.fontSize = widthInPx ? "".concat((widthInPx * scaleDownBy).toFixed(2), "px") : '1em';
_this3.fontSize = widthInPx ? "".concat((widthInPx * scaleDownBy).toFixed(2), "px") : '1em';
});
},

@@ -689,0 +692,0 @@ emitSectionClick: function emitSectionClick(section) {

@@ -172,3 +172,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"40566109-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Donut.vue?vue&type=template&id=1754f022&
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"40566109-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Donut.vue?vue&type=template&id=651bd70d&
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"cdc-container",style:(_vm.placementStyles.container)},[_c('div',{ref:"donut",staticClass:"cdc",style:(_vm.donutStyles)},[_c('DonutSections',{attrs:{"sections":_vm.donutSections,"start-angle":_vm.startAngle},on:{"section-click":_vm.emitSectionClick}}),_c('div',{staticClass:"cdc-overlay",style:(_vm.overlayStyles)},[_c('div',{staticClass:"cdc-text",style:(_vm.donutTextStyles)},[_vm._t("default",[_vm._v(_vm._s(_vm.text))])],2)])],1),_vm._t("legend",[(_vm.hasLegend)?_c('div',{staticClass:"cdc-legend",style:(_vm.placementStyles.legend)},_vm._l((_vm.legend),function(item,idx){return _c('span',{key:idx,staticClass:"cdc-legend-item",attrs:{"title":item.percent}},[_c('span',{staticClass:"cdc-legend-item-color",style:(item.styles)}),_c('span',[_vm._v(_vm._s(item.label))])])}),0):_vm._e()])],2)}

@@ -178,3 +178,3 @@ var staticRenderFns = []

// CONCATENATED MODULE: ./src/components/Donut.vue?vue&type=template&id=1754f022&
// CONCATENATED MODULE: ./src/components/Donut.vue?vue&type=template&id=651bd70d&

@@ -659,4 +659,4 @@ // CONCATENATED MODULE: ./src/utils/colors.js

var styles = {
height: size,
width: size,
paddingBottom: size,
backgroundColor: this.foreground

@@ -688,10 +688,13 @@ };

recalcFontSize: function recalcFontSize() {
var _this3 = this;
var scaleDownBy = 0.08;
var widthInPx = this.size;
this.$nextTick(function () {
if (_this3.unit !== 'px') {
if (_this3.donutEl) widthInPx = _this3.donutEl.clientWidth;else widthInPx = null;
}
if (this.unit !== 'px') {
if (this.donutEl) widthInPx = this.donutEl.clientWidth;else widthInPx = null;
}
this.fontSize = widthInPx ? "".concat((widthInPx * scaleDownBy).toFixed(2), "px") : '1em';
_this3.fontSize = widthInPx ? "".concat((widthInPx * scaleDownBy).toFixed(2), "px") : '1em';
});
},

@@ -698,0 +701,0 @@ emitSectionClick: function emitSectionClick(section) {

@@ -1,1 +0,1 @@

(function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["vcdonut"]=e():t["vcdonut"]=e()})("undefined"!==typeof self?self:this,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s="fb15")}({"7e79":function(t,e,n){},f6fd:function(t,e){(function(t){var e="currentScript",n=t.getElementsByTagName("script");e in t||Object.defineProperty(t,e,{get:function(){try{throw new Error}catch(r){var t,e=(/.*at [^\(]*\((.*):.+:.+\)$/gi.exec(r.stack)||[!1])[1];for(t in n)if(n[t].src==e||"interactive"==n[t].readyState)return n[t];return null}}})})(document)},fb15:function(t,e,n){"use strict";var r;(n.r(e),"undefined"!==typeof window)&&(n("f6fd"),(r=window.document.currentScript)&&(r=r.src.match(/(.+\/)[^\/]+\.js(\?.*)?$/))&&(n.p=r[1]));var o,i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"cdc-container",style:t.placementStyles.container},[n("div",{ref:"donut",staticClass:"cdc",style:t.donutStyles},[n("DonutSections",{attrs:{sections:t.donutSections,"start-angle":t.startAngle},on:{"section-click":t.emitSectionClick}}),n("div",{staticClass:"cdc-overlay",style:t.overlayStyles},[n("div",{staticClass:"cdc-text",style:t.donutTextStyles},[t._t("default",[t._v(t._s(t.text))])],2)])],1),t._t("legend",[t.hasLegend?n("div",{staticClass:"cdc-legend",style:t.placementStyles.legend},t._l(t.legend,function(e,r){return n("span",{key:r,staticClass:"cdc-legend-item",attrs:{title:e.percent}},[n("span",{staticClass:"cdc-legend-item-color",style:e.styles}),n("span",[t._v(t._s(e.label))])])}),0):t._e()])],2)},c=[],s=["#FF6384","#36A2EB","#FFCE56","#F58231","#46F0F0","#D2F53C","#911EB4","#F032E6","#3CB44B","#FFE119","#E6194B","#FABEBE","#008080","#E6BEFF","#0082C8","#AA6E28","#FFFAC8","#800000","#AAFFC3","#808000","#FFD8B1","#000080","#808080","#000000"],l=s;function a(t){return a="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}function u(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var f="1em",d="dodgerblue",p={TOP:"top",RIGHT:"right",BOTTOM:"bottom",LEFT:"left"},y=(o={},u(o,p.TOP,{container:{flexDirection:"column"},legend:{order:-1,margin:0,marginBottom:f}}),u(o,p.RIGHT,{container:{},legend:{flexDirection:"column",margin:0,marginLeft:f}}),u(o,p.BOTTOM,{container:{flexDirection:"column"},legend:{}}),u(o,p.LEFT,{container:{},legend:{flexDirection:"column",order:-1,margin:0,marginRight:f}}),o),h=function(t){return!!t&&t.constructor===Object},m=[{type:"number",key:"value",required:!0},{key:"label"},{key:"color"}];function v(t){return!!h(t)&&m.reduce(function(e,n){if(!e)return!1;var r=!0;return n.required&&(r=r&&Object.hasOwnProperty.call(t,n.key)),n.type&&(r=r&&a(t[n.key])===n.type),e&&r},!0)}var g=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"cdc-sections",style:t.containerStyles},t._l(t.dSections,function(e,r){return n("div",{key:r,staticClass:"cdc-section",class:e.className,style:e.sectionStyles,on:{click:function(e){return t.emitClick(t.sections[r])}}},[n("div",{staticClass:"cdc-filler",style:e.fillerStyles,attrs:{title:e.label}})])}),0)},b=[],S={LEFT:"cdc-section-left",RIGHT:"cdc-section-right"},_={props:{startAngle:{type:Number,default:0},sections:{type:Array,default:function(){return[]}}},computed:{containerStyles:function(){return{transform:"rotate(".concat(this.startAngle,"deg)")}},dSections:function(){var t=180,e=0,n=0,r=this.sections.map(function(r){var o=[S.RIGHT,-180],i=o[0],c=o[1];if(e>=t){var s=[S.LEFT,180];i=s[0],c=s[1]}var l=c+r.degree,a={backgroundColor:r.color||d,transform:"rotate(".concat(l,"deg)")},u={transform:"rotate(".concat(n,"deg)")};return e+=r.degree,180===e?n=0:n+=r.degree,{label:r.label,className:i,fillerStyles:a,sectionStyles:u}});return r}},methods:{emitClick:function(t){this.$emit("section-click",t)}}},C=_;function E(t,e,n,r,o,i,c,s){var l,a="function"===typeof t?t.options:t;if(e&&(a.render=e,a.staticRenderFns=n,a._compiled=!0),r&&(a.functional=!0),i&&(a._scopeId="data-v-"+i),c?(l=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),o&&o.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(c)},a._ssrRegister=l):o&&(l=s?function(){o.call(this,this.$root.$options.shadowRoot)}:o),l)if(a.functional){a._injectStyles=l;var u=a.render;a.render=function(t,e){return l.call(e),u(t,e)}}else{var f=a.beforeCreate;a.beforeCreate=f?[].concat(f,l):[l]}return{exports:t,options:a}}var F=E(C,g,b,!1,null,null,null),x=F.exports,O=(n("7e79"),{name:"vc-donut",props:{size:{type:Number,default:250,validator:function(t){return t>0}},unit:{type:String,default:"px"},thickness:{type:Number,default:20,validator:function(t){return t>=0&&t<=100}},text:{type:String,default:null},background:{type:String,default:"#ffffff"},foreground:{type:String,default:"#eeeeee"},sections:{type:Array,default:function(){return[]},validator:function(t){for(var e=0;e<t.length;++e)if(!v(t[e]))return!1;return!0}},total:{type:Number,default:100,validator:function(t){return t>0}},hasLegend:{type:Boolean,default:!1},legendPlacement:{default:p.BOTTOM,validator:function(t){return!!p[t.toUpperCase()]}},startAngle:{type:Number,default:0}},watch:{size:function(){this.recalcFontSize()},unit:function(){this.recalcFontSize()}},data:function(){return{donutEl:null,fontSize:"1em",resizeListener:null}},computed:{donutSections:function(){var t=this,e=this.sections.reduce(function(t,e){return t+e.value},0);if(e>this.total){var n="Sum of all the sections' values (".concat(e,") should not exceed `total` (").concat(this.total,")");throw new Error(n)}var r=360,o=180,i=0,c=0,s=[];return this.sections.forEach(function(e){var n=r*(e.value/t.total),a=[n];n>o&&(a=[o,n-o]);var u=e.color||l[c++];a.forEach(function(t){var n=i+t;if(n>o){var r=o-i;s.push(Object.assign({},e,{degree:r,color:u}),Object.assign({},e,{degree:t-r,color:u}))}else s.push(Object.assign({},e,{degree:t,color:u}));i+=t,i>=o&&(i-=o)})}),s},legend:function(){var t=this;if(!this.hasLegend)return null;var e=0;return this.sections.map(function(n,r){return{label:n.label||"Section ".concat(r+1),percent:"".concat(n.value," (").concat(n.value/t.total*100,"%)"),styles:{backgroundColor:n.color||l[e++]}}})},placementStyles:function(){return this.hasLegend?y[this.legendPlacement]:{}},donutStyles:function(){var t="".concat(this.size).concat(this.unit),e={height:t,width:t,backgroundColor:this.foreground};return e},overlayStyles:function(){var t=100,e=t-this.thickness,n="".concat(e,"%"),r="calc(50% - ".concat(e/2,"%)");return{height:n,width:n,top:r,left:r,backgroundColor:this.background}},donutTextStyles:function(){var t=this.fontSize;return{fontSize:t}}},methods:{recalcFontSize:function(){var t=.08,e=this.size;"px"!==this.unit&&(e=this.donutEl?this.donutEl.clientWidth:null),this.fontSize=e?"".concat((e*t).toFixed(2),"px"):"1em"},emitSectionClick:function(t){this.$emit("section-click",t)}},mounted:function(){this.donutEl=this.$refs.donut,this.recalcFontSize(),this.resizeListener=this.recalcFontSize.bind(this),window.addEventListener("resize",this.resizeListener)},beforeDestroy:function(){window.removeEventListener("resize",this.resizeListener)},components:{DonutSections:x}}),T=O,k=E(T,i,c,!1,null,null,null),j=k.exports,w={install:function(t){t.component(j.name,j)}},z=w;e["default"]=z}})});
(function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["vcdonut"]=e():t["vcdonut"]=e()})("undefined"!==typeof self?self:this,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s="fb15")}({"7e79":function(t,e,n){},f6fd:function(t,e){(function(t){var e="currentScript",n=t.getElementsByTagName("script");e in t||Object.defineProperty(t,e,{get:function(){try{throw new Error}catch(r){var t,e=(/.*at [^\(]*\((.*):.+:.+\)$/gi.exec(r.stack)||[!1])[1];for(t in n)if(n[t].src==e||"interactive"==n[t].readyState)return n[t];return null}}})})(document)},fb15:function(t,e,n){"use strict";var r;(n.r(e),"undefined"!==typeof window)&&(n("f6fd"),(r=window.document.currentScript)&&(r=r.src.match(/(.+\/)[^\/]+\.js(\?.*)?$/))&&(n.p=r[1]));var o,i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"cdc-container",style:t.placementStyles.container},[n("div",{ref:"donut",staticClass:"cdc",style:t.donutStyles},[n("DonutSections",{attrs:{sections:t.donutSections,"start-angle":t.startAngle},on:{"section-click":t.emitSectionClick}}),n("div",{staticClass:"cdc-overlay",style:t.overlayStyles},[n("div",{staticClass:"cdc-text",style:t.donutTextStyles},[t._t("default",[t._v(t._s(t.text))])],2)])],1),t._t("legend",[t.hasLegend?n("div",{staticClass:"cdc-legend",style:t.placementStyles.legend},t._l(t.legend,function(e,r){return n("span",{key:r,staticClass:"cdc-legend-item",attrs:{title:e.percent}},[n("span",{staticClass:"cdc-legend-item-color",style:e.styles}),n("span",[t._v(t._s(e.label))])])}),0):t._e()])],2)},c=[],s=["#FF6384","#36A2EB","#FFCE56","#F58231","#46F0F0","#D2F53C","#911EB4","#F032E6","#3CB44B","#FFE119","#E6194B","#FABEBE","#008080","#E6BEFF","#0082C8","#AA6E28","#FFFAC8","#800000","#AAFFC3","#808000","#FFD8B1","#000080","#808080","#000000"],l=s;function a(t){return a="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}function u(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var f="1em",d="dodgerblue",p={TOP:"top",RIGHT:"right",BOTTOM:"bottom",LEFT:"left"},y=(o={},u(o,p.TOP,{container:{flexDirection:"column"},legend:{order:-1,margin:0,marginBottom:f}}),u(o,p.RIGHT,{container:{},legend:{flexDirection:"column",margin:0,marginLeft:f}}),u(o,p.BOTTOM,{container:{flexDirection:"column"},legend:{}}),u(o,p.LEFT,{container:{},legend:{flexDirection:"column",order:-1,margin:0,marginRight:f}}),o),m=function(t){return!!t&&t.constructor===Object},v=[{type:"number",key:"value",required:!0},{key:"label"},{key:"color"}];function h(t){return!!m(t)&&v.reduce(function(e,n){if(!e)return!1;var r=!0;return n.required&&(r=r&&Object.hasOwnProperty.call(t,n.key)),n.type&&(r=r&&a(t[n.key])===n.type),e&&r},!0)}var g=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"cdc-sections",style:t.containerStyles},t._l(t.dSections,function(e,r){return n("div",{key:r,staticClass:"cdc-section",class:e.className,style:e.sectionStyles,on:{click:function(e){return t.emitClick(t.sections[r])}}},[n("div",{staticClass:"cdc-filler",style:e.fillerStyles,attrs:{title:e.label}})])}),0)},b=[],S={LEFT:"cdc-section-left",RIGHT:"cdc-section-right"},_={props:{startAngle:{type:Number,default:0},sections:{type:Array,default:function(){return[]}}},computed:{containerStyles:function(){return{transform:"rotate(".concat(this.startAngle,"deg)")}},dSections:function(){var t=180,e=0,n=0,r=this.sections.map(function(r){var o=[S.RIGHT,-180],i=o[0],c=o[1];if(e>=t){var s=[S.LEFT,180];i=s[0],c=s[1]}var l=c+r.degree,a={backgroundColor:r.color||d,transform:"rotate(".concat(l,"deg)")},u={transform:"rotate(".concat(n,"deg)")};return e+=r.degree,180===e?n=0:n+=r.degree,{label:r.label,className:i,fillerStyles:a,sectionStyles:u}});return r}},methods:{emitClick:function(t){this.$emit("section-click",t)}}},C=_;function E(t,e,n,r,o,i,c,s){var l,a="function"===typeof t?t.options:t;if(e&&(a.render=e,a.staticRenderFns=n,a._compiled=!0),r&&(a.functional=!0),i&&(a._scopeId="data-v-"+i),c?(l=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),o&&o.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(c)},a._ssrRegister=l):o&&(l=s?function(){o.call(this,this.$root.$options.shadowRoot)}:o),l)if(a.functional){a._injectStyles=l;var u=a.render;a.render=function(t,e){return l.call(e),u(t,e)}}else{var f=a.beforeCreate;a.beforeCreate=f?[].concat(f,l):[l]}return{exports:t,options:a}}var F=E(C,g,b,!1,null,null,null),x=F.exports,T=(n("7e79"),{name:"vc-donut",props:{size:{type:Number,default:250,validator:function(t){return t>0}},unit:{type:String,default:"px"},thickness:{type:Number,default:20,validator:function(t){return t>=0&&t<=100}},text:{type:String,default:null},background:{type:String,default:"#ffffff"},foreground:{type:String,default:"#eeeeee"},sections:{type:Array,default:function(){return[]},validator:function(t){for(var e=0;e<t.length;++e)if(!h(t[e]))return!1;return!0}},total:{type:Number,default:100,validator:function(t){return t>0}},hasLegend:{type:Boolean,default:!1},legendPlacement:{default:p.BOTTOM,validator:function(t){return!!p[t.toUpperCase()]}},startAngle:{type:Number,default:0}},watch:{size:function(){this.recalcFontSize()},unit:function(){this.recalcFontSize()}},data:function(){return{donutEl:null,fontSize:"1em",resizeListener:null}},computed:{donutSections:function(){var t=this,e=this.sections.reduce(function(t,e){return t+e.value},0);if(e>this.total){var n="Sum of all the sections' values (".concat(e,") should not exceed `total` (").concat(this.total,")");throw new Error(n)}var r=360,o=180,i=0,c=0,s=[];return this.sections.forEach(function(e){var n=r*(e.value/t.total),a=[n];n>o&&(a=[o,n-o]);var u=e.color||l[c++];a.forEach(function(t){var n=i+t;if(n>o){var r=o-i;s.push(Object.assign({},e,{degree:r,color:u}),Object.assign({},e,{degree:t-r,color:u}))}else s.push(Object.assign({},e,{degree:t,color:u}));i+=t,i>=o&&(i-=o)})}),s},legend:function(){var t=this;if(!this.hasLegend)return null;var e=0;return this.sections.map(function(n,r){return{label:n.label||"Section ".concat(r+1),percent:"".concat(n.value," (").concat(n.value/t.total*100,"%)"),styles:{backgroundColor:n.color||l[e++]}}})},placementStyles:function(){return this.hasLegend?y[this.legendPlacement]:{}},donutStyles:function(){var t="".concat(this.size).concat(this.unit),e={width:t,paddingBottom:t,backgroundColor:this.foreground};return e},overlayStyles:function(){var t=100,e=t-this.thickness,n="".concat(e,"%"),r="calc(50% - ".concat(e/2,"%)");return{height:n,width:n,top:r,left:r,backgroundColor:this.background}},donutTextStyles:function(){var t=this.fontSize;return{fontSize:t}}},methods:{recalcFontSize:function(){var t=this,e=.08,n=this.size;this.$nextTick(function(){"px"!==t.unit&&(n=t.donutEl?t.donutEl.clientWidth:null),t.fontSize=n?"".concat((n*e).toFixed(2),"px"):"1em"})},emitSectionClick:function(t){this.$emit("section-click",t)}},mounted:function(){this.donutEl=this.$refs.donut,this.recalcFontSize(),this.resizeListener=this.recalcFontSize.bind(this),window.addEventListener("resize",this.resizeListener)},beforeDestroy:function(){window.removeEventListener("resize",this.resizeListener)},components:{DonutSections:x}}),k=T,O=E(k,i,c,!1,null,null,null),j=O.exports,w={install:function(t){t.component(j.name,j)}},z=w;e["default"]=z}})});
{
"name": "vue-css-donut-chart",
"version": "1.1.2",
"version": "1.1.3",
"description": "Lightweight Vue component for drawing pure CSS donut charts",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc