1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | (function(c,u){typeof exports=="object"&&typeof module=="object"?module.exports=u(require("d3-brush"),require("d3-selection")):typeof define=="function"&&define.amd?define("bb",["d3-brush","d3-selection"],u):typeof exports=="object"?exports.bb=u(require("d3-brush"),require("d3-selection")):(c.bb=c.bb||{},c.bb.plugin=c.bb.plugin||{},c.bb.plugin.tableview=u(c.d3,c.d3))})(this,function(j,c){return function(){"use strict";var u={853:function(e){e.exports=j},747:function(e){e.exports=c}},C={};function a(e){var t=C[e];if(t!==void 0)return t.exports;var n=C[e]={exports:{}};return u[e](n,n.exports,a),n.exports}(function(){a.d=function(e,t){for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}})(),function(){a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}}();var m={};a.d(m,{default:function(){return fe}});var be=a(853),he=a(747);function R(){return typeof globalThis=="object"&&globalThis!==null&&globalThis.Object===Object&&globalThis||typeof global=="object"&&global!==null&&global.Object===Object&&global||typeof self=="object"&&self!==null&&self.Object===Object&&self||Function("return this")()}function q(e){const t=typeof(e==null?void 0:e.requestAnimationFrame)=="function"&&typeof(e==null?void 0:e.cancelAnimationFrame)=="function",n=typeof(e==null?void 0:e.requestIdleCallback)=="function"&&typeof(e==null?void 0:e.cancelIdleCallback)=="function",o=i=>setTimeout(i,1),r=i=>clearTimeout(i);return[t?e.requestAnimationFrame:o,t?e.cancelAnimationFrame:r,n?e.requestIdleCallback:o,n?e.cancelIdleCallback:r]}const g=R(),V=g==null?void 0:g.document,[pe,me,ge,_e]=q(g);var L=Object.defineProperty,S=Object.getOwnPropertySymbols,U=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable,M=(e,t,n)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,D=(e,t)=>{for(var n in t||(t={}))U.call(t,n)&&M(e,n,t[n]);if(S)for(var n of S(t))z.call(t,n)&&M(e,n,t[n]);return e};const ye=e=>e||e===0,X=e=>typeof e=="function",_=e=>typeof e=="string",y=e=>typeof e=="number",Y=e=>typeof e=="undefined",A=e=>typeof e!="undefined",ve=e=>typeof e=="boolean",we=e=>Math.ceil(e/10)*10,xe=e=>Math.ceil(e)+.5,Oe=e=>e[1]-e[0],O=e=>typeof e=="object",k=e=>Y(e)||e===null||_(e)&&e.length===0||O(e)&&!(e instanceof Date)&&Object.keys(e).length===0||y(e)&&isNaN(e),H=e=>!k(e),E=e=>Array.isArray(e),v=e=>e&&!(e!=null&&e.nodeType)&&O(e)&&!E(e);function Ee(e,t,n){return A(e[t])?e[t]:n}function Pe(e,t){let n=!1;return Object.keys(e).forEach(o=>e[o]===t&&(n=!0)),n}function Te(e,t,...n){const o=X(e);return o&&e.call(t,...n),o}function $e(e,t){let n=0;const o=function(...r){!--n&&t.apply(this,...r)};"duration"in e?e.each(()=>++n).on("end",o):(++n,e.call(o))}function je(e){return _(e)?e.replace(/<(script|img)?/ig,"<").replace(/(script)?>/ig,">"):e}function Ce(e,t,n=[-1,1],o=!1){if(!(!e||!_(t)))if(t.indexOf(`
|
12 | `)===-1)e.text(t);else{const r=[e.text(),t].map(i=>i.replace(/[\s\n]/g,""));if(r[0]!==r[1]){const i=t.split(`
|
13 | `),s=o?i.length-1:1;e.html(""),i.forEach((l,d)=>{e.append("tspan").attr("x",0).attr("dy",`${d===0?n[0]*s:n[1]}em`).text(l)})}}}function G(e){const{x:t,y:n,width:o,height:r}=e.getBBox();return[{x:t,y:n+r},{x:t,y:n},{x:t+o,y:n},{x:t+o,y:n+r}]}function Se(e){const{width:t,height:n}=e.getBoundingClientRect(),o=G(e),r=o[0].x,i=Math.min(o[0].y,o[1].y);return{x:r,y:i,width:t,height:n}}function Me(e,t){var n;const o=e&&((n=e.touches||e.sourceEvent&&e.sourceEvent.touches)==null?void 0:n[0]);let r=[0,0];try{r=d3Pointer(o||e,t)}catch(i){}return r.map(i=>isNaN(i)?0:i)}function K(e){const{event:t,$el:n}=e,o=n.subchart.main||n.main;let r;return t&&t.type==="brush"?r=t.selection:o&&(r=o.select(".bb-brush").node())&&(r=d3BrushSelection(r)),r}function De(e){return!("rect"in e)||"rect"in e&&e.hasAttribute("width")&&e.rect.width!==+e.getAttribute("width")?e.rect=e.getBoundingClientRect():e.rect}function Ae(e=!0,t=0,n=1e4){const o=window.crypto||window.msCrypto,r=o?t+o.getRandomValues(new Uint32Array(1))[0]%(n-t+1):Math.floor(Math.random()*(n-t)+t);return e?String(r):r}function N(e,t,n,o,r){if(n>o)return-1;const i=Math.floor((n+o)/2);let{x:s,w:l=0}=e[i];return r&&(s=e[i].y,l=e[i].h),t>=s&&t<=s+l?i:t<s?N(e,t,n,i-1,r):N(e,t,i+1,o,r)}function Ne(e){const t=K(e);return t?t[0]===t[1]:!0}function Be(...e){const t=n=>{if(v(n)&&n.constructor){const o=new n.constructor;for(const r in n)o[r]=t(n[r]);return o}return n};return e.map(n=>t(n)).reduce((n,o)=>D(D({},n),o))}function W(e={},t){E(t)&&t.forEach(n=>W(e,n));for(const n in t)/^\d+$/.test(n)||n in e||(e[n]=t[n]);return e}const Ie=e=>e.charAt(0).toUpperCase()+e.slice(1);function Fe(e,t="-"){return e.split(t).map((n,o)=>o?n.charAt(0).toUpperCase()+n.slice(1).toLowerCase():n.toLowerCase()).join("")}const J=e=>[].slice.call(e);function Re(e,t,n){const{rootSelector:o="",sheet:r}=e,s=`${o} ${(l=>l.replace(/\s?(bb-)/g,".$1").replace(/\.+/g,"."))(t)} {${n.join(";")}}`;return r[r.insertRule?"insertRule":"addRule"](s,r.cssRules.length)}function qe(e){let t=[];return e.forEach(n=>{var o;try{n.cssRules&&n.cssRules.length&&(t=t.concat(J(n.cssRules)))}catch(r){(o=window.console)==null||o.warn(`Error while reading rules from ${n.href}: ${r.toString()}`)}}),t}function Ve(e){var t,n,o,r,i,s;return{x:((n=(t=window.pageXOffset)!=null?t:window.scrollX)!=null?n:0)+((o=e.scrollLeft)!=null?o:0),y:((i=(r=window.pageYOffset)!=null?r:window.scrollY)!=null?i:0)+((s=e.scrollTop)!=null?s:0)}}function Le(e,t=0,n=0,o=!0){const r=new DOMPoint(t,n),i=e.getScreenCTM(),s=r.matrixTransform(o?i==null?void 0:i.inverse():i);if(o===!1){const l=e.getBoundingClientRect();s.x-=l.x,s.y-=l.y}return s}function Ue(e){const t=e?e.transform:null,n=t&&t.baseVal;return n&&n.numberOfItems?n.getItem(0).matrix:{a:0,b:0,c:0,d:0,e:0,f:0}}function ze(e){const t=e[0]instanceof Date,n=(t?e.map(Number):e).filter((o,r,i)=>i.indexOf(o)===r);return t?n.map(o=>new Date(o)):n}function Xe(e){return e&&e.length?e.reduce((t,n)=>t.concat(n)):[]}function P(e,...t){if(!t.length||t.length===1&&!t[0])return e;const n=t.shift();return v(e)&&v(n)&&Object.keys(n).forEach(o=>{const r=n[o];v(r)?(!e[o]&&(e[o]={}),e[o]=P(e[o],r)):e[o]=E(r)?r.concat():r}),P(e,...t)}function Q(e,t=!0){let n;return e[0]instanceof Date?n=t?(o,r)=>o-r:(o,r)=>r-o:t&&!e.every(isNaN)?n=(o,r)=>o-r:t||(n=(o,r)=>o>r&&-1||o<r&&1||o===r&&0),e.concat().sort(n)}function Ye(e,t){let n=t.filter(o=>H(o));return n.length?y(n[0])?n=Math[e](...n):n[0]instanceof Date&&(n=Q(n,e==="min")[0]):n=void 0,n}const ke=(e,t,n=1)=>{const o=[],r=Math.max(0,Math.ceil((t-e)/n))|0;for(let i=e;i<r;i++)o.push(e+i*n);return o},He={mouse:(()=>{const e=()=>({bubbles:!1,cancelable:!1,screenX:0,screenY:0,clientX:0,clientY:0});try{return new MouseEvent("t"),(t,n,o=e())=>{t.dispatchEvent(new MouseEvent(n,o))}}catch(t){return(n,o,r=e())=>{const i=V.createEvent("MouseEvent");i.initMouseEvent(o,r.bubbles,r.cancelable,g,0,r.screenX,r.screenY,r.clientX,r.clientY,!1,!1,!1,!1,0,null),n.dispatchEvent(i)}}})(),touch:(e,t,n)=>{const o=new Touch(P({identifier:Date.now(),target:e,radiusX:2.5,radiusY:2.5,rotationAngle:10,force:.5},n));e.dispatchEvent(new TouchEvent(t,{cancelable:!0,bubbles:!0,shiftKey:!0,touches:[o],targetTouches:[],changedTouches:[o]}))}};function w(e,t){let n=e;for(const o in t)n=n.replace(new RegExp(`{=${o}}`,"g"),t[o]);return n}function Ge(e){var t;let n;if(e instanceof Date)n=e;else if(_(e)){const{config:o,format:r}=this;n=(t=r.dataTime(o.data_xFormat)(e))!=null?t:new Date(e)}else y(e)&&!isNaN(e)&&(n=new Date(+e));return(!n||isNaN(+n))&&console&&console.error&&console.error(`Failed to parse x '${e}' to Date object`),n}function Ke(e){const t=e.attr("viewBox");return t?/(\d+(\.\d+)?){3}/.test(t):!1}function We(e,t,n=!1){const o=!!e.node;let r=!1;for(const[i,s]of Object.entries(t))if(r=o?e.style(i)===s:e.style[i]===s,n===!1&&r)break;return r}function Je(){var e,t;return((e=document)==null?void 0:e.hidden)===!1||((t=document)==null?void 0:t.visibilityState)==="visible"}function Qe(e,t){const{DocumentTouch:n,matchMedia:o,navigator:r}=window,i=o==null?void 0:o("(pointer:coarse)").matches;let s=!1;if(t)if(r&&"maxTouchPoints"in r)s=r.maxTouchPoints>0;else if("ontouchmove"in window||n&&document instanceof n)s=!0;else if(i)s=!0;else{const d=r.userAgent;s=/\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(d)||/\b(Android|Windows Phone|iPad|iPod)\b/i.test(d)}return e&&!i&&(o==null?void 0:o("(pointer:fine)").matches)&&"mouse"||s&&"touch"||"mouse"}function Z(e,t){t()===!1?requestAnimationFrame(()=>Z(e,t)):e()}function ee(e){const t=this.config;let n,o,r;const i=()=>{const s=o.shift();if(s&&n&&O(n)&&s in n)return n=n[s],i();if(!s)return n};Object.keys(t).forEach(s=>{n=e,o=s.split("_"),r=i(),A(r)&&(t[s]=r)}),this.api&&(this.state.orgConfig=e)}var te=Object.defineProperty,ne=(e,t,n)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,T=(e,t,n)=>ne(e,typeof t!="symbol"?t+"":t,n);class B{constructor(t={}){T(this,"$$"),T(this,"options"),this.options=t}$beforeInit(){}$init(){}$afterInit(){}$redraw(){}$willDestroy(){Object.keys(this).forEach(t=>{this[t]=null,delete this[t]})}}T(B,"version","3.14.2");const f={id:"__tableview-style__",class:"bb-tableview",rule:`.bb-tableview {
|
14 | border-collapse:collapse;
|
15 | border-spacing:0;
|
16 | background:#fff;
|
17 | min-width:100%;
|
18 | margin-top:10px;
|
19 | font-family:sans-serif;
|
20 | font-size:.9em;
|
21 | }
|
22 | .bb-tableview tr:hover {
|
23 | background:#eef7ff;
|
24 | }
|
25 | .bb-tableview thead tr {
|
26 | background:#f8f8f8;
|
27 | }
|
28 | .bb-tableview caption,.bb-tableview td,.bb-tableview th {
|
29 | text-align: center;
|
30 | border:1px solid silver;
|
31 | padding:.5em;
|
32 | }
|
33 | .bb-tableview caption {
|
34 | font-size:1.1em;
|
35 | font-weight:700;
|
36 | margin-bottom: -1px;
|
37 | }`},p={body:`<caption>{=title}</caption>
|
38 | <thead><tr>{=thead}</tr></thead>
|
39 | <tbody>{=tbody}</tbody>`,thead:'<th scope="col">{=title}</th>',tbodyHeader:'<th scope="row">{=value}</th>',tbody:"<td>{=value}</td>"};class oe{constructor(){return{selector:void 0,categoryTitle:"Category",categoryFormat:function(t){let n=t;return this.$$.axis.isCategorized()?n=this.$$.categoryName(t):this.$$.axis.isTimeSeries()&&(n=t.toLocaleDateString()),n},class:void 0,style:!0,title:void 0,updateOnToggle:!0,nullString:"-"}}}var re=Object.defineProperty,ie=Object.defineProperties,se=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,le=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable,$=(e,t,n)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ae=(e,t)=>{for(var n in t||(t={}))le.call(t,n)&&$(e,n,t[n]);if(I)for(var n of I(t))ce.call(t,n)&&$(e,n,t[n]);return e},ue=(e,t)=>ie(e,se(t)),F=(e,t,n)=>$(e,typeof t!="symbol"?t+"":t,n);class fe extends B{constructor(t){return super(t),F(this,"config"),F(this,"element"),this.config=new oe,this}$beforeInit(){ee.call(this,this.options)}$init(){const{class:t,selector:n,style:o}=this.config;let r=document.querySelector(n||`.${t||f.class}`);if(!r){const i=this.$$.$el.chart.node();r=document.createElement("table"),i.parentNode.insertBefore(r,i.nextSibling)}if(r.tagName!=="TABLE"){const i=document.createElement("table");r.appendChild(i),r=i}if(o&&!document.getElementById(f.id)){const i=document.createElement("style");i.id=f.id,i.innerHTML=f.rule,(document.head||document.getElementsByTagName("head")[0]).appendChild(i)}r.classList.add(...[o&&f.class,t].filter(Boolean)),this.element=r}generateTable(){const{$$:t,config:n,element:o}=this,r=t.filterTargetsToShow(t.data.targets);let i=w(p.thead,{title:r.length?this.config.categoryTitle:""}),s="";const l=[];r.forEach(x=>{i+=w(p.thead,{title:x.id}),x.values.forEach((b,h)=>{l[h]||(l[h]=[b.x]),l[h].push(b.value)})}),l.forEach(x=>{s+=`<tr>${x.map((b,h)=>w(h?p.tbody:p.tbodyHeader,{value:h===0?n.categoryFormat.bind(this)(b):y(b)?b.toLocaleString():n.nullString})).join("")}</tr>`});const d=/(<\/?(script|img)[^>]*>|<[^>]+><\/[^>]+>)/ig,de=w(p.body,ue(ae({},n),{title:n.title||t.config.title_text||"",thead:i,tbody:s})).replace(d,"");o.innerHTML=de}$redraw(){const{state:t}=this.$$;!(t.resizing||!this.config.updateOnToggle&&t.toggling)&&this.generateTable()}$willDestroy(){var t,n;if((t=this.element.parentNode)==null||t.removeChild(this.element),this.$$.charts.length===1){const o=document.getElementById(f.id);(n=o==null?void 0:o.parentNode)==null||n.removeChild(o)}}}return m=m.default,m}()});
|
40 |
|
\ | No newline at end of file |