UNPKG

12.1 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(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("d3-selection"),require("d3-brush")):"function"==typeof define&&define.amd?define("bb",["d3-selection","d3-brush"],t):"object"==typeof exports?exports.bb=t(require("d3-selection"),require("d3-brush")):(e.bb=e.bb||{},e.bb.plugin=e.bb.plugin||{},e.bb.plugin.sparkline=t(e.d3,e.d3))}(this,(function(e,t){return function(){"use strict";var n=[,function(t){t.exports=e},,function(e){e.exports=t}],i={};function r(e){var t=i[e];if(void 0!==t)return t.exports;var o=i[e]={exports:{}};return n[e](o,o.exports,r),o.exports}r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var o={};return function(){function e(e,t){if(e!==t)throw new TypeError("Cannot instantiate an arrow function")}function t(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function n(e,t){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},n(e,t)}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function a(e){for(var t,n=1;n<arguments.length;n++)t=null!=arguments[n]?arguments[n]:{},n%2?s(Object(t),!0).forEach((function(n){i(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):s(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}));return e}r.d(o,{default:function(){return E}});var c={button:"bb-button",chart:"bb-chart",empty:"bb-empty",main:"bb-main",target:"bb-target",EXPANDED:"_expanded_"},b=(a(a(a(a(a(a(a(a(a(a(a(a(a(a(a(a(a(a(a(a(a(a(a({},c),{arc:"bb-arc",arcLabelLine:"bb-arc-label-line",arcs:"bb-arcs",chartArc:"bb-chart-arc",chartArcs:"bb-chart-arcs",chartArcsBackground:"bb-chart-arcs-background",chartArcsTitle:"bb-chart-arcs-title"}),{area:"bb-area",areas:"bb-areas"}),{axis:"bb-axis",axisX:"bb-axis-x",axisXLabel:"bb-axis-x-label",axisY:"bb-axis-y",axisY2:"bb-axis-y2",axisY2Label:"bb-axis-y2-label",axisYLabel:"bb-axis-y-label"}),{bar:"bb-bar",bars:"bb-bars",chartBar:"bb-chart-bar",chartBars:"bb-chart-bars"}),{candlestick:"bb-candlestick",candlesticks:"bb-candlesticks",chartCandlestick:"bb-chart-candlestick",chartCandlesticks:"bb-chart-candlesticks",valueDown:"bb-value-down",valueUp:"bb-value-up"}),{chartCircles:"bb-chart-circles",circle:"bb-circle",circles:"bb-circles"}),{colorPattern:"bb-color-pattern",colorScale:"bb-colorscale"}),{dragarea:"bb-dragarea",INCLUDED:"_included_"}),{chartArcsGaugeMax:"bb-chart-arcs-gauge-max",chartArcsGaugeMin:"bb-chart-arcs-gauge-min",chartArcsGaugeUnit:"bb-chart-arcs-gauge-unit",chartArcsGaugeTitle:"bb-chart-arcs-gauge-title",gaugeValue:"bb-gauge-value"}),{legend:"bb-legend",legendBackground:"bb-legend-background",legendItem:"bb-legend-item",legendItemEvent:"bb-legend-item-event",legendItemHidden:"bb-legend-item-hidden",legendItemPoint:"bb-legend-item-point",legendItemTile:"bb-legend-item-tile"}),{chartLine:"bb-chart-line",chartLines:"bb-chart-lines",line:"bb-line",lines:"bb-lines"}),{eventRect:"bb-event-rect",eventRects:"bb-event-rects",eventRectsMultiple:"bb-event-rects-multiple",eventRectsSingle:"bb-event-rects-single"}),{focused:"bb-focused",defocused:"bb-defocused",legendItemFocused:"bb-legend-item-focused",xgridFocus:"bb-xgrid-focus",ygridFocus:"bb-ygrid-focus"}),{grid:"bb-grid",gridLines:"bb-grid-lines",xgrid:"bb-xgrid",xgridLine:"bb-xgrid-line",xgridLines:"bb-xgrid-lines",xgrids:"bb-xgrids",ygrid:"bb-ygrid",ygridLine:"bb-ygrid-line",ygridLines:"bb-ygrid-lines",ygrids:"bb-ygrids"}),{chartRadar:"bb-chart-radar",chartRadars:"bb-chart-radars"}),{region:"bb-region",regions:"bb-regions"}),{selectedCircle:"bb-selected-circle",selectedCircles:"bb-selected-circles",SELECTED:"_selected_"}),{shape:"bb-shape",shapes:"bb-shapes"}),{brush:"bb-brush",subchart:"bb-subchart"}),{chartText:"bb-chart-text",chartTexts:"bb-chart-texts",text:"bb-text",texts:"bb-texts",title:"bb-title",TextOverlapping:"text-overlapping"}),{tooltip:"bb-tooltip",tooltipContainer:"bb-tooltip-container",tooltipName:"bb-tooltip-name"}),{buttonZoomReset:"bb-zoom-reset",zoomBrush:"bb-zoom-brush"}),function(){function t(e){void 0===e&&(e={}),this.$$=void 0,this.options=void 0,this.options=e}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}());b.version="3.6.3";var l=function(){return{selector:void 0}},d=(r(1),r(3),void 0),u=function(){return e(this,d),"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)();u.requestIdleCallback=u.requestIdleCallback||function(t){return e(this,d),setTimeout(t,1)}.bind(void 0),u.requestAnimationFrame=u.requestAnimationFrame||function(t){return e(this,d),setTimeout(t,1)}.bind(void 0);var h=null==u?void 0:u.document,f=void 0;(function(t){return e(this,f),t||0===t}).bind(void 0),function(t){return e(this,f),"function"==typeof t}.bind(void 0);var v=function(t){return e(this,f),"string"==typeof t}.bind(void 0),g=function(t){return e(this,f),"number"==typeof t}.bind(void 0),p=function(t){return e(this,f),void 0===t}.bind(void 0),y=function(t){return e(this,f),void 0!==t}.bind(void 0),m=(function(t){return e(this,f),"boolean"==typeof t}.bind(void 0),function(t){return e(this,f),10*Math.ceil(t/10)}.bind(void 0),function(t){return e(this,f),Math.ceil(t)+.5}.bind(void 0),function(t){return e(this,f),t[1]-t[0]}.bind(void 0),function(t){return e(this,f),"object"==typeof t}.bind(void 0)),x=function(t){return e(this,f),p(t)||null===t||v(t)&&0===t.length||m(t)&&!(t instanceof Date)&&0===Object.keys(t).length||g(t)&&isNaN(t)}.bind(void 0),O=(function(t){return e(this,f),!x(t)}.bind(void 0),function(t){return e(this,f),Array.isArray(t)}.bind(void 0)),j=function(t){return e(this,f),t&&!(null!=t&&t.nodeType)&&m(t)&&!O(t)}.bind(void 0);(function(t){return e(this,f),t.charAt(0).toUpperCase()+t.slice(1)}).bind(void 0);(function(t){return e(this,f),[].slice.call(t)}).bind(void 0);function $(t){for(var n=this,i=arguments.length,r=Array(i>1?i-1:0),o=1;o<i;o++)r[o-1]=arguments[o];if(!r.length||1===r.length&&!r[0])return t;var s=r.shift();return j(t)&&j(s)&&Object.keys(s).forEach(function(i){e(this,n);var r=s[i];j(r)?(t[i]||(t[i]={}),t[i]=$(t[i],r)):t[i]=O(r)?r.concat():r}.bind(this)),$.apply(void 0,[t].concat(r))}(function(t,n,i){void 0===i&&(i=1),e(this,f);for(var r=[],o=0|Math.max(0,Math.ceil((n-t)/i)),s=t;s<o;s++)r.push(t+s*i);return r}).bind(void 0),function(){var t=this;e(this,f);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,r,o){void 0===o&&(o=n()),e(this,t),i.dispatchEvent(new MouseEvent(r,o))}.bind(this)}catch(i){return function(i,r,o){void 0===o&&(o=n()),e(this,t);var s=h.createEvent("MouseEvent");s.initMouseEvent(r,o.bubbles,o.cancelable,u,0,o.screenX,o.screenY,o.clientX,o.clientY,!1,!1,!1,!1,0,null),i.dispatchEvent(s)}.bind(this)}}.bind(void 0)(),function(t,n,i){e(this,f);var r=new Touch($({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:[r],targetTouches:[],changedTouches:[r]}))}.bind(void 0);function w(t){var n,i,r,o=this,s=this.config,a=function(){e(this,o);var t=i.shift();return t&&n&&m(n)&&t in n?(n=n[t],a()):t?void 0:n}.bind(this);Object.keys(s).forEach(function(c){e(this,o),n=t,i=c.split("_"),r=a(),y(r)&&(s[c]=r)}.bind(this)),this.api&&(this.state.orgConfig=t)}var E=function(i){var r,o;function s(e){var n=i.call(this,e)||this;return n.config=void 0,n.element=void 0,n.config=new l,t(n)||t(n)}o=i,(r=s).prototype=Object.create(o.prototype),r.prototype.constructor=r,n(r,o);var a=s.prototype;return a.$beforeInit=function(){w.call(this,this.options),this.validate(),this.element=[].slice.call(document.querySelectorAll(this.config.selector)),this.overrideInternals(),this.overrideOptions(),this.overHandler=this.overHandler.bind(this),this.moveHandler=this.moveHandler.bind(this),this.outHandler=this.outHandler.bind(this)},a.validate=function(){var e=this.$$,t=this.config,n="";if(t.selector&&document.querySelector(t.selector)||(n="No holder elements found from given selector option."),(e.hasType("bubble")||e.hasType("scatter")||e.hasArcType(e.data.targets))&&(n="Contains non supported chart types."),n)throw new Error("[Sparkline plugin] "+n)},a.overrideInternals=function(){var e=this.$$,t=e.getBarW,n=e.getIndices;e.getIndices=function(e,t,i){return"getShapeX"===i?{}:n.call(this,e,t)},e.getBarW=function(e,n){return t.call(this,e,n,1)}},a.overrideOptions=function(){var t=this,n=this.$$.config;if(n.legend_show=!1,n.resize_auto=!1,n.axis_x_show=!1,!1!==n.padding){var i=function(n){return e(this,t),Object.keys(n||{}).length>0}.bind(this);i(n.axis_x_padding)&&(n.axis_x_padding={left:15,right:15,unit:"px"}),i(n.axis_y_padding)&&(n.axis_y_padding=5)}n.axis_y_show=!1,n.tooltip_position||(n.tooltip_position=function(e,t,n){var i=this.internal.state.event,r=i.pageY-1.35*n,o=i.pageX-t/2;return r<0&&(r=0),o<0&&(o=0),{top:r,left:o}})},a.$init=function(){var e,t=this.$$.$el;t.chart.style("width","0").style("height","0").style("pointer-events","none"),(null==(e=t.tooltip)?void 0:e.node())&&document.body.appendChild(t.tooltip.node())},a.$afterInit=function(){this.$$.$el.svg.attr("style",null).style("width","0").style("height","0"),this.bindEvents(!0)},a.bindEvents=function(t){var n=this;void 0===t&&(t=!0);var i=this.$$.config;if(i.interaction_enabled&&i.tooltip_show){var r=(t?"add":"remove")+"EventListener";this.element.forEach(function(t){e(this,n);var i=t.querySelector("svg");i[r]("mouseover",this.overHandler),i[r]("mousemove",this.moveHandler),i[r]("mouseout",this.outHandler)}.bind(this))}},a.overHandler=function(e){this.$$.state.eventReceiver.rect=e.target.getBoundingClientRect()},a.moveHandler=function(e){var t,n,i=this.$$,r=i.getDataIndexFromEvent(e),o=null==(t=i.api.data(e.target.__id))?void 0:t[0],s=null==o||null==(n=o.values)?void 0:n[r];s&&!s.name&&(s.name=s.id),i.state.event=e,i.setExpand(r,o.id,!0),i.showTooltip([s],e.target)},a.outHandler=function(e){var t=this.$$;t.state.event=e,t.unexpandCircles(),t.hideTooltip()},a.$redraw=function(){var t,n=this.$$,i=n.$el,r=this.element,o=n.api.data(),s=null==(t=i.chart.html().match(/<svg[^>]*>/))?void 0:t[0],a=this;if(r.length<o.length){for(var b=i.chart.node(),l=o.length-r.length;l>0;l--)b.parentNode.insertBefore(r[0].cloneNode(),b.nextSibling);this.element=document.querySelectorAll(this.config.selector),r=this.element}o.map(function(t){return e(this,a),t.id}.bind(this)).forEach(function(t,n){e(this,a);var o="."+c.target+"-"+t,b=i.main.selectAll(o),l=r[n].querySelector("svg");l||(r[n].innerHTML=s+"</svg>",(l=r[n].querySelector("svg")).__id=t),l.querySelector(o)||b.style("opacity",null),b.style("fill","none").style("opacity",null),l.innerHTML="",l.appendChild(b.node())}.bind(this))},a.$willDestroy=function(){var t=this;this.bindEvents(!1),this.element.forEach(function(n){e(this,t),n.innerHTML=""}.bind(this))},s}(b);E.version="0.0.1"}(),o=o.default}()}));
\No newline at end of file