UNPKG

8.8 kBJavaScriptView Raw
1/*!
2 * Copyright (c) 2017 ~ present NAVER Corp.
3 * billboard.js project is licensed under the MIT license
4 *
5 * billboard.js, JavaScript chart library
6 * https://naver.github.io/billboard.js/
7 *
8 * @version 3.6.3
9 * @requires billboard.js
10 * @summary billboard.js plugin
11 */
12!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("d3-selection"),require("d3-brush")):"function"==typeof define&&define.amd?define("bb",["d3-selection","d3-brush"],e):"object"==typeof exports?exports.bb=e(require("d3-selection"),require("d3-brush")):(t.bb=t.bb||{},t.bb.plugin=t.bb.plugin||{},t.bb.plugin.tableview=e(t.d3,t.d3))}(this,(function(t,e){return function(){"use strict";var n=[,function(e){e.exports=t},,function(t){t.exports=e}],i={};function o(t){var e=i[t];if(void 0!==e)return e.exports;var r=i[t]={exports:{}};return n[t](r,r.exports,o),r.exports}o.d=function(t,e){for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};var r={};return function(){function t(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function e(t,e){if(t!==e)throw new TypeError("Cannot instantiate an arrow function")}function n(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}o.d(r,{default:function(){return q}});var c=function(){function t(t){void 0===t&&(t={}),this.$$=void 0,this.options=void 0,this.options=t}var n=t.prototype;return n.$beforeInit=function(){},n.$init=function(){},n.$afterInit=function(){},n.$redraw=function(){},n.$willDestroy=function(){var t=this;Object.keys(this).forEach(function(n){e(this,t),this[n]=null,delete this[n]}.bind(this))},t}();c.version="3.6.3";var a=function(){return{selector:void 0,categoryTitle:"Category",categoryFormat:function(t){var e=t;return this.$$.axis.isCategorized()?e=this.$$.categoryName(t):this.$$.axis.isTimeSeries()&&(e=t.toLocaleDateString()),e},class:void 0,style:!0,title:void 0,updateOnToggle:!0}},s="__tableview-style__",u="bb-tableview",l=".bb-tableview {\n\t\tborder-collapse:collapse;\n\t\tborder-spacing:0;\n\t\tbackground:#fff;\n\t\tmin-width:100%;\n\t\tmargin-top:10px;\n\t\tfont-family:sans-serif;\n\t\tfont-size:.9em;\n\t}\n\t.bb-tableview tr:hover {\n\t\tbackground:#eef7ff;\n\t}\n\t.bb-tableview thead tr {\n\t\tbackground:#f8f8f8;\n\t}\n\t.bb-tableview caption,.bb-tableview td,.bb-tableview th {\n\t\ttext-align: center;\n\t\tborder:1px solid silver;\n\t\tpadding:.5em;\n\t}\n\t.bb-tableview caption {\n\t\tfont-size:1.1em;\n\t\tfont-weight:700;\n\t\tmargin-bottom: -1px;\n\t}",d="<caption>{=title}</caption>\n\t\t<thead><tr>{=thead}</tr></thead>\n\t\t<tbody>{=tbody}</tbody>",b='<th scope="col">{=title}</th>',f='<th scope="row">{=value}</th>',h="<td>{=value}</td>",v=(o(1),o(3),void 0),p=function(){return e(this,v),"object"==typeof globalThis&&null!==globalThis&&globalThis.Object===Object&&globalThis||"object"==typeof global&&null!==global&&global.Object===Object&&global||"object"==typeof self&&null!==self&&self.Object===Object&&self||Function("return this")()}.bind(void 0)();p.requestIdleCallback=p.requestIdleCallback||function(t){return e(this,v),setTimeout(t,1)}.bind(void 0),p.requestAnimationFrame=p.requestAnimationFrame||function(t){return e(this,v),setTimeout(t,1)}.bind(void 0);var g=null==p?void 0:p.document,y=void 0;(function(t){return e(this,y),t||0===t}).bind(void 0),function(t){return e(this,y),"function"==typeof t}.bind(void 0);var m=function(t){return e(this,y),"string"==typeof t}.bind(void 0),w=function(t){return e(this,y),"number"==typeof t}.bind(void 0),O=function(t){return e(this,y),void 0===t}.bind(void 0),j=function(t){return e(this,y),void 0!==t}.bind(void 0),E=(function(t){return e(this,y),"boolean"==typeof t}.bind(void 0),function(t){return e(this,y),10*Math.ceil(t/10)}.bind(void 0),function(t){return e(this,y),Math.ceil(t)+.5}.bind(void 0),function(t){return e(this,y),t[1]-t[0]}.bind(void 0),function(t){return e(this,y),"object"==typeof t}.bind(void 0)),$=function(t){return e(this,y),O(t)||null===t||m(t)&&0===t.length||E(t)&&!(t instanceof Date)&&0===Object.keys(t).length||w(t)&&isNaN(t)}.bind(void 0),T=(function(t){return e(this,y),!$(t)}.bind(void 0),function(t){return e(this,y),Array.isArray(t)}.bind(void 0)),x=function(t){return e(this,y),t&&!(null!=t&&t.nodeType)&&E(t)&&!T(t)}.bind(void 0);(function(t){return e(this,y),t.charAt(0).toUpperCase()+t.slice(1)}).bind(void 0);(function(t){return e(this,y),[].slice.call(t)}).bind(void 0);function P(t){for(var n=this,i=arguments.length,o=Array(i>1?i-1:0),r=1;r<i;r++)o[r-1]=arguments[r];if(!o.length||1===o.length&&!o[0])return t;var c=o.shift();return x(t)&&x(c)&&Object.keys(c).forEach(function(i){e(this,n);var o=c[i];x(o)?(t[i]||(t[i]={}),t[i]=P(t[i],o)):t[i]=T(o)?o.concat():o}.bind(this)),P.apply(void 0,[t].concat(o))}(function(t,n,i){void 0===i&&(i=1),e(this,y);for(var o=[],r=0|Math.max(0,Math.ceil((n-t)/i)),c=t;c<r;c++)o.push(t+c*i);return o}).bind(void 0),function(){var t=this;e(this,y);var n=function(){return e(this,t),{bubbles:!1,cancelable:!1,screenX:0,screenY:0,clientX:0,clientY:0}}.bind(this);try{return new MouseEvent("t"),function(i,o,r){void 0===r&&(r=n()),e(this,t),i.dispatchEvent(new MouseEvent(o,r))}.bind(this)}catch(i){return function(i,o,r){void 0===r&&(r=n()),e(this,t);var c=g.createEvent("MouseEvent");c.initMouseEvent(o,r.bubbles,r.cancelable,p,0,r.screenX,r.screenY,r.clientX,r.clientY,!1,!1,!1,!1,0,null),i.dispatchEvent(c)}.bind(this)}}.bind(void 0)(),function(t,n,i){e(this,y);var o=new Touch(P({identifier:Date.now(),target:t,radiusX:2.5,radiusY:2.5,rotationAngle:10,force:.5},i));t.dispatchEvent(new TouchEvent(n,{cancelable:!0,bubbles:!0,shiftKey:!0,touches:[o],targetTouches:[],changedTouches:[o]}))}.bind(void 0);function C(t,e){var n=t;for(var i in e)n=n.replace(new RegExp("{="+i+"}","g"),e[i]);return n}function k(t){var n,i,o,r=this,c=this.config,a=function(){e(this,r);var t=i.shift();return t&&n&&E(n)&&t in n?(n=n[t],a()):t?void 0:n}.bind(this);Object.keys(c).forEach(function(s){e(this,r),n=t,i=s.split("_"),o=a(),j(o)&&(c[s]=o)}.bind(this)),this.api&&(this.state.orgConfig=t)}function M(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function _(e){for(var n,i=1;i<arguments.length;i++)n=null!=arguments[i]?arguments[i]:{},i%2?M(Object(n),!0).forEach((function(i){t(e,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):M(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}));return e}var q=function(t){var o,r;function c(e){var i=t.call(this,e)||this;return i.config=void 0,i.element=void 0,i.config=new a,n(i)||n(i)}r=t,(o=c).prototype=Object.create(r.prototype),o.prototype.constructor=o,i(o,r);var v=c.prototype;return v.$beforeInit=function(){k.call(this,this.options)},v.$init=function(){var t,e=this.config,n=e.class,i=e.selector,o=e.style,r=document.querySelector(i||"."+(n||u));if(!r){var c=this.$$.$el.chart.node();r=document.createElement("table"),c.parentNode.insertBefore(r,c.nextSibling)}if("TABLE"!==r.tagName){var a=document.createElement("table");r.appendChild(a),r=a}if(o&&!document.getElementById(s)){var d=document.createElement("style");d.id=s,d.innerHTML=l,(document.head||document.getElementsByTagName("head")[0]).appendChild(d)}(t=r.classList).add.apply(t,[o&&u,n].filter(Boolean)),this.element=r},v.generateTable=function(){var t=this,n=this.$$,i=this.config,o=this.element,r=n.filterTargetsToShow(n.data.targets),c=C(b,{title:r.length?this.config.categoryTitle:""}),a="",s=[];r.forEach(function(n){var i=this;e(this,t),c+=C(b,{title:n.id}),n.values.forEach(function(t,n){e(this,i),s[n]||(s[n]=[t.x]),s[n].push(t.value)}.bind(this))}.bind(this)),s.forEach(function(n){var o=this;e(this,t),a+="<tr>"+n.map(function(t,n){return e(this,o),C(n?h:f,{value:0===n?i.categoryFormat.bind(this)(t):w(t)?t.toLocaleString():""})}.bind(this)).join("")+"</tr>"}.bind(this));var u=C(d,_(_({},i),{},{title:i.title||n.config.title_text||"",thead:c,tbody:a})).replace(/<[^>]+><\/[^>]+>/g,"");o.innerHTML=u},v.$redraw=function(){var t=this.$$.state;t.resizing||!this.config.updateOnToggle&&t.toggling||this.generateTable()},v.$willDestroy=function(){if(this.element.parentNode.removeChild(this.element),1===this.$$.charts.length){var t,e=document.getElementById(s);null==e||null==(t=e.parentNode)||t.removeChild(e)}},c}(c)}(),r=r.default}()}));
\No newline at end of file