Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@chartisan/chartisan

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chartisan/chartisan - npm Package Compare versions

Comparing version 3.2.0 to 3.2.1

2

dist/chartisan.js

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

var t,e=(t=require("deepmerge"))&&"object"==typeof t&&"default"in t?t.default:t;function n(t){return"labels"in t}function r(t){return"name"in t&&"values"in t}function o(t){return"chart"in t&&"datasets"in t&&n(t.chart)&&t.datasets.every(function(t){return r(t)})}var i=function(){function t(){this.hooks=[]}var e=t.prototype;return e.custom=function(t){return this.hooks.push(t),this},e.options=function(t){return this.custom(function(e){return(0,e.merge)(e.data,t)})},e.merge=function(t){return this.hooks=[].concat(this.hooks,t.hooks),this},t}(),a=e;function s(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function h(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?l(Object(n),!0).forEach(function(e){s(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}var c,d={general:function(t){var e=t.size,n=t.color;return'\n <svg\n role="img"\n xmlns="http://www.w3.org/2000/svg"\n width="'+e[0]+'"\n height="'+e[1]+'"\n viewBox="0 0 24 24"\n aria-labelledby="refreshIconTitle"\n stroke="'+n+'"\n stroke-width="1"\n stroke-linecap="square"\n stroke-linejoin="miter"\n fill="none"\n color="'+n+'"\n >\n <title id="refreshIconTitle">Refresh</title>\n <polyline points="22 12 19 15 16 12"/>\n <path d="M11,20 C6.581722,20 3,16.418278 3,12 C3,7.581722 6.581722,4 11,4 C15.418278,4 19,7.581722 19,12 L19,14"/>\n </svg>\n'}},u=function(t,e){return'\n <div class="chartisan-help-block">\n <div class="chartisan-refresh-chart">\n '+d[t.type](t)+"\n </div>\n "+(""!=t.text?'\n <div class="chartisan-help-text" style="color: '+t.textColor+';">\n '+t.text+"\n </div>\n ":"")+"\n "+(t.debug?'\n <div class="chartisan-help-text-error">\n '+e.message+"\n </div>":"")+"\n </div>\n"},p={bar:function(t){var e=t.size;return'\n <svg width="'+e[0]+'" height="'+e[1]+'" viewBox="0 0 135 140" xmlns="http://www.w3.org/2000/svg" fill="'+t.color+'">\n <rect y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.5s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.5s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="30" y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.25s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.25s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="60" width="15" height="140" rx="6">\n <animate attributeName="height"\n begin="0s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="90" y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.25s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.25s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="120" y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.5s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.5s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n </svg>\n'}},f=function(t){return'\n <div class="chartisan-help-block">\n '+p[t.type](t)+"\n "+(""!=t.text?'\n <div class="chartisan-help-text" style="color: '+t.textColor+';">\n '+t.text+"\n </div>":"")+"\n </div>\n"};(c=exports.ChartState||(exports.ChartState={})).Initializing="initializing",c.Loading="loading",c.Error="error",c.Show="show",c.Destroyed="destroyed",exports.Chartisan=function(){function t(t){this.options={el:".chartisan",url:void 0,options:void 0,data:void 0,loader:{type:"bar",size:[35,35],color:"#000",text:"Loading chart",textColor:"#a0aec0"},error:{type:"general",size:[50,50],color:"#f56565",text:"There was an error",textColor:"#a0aec0",debug:!0},hooks:void 0},this.cstate=exports.ChartState.Initializing;var e=(this.options=h(h({},this.options),t)).el;if("string"==typeof e){var n=document.querySelector(e);if(!n)throw Error("[Chartisan] Unable to find an element to bind the chart to a DOM element with the selector: '"+e+"'");this.element=n}else this.element=e;if(this.element.querySelector(".chartisan-controller"))throw Error("[Chartisan] There seems to be a chart already at the element selected by: '"+e+"'");this.controller=document.createElement("div"),this.body=document.createElement("div"),this.modal=document.createElement("div"),this.bootstrap()}var e=t.prototype;return e.setModal=function(t){var e=t.show,n=void 0===e||e,r=t.color,o=t.content;this.modal.style.backgroundColor=void 0===r?"#FFFFFF":r,this.modal.style.display=n?"flex":"none",o&&(this.modal.innerHTML=o)},e.changeTo=function(t,e){switch(t){case exports.ChartState.Loading:this.setModal({show:!0,content:f(this.options.loader)});break;case exports.ChartState.Show:this.setModal({show:!1});break;case exports.ChartState.Error:this.setModal({show:!0,content:u(this.options.error,null!=e?e:new Error("Unknown Error"))}),this.refreshEvent()}this.cstate=t},e.bootstrap=function(){this.element.appendChild(this.controller),this.controller.appendChild(this.body),this.controller.appendChild(this.modal),this.controller.classList.add("chartisan-controller"),this.body.classList.add("chartisan-body"),this.modal.classList.add("chartisan-modal"),this.update(this.options)},e.request=function(t){var e=this;if(!this.options.url)return this.onError(new Error("No URL provided to fetch the data."));fetch(this.options.url,this.options.options).then(function(t){return t.json()}).then(function(n){return e.onRawUpdate(n,t)}).catch(function(t){return e.onError(t)})},e.refreshEvent=function(){var t=this;this.controller.getElementsByClassName("chartisan-refresh-chart")[0].addEventListener("click",function(){return t.update()},{once:!0})},e.update=function(t){if((null==t?void 0:t.url)&&(this.options.url=t.url),(null==t?void 0:t.options)&&(this.options.options=t.options),null==t?void 0:t.data){var e;o(t.data)?e=t.data:((null==t?void 0:t.background)||this.changeTo(exports.ChartState.Loading),e=t.data());var n=this.getDataFrom(e);return this.changeTo(exports.ChartState.Show),t.background?this.onBackgroundUpdate(n,null==t?void 0:t.additional):this.onUpdate(n,null==t?void 0:t.additional)}(null==t?void 0:t.background)||this.changeTo(exports.ChartState.Loading),this.request(t)},e.destroy=function(){this.onDestroy(),this.controller.remove(),this.changeTo(exports.ChartState.Destroyed)},e.getDataFrom=function(t){var e=this.formatData(t);if(this.options.hooks){var n=this.options.hooks.hooks,r=Array.isArray(n),o=0;for(n=r?n:n[Symbol.iterator]();;){var i;if(r){if(o>=n.length)break;i=n[o++]}else{if((o=n.next()).done)break;i=o.value}e=i({data:e,merge:a,server:t})}}return e},e.onRawUpdate=function(t,e){if(!o(t))return this.onError(new Error("Invalid server data"));var n=this.getDataFrom(t);this.changeTo(exports.ChartState.Show),(null==e?void 0:e.background)?this.onBackgroundUpdate(n,null==e?void 0:e.additional):this.onUpdate(n,null==e?void 0:e.additional)},e.onError=function(t){this.changeTo(exports.ChartState.Error,t)},e.state=function(){return this.cstate},t}(),exports.Hooks=i,exports.colorPalette=["#667EEA","#F56565","#48BB78","#ED8936","#9F7AEA","#38B2AC","#ECC94B","#4299E1","#ED64A6"],exports.error=u,exports.isChartData=n,exports.isDatasetData=r,exports.isServerData=o,exports.loader=f,exports.mergeOptions=a;
var t,e=(t=require("deepmerge"))&&"object"==typeof t&&"default"in t?t.default:t;function n(t){return"labels"in t}function r(t){return"name"in t&&"values"in t}function o(t){return"chart"in t&&"datasets"in t&&n(t.chart)&&t.datasets.every(function(t){return r(t)})}var i=function(){function t(){this.hooks=[]}var e=t.prototype;return e.custom=function(t){return this.hooks.push(t),this},e.options=function(t){return this.custom(function(e){return(0,e.merge)(e.data,t)})},e.merge=function(t){return this.hooks=[].concat(this.hooks,t.hooks),this},t}(),a=e;function s(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function h(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?l(Object(n),!0).forEach(function(e){s(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var d,u={general:function(t){var e=t.size,n=t.color;return'\n <svg\n role="img"\n xmlns="http://www.w3.org/2000/svg"\n width="'+e[0]+'"\n height="'+e[1]+'"\n viewBox="0 0 24 24"\n aria-labelledby="refreshIconTitle"\n stroke="'+n+'"\n stroke-width="1"\n stroke-linecap="square"\n stroke-linejoin="miter"\n fill="none"\n color="'+n+'"\n >\n <title id="refreshIconTitle">Refresh</title>\n <polyline points="22 12 19 15 16 12"/>\n <path d="M11,20 C6.581722,20 3,16.418278 3,12 C3,7.581722 6.581722,4 11,4 C15.418278,4 19,7.581722 19,12 L19,14"/>\n </svg>\n'}},p=function(t,e){return'\n <div class="chartisan-help-block">\n <div class="chartisan-refresh-chart">\n '+u[t.type](t)+"\n </div>\n "+(""!=t.text?'\n <div class="chartisan-help-text" style="color: '+t.textColor+';">\n '+t.text+"\n </div>\n ":"")+"\n "+(t.debug?'\n <div class="chartisan-help-text-error">\n '+e.message+"\n </div>":"")+"\n </div>\n"},f={bar:function(t){var e=t.size;return'\n <svg width="'+e[0]+'" height="'+e[1]+'" viewBox="0 0 135 140" xmlns="http://www.w3.org/2000/svg" fill="'+t.color+'">\n <rect y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.5s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.5s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="30" y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.25s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.25s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="60" width="15" height="140" rx="6">\n <animate attributeName="height"\n begin="0s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="90" y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.25s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.25s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="120" y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.5s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.5s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n </svg>\n'}},v=function(t){return'\n <div class="chartisan-help-block">\n '+f[t.type](t)+"\n "+(""!=t.text?'\n <div class="chartisan-help-text" style="color: '+t.textColor+';">\n '+t.text+"\n </div>":"")+"\n </div>\n"};(d=exports.ChartState||(exports.ChartState={})).Initializing="initializing",d.Loading="loading",d.Error="error",d.Show="show",d.Destroyed="destroyed",exports.Chartisan=function(){function t(t){this.options={el:".chartisan",url:void 0,options:void 0,data:void 0,loader:{type:"bar",size:[35,35],color:"#000",text:"Loading chart",textColor:"#a0aec0"},error:{type:"general",size:[50,50],color:"#f56565",text:"There was an error",textColor:"#a0aec0",debug:!0},hooks:void 0},this.cstate=exports.ChartState.Initializing;var e=(this.options=h(h({},this.options),t)).el;if("string"==typeof e){var n=document.querySelector(e);if(!n)throw Error("[Chartisan] Unable to find an element to bind the chart to a DOM element with the selector: '"+e+"'");this.element=n}else this.element=e;if(this.element.querySelector(".chartisan-controller"))throw Error("[Chartisan] There seems to be a chart already at the element selected by: '"+e+"'");this.controller=document.createElement("div"),this.body=document.createElement("div"),this.modal=document.createElement("div"),this.bootstrap()}var e=t.prototype;return e.setModal=function(t){var e=t.show,n=void 0===e||e,r=t.color,o=t.content;this.modal.style.backgroundColor=void 0===r?"#FFFFFF":r,this.modal.style.display=n?"flex":"none",o&&(this.modal.innerHTML=o)},e.changeTo=function(t,e){switch(t){case exports.ChartState.Loading:this.setModal({show:!0,content:v(this.options.loader)});break;case exports.ChartState.Show:this.setModal({show:!1});break;case exports.ChartState.Error:this.setModal({show:!0,content:p(this.options.error,null!=e?e:new Error("Unknown Error"))}),this.refreshEvent()}this.cstate=t},e.bootstrap=function(){this.element.appendChild(this.controller),this.controller.appendChild(this.body),this.controller.appendChild(this.modal),this.controller.classList.add("chartisan-controller"),this.body.classList.add("chartisan-body"),this.modal.classList.add("chartisan-modal"),this.update(this.options)},e.request=function(t){var e=this;if(!this.options.url)return this.onError(new Error("No URL provided to fetch the data."));fetch(this.options.url,this.options.options).then(function(t){return t.json()}).then(function(n){return e.onRawUpdate(n,t)}).catch(function(t){return e.onError(t)})},e.refreshEvent=function(){var t=this;this.controller.getElementsByClassName("chartisan-refresh-chart")[0].addEventListener("click",function(){return t.update()},{once:!0})},e.update=function(t){if((null==t?void 0:t.url)&&(this.options.url=t.url),(null==t?void 0:t.options)&&(this.options.options=t.options),null==t?void 0:t.data){var e;o(t.data)?e=t.data:((null==t?void 0:t.background)||this.changeTo(exports.ChartState.Loading),e=t.data());var n=this.getDataFrom(e);return this.changeTo(exports.ChartState.Show),t.background?this.onBackgroundUpdate(n,null==t?void 0:t.additional):this.onUpdate(n,null==t?void 0:t.additional)}(null==t?void 0:t.background)||this.changeTo(exports.ChartState.Loading),this.request(t)},e.destroy=function(){this.onDestroy(),this.controller.remove(),this.changeTo(exports.ChartState.Destroyed)},e.getDataFrom=function(t){var e=this.formatData(t);if(this.options.hooks)for(var n,r=function(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return c(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(t,void 0):void 0}}(t))){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}(this.options.hooks.hooks);!(n=r()).done;)e=(0,n.value)({data:e,merge:a,server:t});return e},e.onRawUpdate=function(t,e){if(!o(t))return this.onError(new Error("Invalid server data"));var n=this.getDataFrom(t);this.changeTo(exports.ChartState.Show),(null==e?void 0:e.background)?this.onBackgroundUpdate(n,null==e?void 0:e.additional):this.onUpdate(n,null==e?void 0:e.additional)},e.onError=function(t){this.changeTo(exports.ChartState.Error,t)},e.state=function(){return this.cstate},t}(),exports.Hooks=i,exports.colorPalette=["#667EEA","#F56565","#48BB78","#ED8936","#9F7AEA","#38B2AC","#ECC94B","#4299E1","#ED64A6"],exports.error=p,exports.isChartData=n,exports.isDatasetData=r,exports.isServerData=o,exports.loader=v,exports.mergeOptions=a;
//# sourceMappingURL=chartisan.js.map

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

import t from"deepmerge";function e(t){return"labels"in t}function n(t){return"name"in t&&"values"in t}function r(t){return"chart"in t&&"datasets"in t&&e(t.chart)&&t.datasets.every(function(t){return n(t)})}var i=function(){function t(){this.hooks=[]}var e=t.prototype;return e.custom=function(t){return this.hooks.push(t),this},e.options=function(t){return this.custom(function(e){return(0,e.merge)(e.data,t)})},e.merge=function(t){return this.hooks=[].concat(this.hooks,t.hooks),this},t}(),o=["#667EEA","#F56565","#48BB78","#ED8936","#9F7AEA","#38B2AC","#ECC94B","#4299E1","#ED64A6"],a=t;function s(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function c(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?l(Object(n),!0).forEach(function(e){s(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}var h,d={general:function(t){var e=t.size,n=t.color;return'\n <svg\n role="img"\n xmlns="http://www.w3.org/2000/svg"\n width="'+e[0]+'"\n height="'+e[1]+'"\n viewBox="0 0 24 24"\n aria-labelledby="refreshIconTitle"\n stroke="'+n+'"\n stroke-width="1"\n stroke-linecap="square"\n stroke-linejoin="miter"\n fill="none"\n color="'+n+'"\n >\n <title id="refreshIconTitle">Refresh</title>\n <polyline points="22 12 19 15 16 12"/>\n <path d="M11,20 C6.581722,20 3,16.418278 3,12 C3,7.581722 6.581722,4 11,4 C15.418278,4 19,7.581722 19,12 L19,14"/>\n </svg>\n'}},u=function(t,e){return'\n <div class="chartisan-help-block">\n <div class="chartisan-refresh-chart">\n '+d[t.type](t)+"\n </div>\n "+(""!=t.text?'\n <div class="chartisan-help-text" style="color: '+t.textColor+';">\n '+t.text+"\n </div>\n ":"")+"\n "+(t.debug?'\n <div class="chartisan-help-text-error">\n '+e.message+"\n </div>":"")+"\n </div>\n"},p={bar:function(t){var e=t.size;return'\n <svg width="'+e[0]+'" height="'+e[1]+'" viewBox="0 0 135 140" xmlns="http://www.w3.org/2000/svg" fill="'+t.color+'">\n <rect y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.5s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.5s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="30" y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.25s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.25s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="60" width="15" height="140" rx="6">\n <animate attributeName="height"\n begin="0s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="90" y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.25s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.25s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="120" y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.5s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.5s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n </svg>\n'}},f=function(t){return'\n <div class="chartisan-help-block">\n '+p[t.type](t)+"\n "+(""!=t.text?'\n <div class="chartisan-help-text" style="color: '+t.textColor+';">\n '+t.text+"\n </div>":"")+"\n </div>\n"};!function(t){t.Initializing="initializing",t.Loading="loading",t.Error="error",t.Show="show",t.Destroyed="destroyed"}(h||(h={}));var v=function(){function t(t){this.options={el:".chartisan",url:void 0,options:void 0,data:void 0,loader:{type:"bar",size:[35,35],color:"#000",text:"Loading chart",textColor:"#a0aec0"},error:{type:"general",size:[50,50],color:"#f56565",text:"There was an error",textColor:"#a0aec0",debug:!0},hooks:void 0},this.cstate=h.Initializing;var e=(this.options=c(c({},this.options),t)).el;if("string"==typeof e){var n=document.querySelector(e);if(!n)throw Error("[Chartisan] Unable to find an element to bind the chart to a DOM element with the selector: '"+e+"'");this.element=n}else this.element=e;if(this.element.querySelector(".chartisan-controller"))throw Error("[Chartisan] There seems to be a chart already at the element selected by: '"+e+"'");this.controller=document.createElement("div"),this.body=document.createElement("div"),this.modal=document.createElement("div"),this.bootstrap()}var e=t.prototype;return e.setModal=function(t){var e=t.show,n=void 0===e||e,r=t.color,i=t.content;this.modal.style.backgroundColor=void 0===r?"#FFFFFF":r,this.modal.style.display=n?"flex":"none",i&&(this.modal.innerHTML=i)},e.changeTo=function(t,e){switch(t){case h.Loading:this.setModal({show:!0,content:f(this.options.loader)});break;case h.Show:this.setModal({show:!1});break;case h.Error:this.setModal({show:!0,content:u(this.options.error,null!=e?e:new Error("Unknown Error"))}),this.refreshEvent()}this.cstate=t},e.bootstrap=function(){this.element.appendChild(this.controller),this.controller.appendChild(this.body),this.controller.appendChild(this.modal),this.controller.classList.add("chartisan-controller"),this.body.classList.add("chartisan-body"),this.modal.classList.add("chartisan-modal"),this.update(this.options)},e.request=function(t){var e=this;if(!this.options.url)return this.onError(new Error("No URL provided to fetch the data."));fetch(this.options.url,this.options.options).then(function(t){return t.json()}).then(function(n){return e.onRawUpdate(n,t)}).catch(function(t){return e.onError(t)})},e.refreshEvent=function(){var t=this;this.controller.getElementsByClassName("chartisan-refresh-chart")[0].addEventListener("click",function(){return t.update()},{once:!0})},e.update=function(t){if((null==t?void 0:t.url)&&(this.options.url=t.url),(null==t?void 0:t.options)&&(this.options.options=t.options),null==t?void 0:t.data){var e;r(t.data)?e=t.data:((null==t?void 0:t.background)||this.changeTo(h.Loading),e=t.data());var n=this.getDataFrom(e);return this.changeTo(h.Show),t.background?this.onBackgroundUpdate(n,null==t?void 0:t.additional):this.onUpdate(n,null==t?void 0:t.additional)}(null==t?void 0:t.background)||this.changeTo(h.Loading),this.request(t)},e.destroy=function(){this.onDestroy(),this.controller.remove(),this.changeTo(h.Destroyed)},e.getDataFrom=function(t){var e=this.formatData(t);if(this.options.hooks){var n=this.options.hooks.hooks,r=Array.isArray(n),i=0;for(n=r?n:n[Symbol.iterator]();;){var o;if(r){if(i>=n.length)break;o=n[i++]}else{if((i=n.next()).done)break;o=i.value}e=o({data:e,merge:a,server:t})}}return e},e.onRawUpdate=function(t,e){if(!r(t))return this.onError(new Error("Invalid server data"));var n=this.getDataFrom(t);this.changeTo(h.Show),(null==e?void 0:e.background)?this.onBackgroundUpdate(n,null==e?void 0:e.additional):this.onUpdate(n,null==e?void 0:e.additional)},e.onError=function(t){this.changeTo(h.Error,t)},e.state=function(){return this.cstate},t}();export{h as ChartState,v as Chartisan,i as Hooks,o as colorPalette,u as error,e as isChartData,n as isDatasetData,r as isServerData,f as loader,a as mergeOptions};
import t from"deepmerge";function e(t){return"labels"in t}function n(t){return"name"in t&&"values"in t}function r(t){return"chart"in t&&"datasets"in t&&e(t.chart)&&t.datasets.every(function(t){return n(t)})}var i=function(){function t(){this.hooks=[]}var e=t.prototype;return e.custom=function(t){return this.hooks.push(t),this},e.options=function(t){return this.custom(function(e){return(0,e.merge)(e.data,t)})},e.merge=function(t){return this.hooks=[].concat(this.hooks,t.hooks),this},t}(),o=["#667EEA","#F56565","#48BB78","#ED8936","#9F7AEA","#38B2AC","#ECC94B","#4299E1","#ED64A6"],a=t;function s(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function c(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?l(Object(n),!0).forEach(function(e){s(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function h(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var d,u={general:function(t){var e=t.size,n=t.color;return'\n <svg\n role="img"\n xmlns="http://www.w3.org/2000/svg"\n width="'+e[0]+'"\n height="'+e[1]+'"\n viewBox="0 0 24 24"\n aria-labelledby="refreshIconTitle"\n stroke="'+n+'"\n stroke-width="1"\n stroke-linecap="square"\n stroke-linejoin="miter"\n fill="none"\n color="'+n+'"\n >\n <title id="refreshIconTitle">Refresh</title>\n <polyline points="22 12 19 15 16 12"/>\n <path d="M11,20 C6.581722,20 3,16.418278 3,12 C3,7.581722 6.581722,4 11,4 C15.418278,4 19,7.581722 19,12 L19,14"/>\n </svg>\n'}},p=function(t,e){return'\n <div class="chartisan-help-block">\n <div class="chartisan-refresh-chart">\n '+u[t.type](t)+"\n </div>\n "+(""!=t.text?'\n <div class="chartisan-help-text" style="color: '+t.textColor+';">\n '+t.text+"\n </div>\n ":"")+"\n "+(t.debug?'\n <div class="chartisan-help-text-error">\n '+e.message+"\n </div>":"")+"\n </div>\n"},f={bar:function(t){var e=t.size;return'\n <svg width="'+e[0]+'" height="'+e[1]+'" viewBox="0 0 135 140" xmlns="http://www.w3.org/2000/svg" fill="'+t.color+'">\n <rect y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.5s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.5s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="30" y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.25s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.25s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="60" width="15" height="140" rx="6">\n <animate attributeName="height"\n begin="0s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="90" y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.25s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.25s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="120" y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.5s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.5s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n </svg>\n'}},v=function(t){return'\n <div class="chartisan-help-block">\n '+f[t.type](t)+"\n "+(""!=t.text?'\n <div class="chartisan-help-text" style="color: '+t.textColor+';">\n '+t.text+"\n </div>":"")+"\n </div>\n"};!function(t){t.Initializing="initializing",t.Loading="loading",t.Error="error",t.Show="show",t.Destroyed="destroyed"}(d||(d={}));var g=function(){function t(t){this.options={el:".chartisan",url:void 0,options:void 0,data:void 0,loader:{type:"bar",size:[35,35],color:"#000",text:"Loading chart",textColor:"#a0aec0"},error:{type:"general",size:[50,50],color:"#f56565",text:"There was an error",textColor:"#a0aec0",debug:!0},hooks:void 0},this.cstate=d.Initializing;var e=(this.options=c(c({},this.options),t)).el;if("string"==typeof e){var n=document.querySelector(e);if(!n)throw Error("[Chartisan] Unable to find an element to bind the chart to a DOM element with the selector: '"+e+"'");this.element=n}else this.element=e;if(this.element.querySelector(".chartisan-controller"))throw Error("[Chartisan] There seems to be a chart already at the element selected by: '"+e+"'");this.controller=document.createElement("div"),this.body=document.createElement("div"),this.modal=document.createElement("div"),this.bootstrap()}var e=t.prototype;return e.setModal=function(t){var e=t.show,n=void 0===e||e,r=t.color,i=t.content;this.modal.style.backgroundColor=void 0===r?"#FFFFFF":r,this.modal.style.display=n?"flex":"none",i&&(this.modal.innerHTML=i)},e.changeTo=function(t,e){switch(t){case d.Loading:this.setModal({show:!0,content:v(this.options.loader)});break;case d.Show:this.setModal({show:!1});break;case d.Error:this.setModal({show:!0,content:p(this.options.error,null!=e?e:new Error("Unknown Error"))}),this.refreshEvent()}this.cstate=t},e.bootstrap=function(){this.element.appendChild(this.controller),this.controller.appendChild(this.body),this.controller.appendChild(this.modal),this.controller.classList.add("chartisan-controller"),this.body.classList.add("chartisan-body"),this.modal.classList.add("chartisan-modal"),this.update(this.options)},e.request=function(t){var e=this;if(!this.options.url)return this.onError(new Error("No URL provided to fetch the data."));fetch(this.options.url,this.options.options).then(function(t){return t.json()}).then(function(n){return e.onRawUpdate(n,t)}).catch(function(t){return e.onError(t)})},e.refreshEvent=function(){var t=this;this.controller.getElementsByClassName("chartisan-refresh-chart")[0].addEventListener("click",function(){return t.update()},{once:!0})},e.update=function(t){if((null==t?void 0:t.url)&&(this.options.url=t.url),(null==t?void 0:t.options)&&(this.options.options=t.options),null==t?void 0:t.data){var e;r(t.data)?e=t.data:((null==t?void 0:t.background)||this.changeTo(d.Loading),e=t.data());var n=this.getDataFrom(e);return this.changeTo(d.Show),t.background?this.onBackgroundUpdate(n,null==t?void 0:t.additional):this.onUpdate(n,null==t?void 0:t.additional)}(null==t?void 0:t.background)||this.changeTo(d.Loading),this.request(t)},e.destroy=function(){this.onDestroy(),this.controller.remove(),this.changeTo(d.Destroyed)},e.getDataFrom=function(t){var e=this.formatData(t);if(this.options.hooks)for(var n,r=function(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return h(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?h(t,void 0):void 0}}(t))){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}(this.options.hooks.hooks);!(n=r()).done;)e=(0,n.value)({data:e,merge:a,server:t});return e},e.onRawUpdate=function(t,e){if(!r(t))return this.onError(new Error("Invalid server data"));var n=this.getDataFrom(t);this.changeTo(d.Show),(null==e?void 0:e.background)?this.onBackgroundUpdate(n,null==e?void 0:e.additional):this.onUpdate(n,null==e?void 0:e.additional)},e.onError=function(t){this.changeTo(d.Error,t)},e.state=function(){return this.cstate},t}();export{d as ChartState,g as Chartisan,i as Hooks,o as colorPalette,p as error,e as isChartData,n as isDatasetData,r as isServerData,v as loader,a as mergeOptions};
//# sourceMappingURL=chartisan.module.js.map

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("deepmerge")):"function"==typeof define&&define.amd?define(["exports","deepmerge"],e):e((t=t||self).chartisan={},t.deepmerge)}(this,function(t,e){function n(t){return"labels"in t}function r(t){return"name"in t&&"values"in t}function i(t){return"chart"in t&&"datasets"in t&&n(t.chart)&&t.datasets.every(function(t){return r(t)})}e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;var o=function(){function t(){this.hooks=[]}var e=t.prototype;return e.custom=function(t){return this.hooks.push(t),this},e.options=function(t){return this.custom(function(e){return(0,e.merge)(e.data,t)})},e.merge=function(t){return this.hooks=[].concat(this.hooks,t.hooks),this},t}(),a=e;function s(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function h(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?l(Object(n),!0).forEach(function(e){s(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}var c,d={general:function(t){var e=t.size,n=t.color;return'\n <svg\n role="img"\n xmlns="http://www.w3.org/2000/svg"\n width="'+e[0]+'"\n height="'+e[1]+'"\n viewBox="0 0 24 24"\n aria-labelledby="refreshIconTitle"\n stroke="'+n+'"\n stroke-width="1"\n stroke-linecap="square"\n stroke-linejoin="miter"\n fill="none"\n color="'+n+'"\n >\n <title id="refreshIconTitle">Refresh</title>\n <polyline points="22 12 19 15 16 12"/>\n <path d="M11,20 C6.581722,20 3,16.418278 3,12 C3,7.581722 6.581722,4 11,4 C15.418278,4 19,7.581722 19,12 L19,14"/>\n </svg>\n'}},u=function(t,e){return'\n <div class="chartisan-help-block">\n <div class="chartisan-refresh-chart">\n '+d[t.type](t)+"\n </div>\n "+(""!=t.text?'\n <div class="chartisan-help-text" style="color: '+t.textColor+';">\n '+t.text+"\n </div>\n ":"")+"\n "+(t.debug?'\n <div class="chartisan-help-text-error">\n '+e.message+"\n </div>":"")+"\n </div>\n"},p={bar:function(t){var e=t.size;return'\n <svg width="'+e[0]+'" height="'+e[1]+'" viewBox="0 0 135 140" xmlns="http://www.w3.org/2000/svg" fill="'+t.color+'">\n <rect y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.5s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.5s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="30" y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.25s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.25s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="60" width="15" height="140" rx="6">\n <animate attributeName="height"\n begin="0s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="90" y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.25s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.25s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="120" y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.5s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.5s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n </svg>\n'}},f=function(t){return'\n <div class="chartisan-help-block">\n '+p[t.type](t)+"\n "+(""!=t.text?'\n <div class="chartisan-help-text" style="color: '+t.textColor+';">\n '+t.text+"\n </div>":"")+"\n </div>\n"};(c=t.ChartState||(t.ChartState={})).Initializing="initializing",c.Loading="loading",c.Error="error",c.Show="show",c.Destroyed="destroyed",t.Chartisan=function(){function e(e){this.options={el:".chartisan",url:void 0,options:void 0,data:void 0,loader:{type:"bar",size:[35,35],color:"#000",text:"Loading chart",textColor:"#a0aec0"},error:{type:"general",size:[50,50],color:"#f56565",text:"There was an error",textColor:"#a0aec0",debug:!0},hooks:void 0},this.cstate=t.ChartState.Initializing;var n=(this.options=h(h({},this.options),e)).el;if("string"==typeof n){var r=document.querySelector(n);if(!r)throw Error("[Chartisan] Unable to find an element to bind the chart to a DOM element with the selector: '"+n+"'");this.element=r}else this.element=n;if(this.element.querySelector(".chartisan-controller"))throw Error("[Chartisan] There seems to be a chart already at the element selected by: '"+n+"'");this.controller=document.createElement("div"),this.body=document.createElement("div"),this.modal=document.createElement("div"),this.bootstrap()}var n=e.prototype;return n.setModal=function(t){var e=t.show,n=void 0===e||e,r=t.color,i=t.content;this.modal.style.backgroundColor=void 0===r?"#FFFFFF":r,this.modal.style.display=n?"flex":"none",i&&(this.modal.innerHTML=i)},n.changeTo=function(e,n){switch(e){case t.ChartState.Loading:this.setModal({show:!0,content:f(this.options.loader)});break;case t.ChartState.Show:this.setModal({show:!1});break;case t.ChartState.Error:this.setModal({show:!0,content:u(this.options.error,null!=n?n:new Error("Unknown Error"))}),this.refreshEvent()}this.cstate=e},n.bootstrap=function(){this.element.appendChild(this.controller),this.controller.appendChild(this.body),this.controller.appendChild(this.modal),this.controller.classList.add("chartisan-controller"),this.body.classList.add("chartisan-body"),this.modal.classList.add("chartisan-modal"),this.update(this.options)},n.request=function(t){var e=this;if(!this.options.url)return this.onError(new Error("No URL provided to fetch the data."));fetch(this.options.url,this.options.options).then(function(t){return t.json()}).then(function(n){return e.onRawUpdate(n,t)}).catch(function(t){return e.onError(t)})},n.refreshEvent=function(){var t=this;this.controller.getElementsByClassName("chartisan-refresh-chart")[0].addEventListener("click",function(){return t.update()},{once:!0})},n.update=function(e){if((null==e?void 0:e.url)&&(this.options.url=e.url),(null==e?void 0:e.options)&&(this.options.options=e.options),null==e?void 0:e.data){var n;i(e.data)?n=e.data:((null==e?void 0:e.background)||this.changeTo(t.ChartState.Loading),n=e.data());var r=this.getDataFrom(n);return this.changeTo(t.ChartState.Show),e.background?this.onBackgroundUpdate(r,null==e?void 0:e.additional):this.onUpdate(r,null==e?void 0:e.additional)}(null==e?void 0:e.background)||this.changeTo(t.ChartState.Loading),this.request(e)},n.destroy=function(){this.onDestroy(),this.controller.remove(),this.changeTo(t.ChartState.Destroyed)},n.getDataFrom=function(t){var e=this.formatData(t);if(this.options.hooks){var n=this.options.hooks.hooks,r=Array.isArray(n),i=0;for(n=r?n:n[Symbol.iterator]();;){var o;if(r){if(i>=n.length)break;o=n[i++]}else{if((i=n.next()).done)break;o=i.value}e=o({data:e,merge:a,server:t})}}return e},n.onRawUpdate=function(e,n){if(!i(e))return this.onError(new Error("Invalid server data"));var r=this.getDataFrom(e);this.changeTo(t.ChartState.Show),(null==n?void 0:n.background)?this.onBackgroundUpdate(r,null==n?void 0:n.additional):this.onUpdate(r,null==n?void 0:n.additional)},n.onError=function(e){this.changeTo(t.ChartState.Error,e)},n.state=function(){return this.cstate},e}(),t.Hooks=o,t.colorPalette=["#667EEA","#F56565","#48BB78","#ED8936","#9F7AEA","#38B2AC","#ECC94B","#4299E1","#ED64A6"],t.error=u,t.isChartData=n,t.isDatasetData=r,t.isServerData=i,t.loader=f,t.mergeOptions=a});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("deepmerge")):"function"==typeof define&&define.amd?define(["exports","deepmerge"],e):e((t=t||self).chartisan={},t.deepmerge)}(this,function(t,e){function n(t){return"labels"in t}function r(t){return"name"in t&&"values"in t}function o(t){return"chart"in t&&"datasets"in t&&n(t.chart)&&t.datasets.every(function(t){return r(t)})}e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;var i=function(){function t(){this.hooks=[]}var e=t.prototype;return e.custom=function(t){return this.hooks.push(t),this},e.options=function(t){return this.custom(function(e){return(0,e.merge)(e.data,t)})},e.merge=function(t){return this.hooks=[].concat(this.hooks,t.hooks),this},t}(),a=e;function s(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function h(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?l(Object(n),!0).forEach(function(e){s(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var d,u={general:function(t){var e=t.size,n=t.color;return'\n <svg\n role="img"\n xmlns="http://www.w3.org/2000/svg"\n width="'+e[0]+'"\n height="'+e[1]+'"\n viewBox="0 0 24 24"\n aria-labelledby="refreshIconTitle"\n stroke="'+n+'"\n stroke-width="1"\n stroke-linecap="square"\n stroke-linejoin="miter"\n fill="none"\n color="'+n+'"\n >\n <title id="refreshIconTitle">Refresh</title>\n <polyline points="22 12 19 15 16 12"/>\n <path d="M11,20 C6.581722,20 3,16.418278 3,12 C3,7.581722 6.581722,4 11,4 C15.418278,4 19,7.581722 19,12 L19,14"/>\n </svg>\n'}},f=function(t,e){return'\n <div class="chartisan-help-block">\n <div class="chartisan-refresh-chart">\n '+u[t.type](t)+"\n </div>\n "+(""!=t.text?'\n <div class="chartisan-help-text" style="color: '+t.textColor+';">\n '+t.text+"\n </div>\n ":"")+"\n "+(t.debug?'\n <div class="chartisan-help-text-error">\n '+e.message+"\n </div>":"")+"\n </div>\n"},p={bar:function(t){var e=t.size;return'\n <svg width="'+e[0]+'" height="'+e[1]+'" viewBox="0 0 135 140" xmlns="http://www.w3.org/2000/svg" fill="'+t.color+'">\n <rect y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.5s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.5s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="30" y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.25s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.25s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="60" width="15" height="140" rx="6">\n <animate attributeName="height"\n begin="0s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="90" y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.25s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.25s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n <rect x="120" y="10" width="15" height="120" rx="6">\n <animate attributeName="height"\n begin="0.5s" dur="1s"\n values="120;110;100;90;80;70;60;50;40;140;120" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="y"\n begin="0.5s" dur="1s"\n values="10;15;20;25;30;35;40;45;50;0;10" calcMode="linear"\n repeatCount="indefinite" />\n </rect>\n </svg>\n'}},v=function(t){return'\n <div class="chartisan-help-block">\n '+p[t.type](t)+"\n "+(""!=t.text?'\n <div class="chartisan-help-text" style="color: '+t.textColor+';">\n '+t.text+"\n </div>":"")+"\n </div>\n"};(d=t.ChartState||(t.ChartState={})).Initializing="initializing",d.Loading="loading",d.Error="error",d.Show="show",d.Destroyed="destroyed",t.Chartisan=function(){function e(e){this.options={el:".chartisan",url:void 0,options:void 0,data:void 0,loader:{type:"bar",size:[35,35],color:"#000",text:"Loading chart",textColor:"#a0aec0"},error:{type:"general",size:[50,50],color:"#f56565",text:"There was an error",textColor:"#a0aec0",debug:!0},hooks:void 0},this.cstate=t.ChartState.Initializing;var n=(this.options=h(h({},this.options),e)).el;if("string"==typeof n){var r=document.querySelector(n);if(!r)throw Error("[Chartisan] Unable to find an element to bind the chart to a DOM element with the selector: '"+n+"'");this.element=r}else this.element=n;if(this.element.querySelector(".chartisan-controller"))throw Error("[Chartisan] There seems to be a chart already at the element selected by: '"+n+"'");this.controller=document.createElement("div"),this.body=document.createElement("div"),this.modal=document.createElement("div"),this.bootstrap()}var n=e.prototype;return n.setModal=function(t){var e=t.show,n=void 0===e||e,r=t.color,o=t.content;this.modal.style.backgroundColor=void 0===r?"#FFFFFF":r,this.modal.style.display=n?"flex":"none",o&&(this.modal.innerHTML=o)},n.changeTo=function(e,n){switch(e){case t.ChartState.Loading:this.setModal({show:!0,content:v(this.options.loader)});break;case t.ChartState.Show:this.setModal({show:!1});break;case t.ChartState.Error:this.setModal({show:!0,content:f(this.options.error,null!=n?n:new Error("Unknown Error"))}),this.refreshEvent()}this.cstate=e},n.bootstrap=function(){this.element.appendChild(this.controller),this.controller.appendChild(this.body),this.controller.appendChild(this.modal),this.controller.classList.add("chartisan-controller"),this.body.classList.add("chartisan-body"),this.modal.classList.add("chartisan-modal"),this.update(this.options)},n.request=function(t){var e=this;if(!this.options.url)return this.onError(new Error("No URL provided to fetch the data."));fetch(this.options.url,this.options.options).then(function(t){return t.json()}).then(function(n){return e.onRawUpdate(n,t)}).catch(function(t){return e.onError(t)})},n.refreshEvent=function(){var t=this;this.controller.getElementsByClassName("chartisan-refresh-chart")[0].addEventListener("click",function(){return t.update()},{once:!0})},n.update=function(e){if((null==e?void 0:e.url)&&(this.options.url=e.url),(null==e?void 0:e.options)&&(this.options.options=e.options),null==e?void 0:e.data){var n;o(e.data)?n=e.data:((null==e?void 0:e.background)||this.changeTo(t.ChartState.Loading),n=e.data());var r=this.getDataFrom(n);return this.changeTo(t.ChartState.Show),e.background?this.onBackgroundUpdate(r,null==e?void 0:e.additional):this.onUpdate(r,null==e?void 0:e.additional)}(null==e?void 0:e.background)||this.changeTo(t.ChartState.Loading),this.request(e)},n.destroy=function(){this.onDestroy(),this.controller.remove(),this.changeTo(t.ChartState.Destroyed)},n.getDataFrom=function(t){var e=this.formatData(t);if(this.options.hooks)for(var n,r=function(t,e){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return c(t,void 0);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(t,void 0):void 0}}(t))){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}(this.options.hooks.hooks);!(n=r()).done;)e=(0,n.value)({data:e,merge:a,server:t});return e},n.onRawUpdate=function(e,n){if(!o(e))return this.onError(new Error("Invalid server data"));var r=this.getDataFrom(e);this.changeTo(t.ChartState.Show),(null==n?void 0:n.background)?this.onBackgroundUpdate(r,null==n?void 0:n.additional):this.onUpdate(r,null==n?void 0:n.additional)},n.onError=function(e){this.changeTo(t.ChartState.Error,e)},n.state=function(){return this.cstate},e}(),t.Hooks=i,t.colorPalette=["#667EEA","#F56565","#48BB78","#ED8936","#9F7AEA","#38B2AC","#ECC94B","#4299E1","#ED64A6"],t.error=f,t.isChartData=n,t.isDatasetData=r,t.isServerData=o,t.loader=v,t.mergeOptions=a});
//# sourceMappingURL=chartisan.umd.js.map
{
"name": "@chartisan/chartisan",
"version": "3.2.0",
"version": "3.2.1",
"description": "Supercharged language agnostic charts",

@@ -36,2 +36,3 @@ "source": "src/index.ts",

"devDependencies": {
"@babel/core": "^7.10.4",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.4",

@@ -44,4 +45,3 @@ "@babel/plugin-proposal-object-rest-spread": "^7.10.4",

"typedoc": "^0.16.11",
"typescript": "^3.9.6",
"ultrabundle": "^1.0.2"
"typescript": "^3.9.6"
},

@@ -48,0 +48,0 @@ "dependencies": {

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc