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

dchart-core

Package Overview
Dependencies
Maintainers
2
Versions
284
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dchart-core - npm Package Compare versions

Comparing version 2.7.3 to 2.7.5

2

area/areaMultiVerti.js

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

"use strict";var DataV=require("./area"),d3=require("d3"),_=require("../util"),animationController=_.animationController;function AreaMultiVerti(e,t){var a={xaxis:{type:"category",orient:"bottom"},groupLabel:null,yaxis:{},label:{show:!1,pos:"center",dx:"0",dy:".4em",anchor:"middle",strokeWidth:0},series:[{label:{}},{label:{}}]};a=_.deepMerge(a,t),DataV.call(this,e,a)}AreaMultiVerti=DataV.extend(AreaMultiVerti,{renderSeries:function(){var e,t,a=this.options,r=this.data(),i=a.xaxis.key,n=a.yaxis.key,s=this;this.svg.classed("bar-chart-g",!0),e=this.getComs("axis","xaxis"),t=this.getComs("axis","yaxis");var o=e.getX(),l=t.getX(),u=_.maxBy(r,(function(e){return e[n].length}))[n].length,c=function(t,r,u){var c=d3.select(this).select(".serie"+(u+1)),d=d3.svg.area().x((function(t){return"time"===a.xaxis.type&&"string"==typeof t[i]?o(d3.time.format(e.options.format).parse(t[i]))+(o.rangeBand?o.rangeBand()/2:0):o(t[i])+(o.rangeBand?o.rangeBand()/2:0)})).y0((function(e){var t=e[n][u];return t.value=t.value||0,t.value>=0?l(e.maxSum):l(e.minSum)})).y1((function(e){var t=e[n][u];return t.value=t.value||0,t.value>=0?(e.maxSum+=t.value,l(e.maxSum)):(e.minSum+=t.value,l(e.minSum)-Math.abs(l(0)-l(t.value)))}));(a.series[u]&&a.series[u].interpolate||a.interpolate)&&d.interpolate(a.series[u]&&a.series[u].interpolate||a.interpolate||""),c.attr("clip-path","url(#"+s.clipPathId+")");var h=a.width,p=a.height,m=function(){return s.clipPath.attr("d",_.getRectPath(0,0,h,p))};c.style({fill:a.series[u]&&a.series[u].color&&a.series[u].color.res||a.color&&a.color.res}).style({"pointer-events":"none",display:_.isBoolean(_.get(a,"series[".concat(u,"].area.show")))&&!1===_.get(a,"series[".concat(u,"].area.show"))?"none":"block"});animationController({animationHandler:function(e){var t=e.duration,r=e.ease;a.isFirst||!a.animationUpdateFromPrevious?(c.attr({d:d}),s.clipPath.transition().duration(t).ease(r).attrTween("d",(function(){var e=d3.interpolate(0,h);return function(t){return _.getRectPath(0,0,e(t),p)}}))):(m(),c.transition().duration(t).ease(r).attr("d",d))},notAnimationHandler:function(){m(),c.attr("d",d)},options:a}),s.addResumeTween(m)};this.series.datum(r),this.series.each((function(r,n){for(var s=d3.select(this),d=0;d<u;d++){s.select(".serie"+(d+1))[0][0]||s.append("path").attr({class:"serie serie"+(d+1),d:d3.svg.area().x((function(t){return"time"===a.xaxis.type&&"string"==typeof t[i]?o(d3.time.format(e.options.format).parse(t[i]))+(o.rangeBand?o.rangeBand()/2:0):o(t[i])+(o.rangeBand?o.rangeBand()/2:0)})).y0(l(t.getMin())).y1(l(t.getMin()))}).style("stroke","none"),c.call(this,r,n,d)}})),this.series.selectAll(".serie.serie"+u+" ~ .serie").remove()},updateSeries:function(){AreaMultiVerti.prototype.renderSeries.call(this)},beforeRender:function(){var e=this.options,t=this;this.dealColor(e,"color"),e.series&&e.series.length&&e.series.forEach((function(a,r){a.color&&t.dealColor(e,"series["+r+"].color")})),!this.clipPathId&&this.createClipPath()},createClipPath:function(){this.clipPathId="ClipPath"+_.getUUID(),this.clipPath=this.svg.append("defs").append("clipPath").attr("id",this.clipPathId).append("path").attr("fill","none").attr("stroke","none")}}),module.exports=AreaMultiVerti;
"use strict";var DataV=require("./area"),d3=require("d3"),_=require("../util"),animationController=_.animationController;function AreaMultiVerti(t,e){var i={xaxis:{type:"category",orient:"bottom"},groupLabel:null,yaxis:{},label:{show:!1,pos:"center",dx:"0",dy:".4em",anchor:"middle",strokeWidth:0},series:[{label:{}},{label:{}}]};i=_.deepMerge(i,e),DataV.call(this,t,i)}AreaMultiVerti=DataV.extend(AreaMultiVerti,{renderSeries:function(){var t,e,i=this.options,a=this.data(),r=i.xaxis.key,n=i.yaxis.key,s=this;this.svg.classed("bar-chart-g",!0),t=this.getComs("axis","xaxis"),e=this.getComs("axis","yaxis");var o=this.options.chart.margin,l=o.top,h=o.bottom,c=o.left,d=o.right,p=this.svg.node().parentNode.getBoundingClientRect(),u=p.width,g=p.height;s.clipPathRect.attr({width:u-c-d,height:g-l-h});var m=t.getX(),f=e.getX(),v=_.maxBy(a,(function(t){return t[n].length}))[n].length,x=function(e,a,o){var l=d3.select(this).select(".serie"+(o+1)),h=d3.svg.area().x((function(e){return"time"===i.xaxis.type&&"string"==typeof e[r]?m(d3.time.format(t.options.format).parse(e[r]))+(m.rangeBand?m.rangeBand()/2:0):m(e[r])+(m.rangeBand?m.rangeBand()/2:0)})).y0((function(t){var e=t[n][o];return e.value=e.value||0,e.value>=0?f(t.maxSum):f(t.minSum)})).y1((function(t){var e=t[n][o];return e.value=e.value||0,e.value>=0?(t.maxSum+=e.value,f(t.maxSum)):(t.minSum+=e.value,f(t.minSum)-Math.abs(f(0)-f(e.value)))}));(i.series[o]&&i.series[o].interpolate||i.interpolate)&&h.interpolate(i.series[o]&&i.series[o].interpolate||i.interpolate||""),l.attr("clip-path","url(#"+s.clipPathId+")");var c=i.width,d=i.height,p=function(){return s.clipPath.attr("d",_.getRectPath(0,0,c,d))};l.style({fill:i.series[o]&&i.series[o].color&&i.series[o].color.res||i.color&&i.color.res}).style({"pointer-events":"none",display:_.isBoolean(_.get(i,"series[".concat(o,"].area.show")))&&!1===_.get(i,"series[".concat(o,"].area.show"))?"none":"block"});animationController({animationHandler:function(t){var e=t.duration,a=t.ease;i.isFirst||!i.animationUpdateFromPrevious?(l.attr({d:h}),s.clipPath.transition().duration(e).ease(a).attrTween("d",(function(){var t=d3.interpolate(0,c);return function(e){return _.getRectPath(0,0,t(e),d)}}))):(p(),l.transition().duration(e).ease(a).attr("d",h))},notAnimationHandler:function(){p(),l.attr("d",h)},options:i}),s.addResumeTween(p)};this.series.datum(a),this.series.each((function(a,n){for(var s=d3.select(this),o=0;o<v;o++){s.select(".serie"+(o+1))[0][0]||s.append("path").attr({class:"serie serie"+(o+1),d:d3.svg.area().x((function(e){return"time"===i.xaxis.type&&"string"==typeof e[r]?m(d3.time.format(t.options.format).parse(e[r]))+(m.rangeBand?m.rangeBand()/2:0):m(e[r])+(m.rangeBand?m.rangeBand()/2:0)})).y0(f(e.getMin())).y1(f(e.getMin()))}).style("stroke","none"),x.call(this,a,n,o)}})),this.series.selectAll(".serie.serie"+v+" ~ .serie").remove()},updateSeries:function(){AreaMultiVerti.prototype.renderSeries.call(this)},beforeRender:function(){var t=this.options,e=this;this.dealColor(t,"color"),t.series&&t.series.length&&t.series.forEach((function(i,a){i.color&&e.dealColor(t,"series["+a+"].color")})),!this.clipPathId&&this.createClipPath(),!this.clipPathRectId&&this.createClipPathRect()},createClipPath:function(){this.clipPathId="ClipPath"+_.getUUID(),this.clipPath=this.svg.append("defs").append("clipPath").attr("id",this.clipPathId).append("path").attr("fill","none").attr("stroke","none")},createClipPathRect:function(){var t=this.options.chart.margin,e=t.top,i=t.bottom,a=t.left,r=t.right,n=this.svg.node().parentNode.getBoundingClientRect(),s=n.width,o=n.height;this.clipPathRectId="ClipPathRect"+_.getUUID(),this.clipPathRect=this.svg.append("defs").append("clipPath").attr("id",this.clipPathRectId).append("rect").attr("width",s-a-r).attr("height",o-e-i)}}),module.exports=AreaMultiVerti;

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

"use strict";function _typeof(t){return(_typeof="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})(t)}function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function _iterableToArrayLimit(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var i=[],n=!0,s=!1,a=void 0;try{for(var r,o=t[Symbol.iterator]();!(n=(r=o.next()).done)&&(i.push(r.value),!e||i.length!==e);n=!0);}catch(t){s=!0,a=t}finally{try{n||null==o.return||o.return()}finally{if(s)throw a}}return i}}function _arrayWithHoles(t){if(Array.isArray(t))return t}var _=require("../util"),Com=require("./index"),d3=require("d3"),numberUtil=require("../util/number"),TICK_PADDING=2,MAX_TICK_COUNT=30,ONE_SECOND=1e3,timeUnitsMSMap={seconds:ONE_SECOND,minutes:60*ONE_SECOND,hours:60*ONE_SECOND*60,days:60*ONE_SECOND*60*24,months:60*ONE_SECOND*60*24*30,years:60*ONE_SECOND*60*24*30*12};function Axis(t,e,i){this.reset(),this.options={fontSize:12,fontColor:"#fff",fontWeight:"normal",fontStrokeWidth:0,key:"x",type:"defaults",orient:null,dy:0,padding:.4,groupPadding:[.4,.4],assistLine:!0,assistLineColor:"#fff",rotate:0,min:null,max:null,tickSize:0,tickValues:null,tickFormat:null,ticks:null,nondecile:{key:"y",tickPadding:10},format:"%Y-%m-%d",label:null,labelColor:"#aaa",labelInAxis:!0,labelFontSize:12,labelFontWeight:"normal",labelFontStrokeWidth:0,textAnchor:"middle",textShow:!0,net:!1,netColor:"#aaa",digit:0,show:!0},this.x=null,this.axisx=null,this.groupX=null,this.net=null,this.init(t,e,i),this._valid()}function getStep(t){var e=t.step,i=t.f,n=t.maxNeedNice,s=t.tickFormat,a="string"==typeof s?(s.split(".")[1]||"0f").split("f")[0]:0;return e=n?i(Math.ceil(Math.pow(10,a)*e)/Math.pow(10,a)):i(10*e)/10}function isTicksOverlap(t,e){if(t&&e&&t.getBoundingClientRect&&e.getBoundingClientRect){var i=t.getBoundingClientRect(),n=e.getBoundingClientRect();return i.left+i.width+TICK_PADDING>n.left&&n.left+n.width+TICK_PADDING>i.left&&i.top+i.height+TICK_PADDING>n.top&&n.top+n.height+TICK_PADDING>i.top}return!1}function removeOverlapTicksOfTargetAxis(t){return new Promise((function(e,i){if(!t)return e();for(var n=t.selectAll(".tick")[0],s=[],a=0;a<n.length;a++){var r=n[a],o=n[a+1];if(r&&o&&r.getBoundingClientRect&&o.getBoundingClientRect)for(;isTicksOverlap(r,o)&&(d3.select(o).remove(),o=n[++a+1]););}return t.selectAll(".tick")[0].forEach((function(t){s.push(t.__data__)})),e(s)}))}Axis=Com.extend(Axis,{init:function(t,e,i){if(!t&&!this.el)return!1;t&&(this.elContainer=d3.select(t)),this.options&&_.toLower(this.options.type)!==_.toLower(e.type)?this.isReset=!0:this.isReset=!1,this.options=_.deepMerge(this.options,e),this.alloptions=i||this.alloptions},_valid:function(){var t=this.options,e=["defaults","category","time","nondecile"];-1===_.indexOf(e,t.type.toLowerCase())&&(this.msg="axis arguments error. there is no "+t.type+" in types.",t.type=e[0],this.valid=!1),t.type=_.initialUpperCase(t.type);var i=["left","top","right","bottom"];-1===_.indexOf(i,t.orient.toLowerCase())&&(this.msg="axis arguments error. there is no "+t.orient+" in orients.",t.orient=i[0],this.valid=!1),t.orient=_.initialUpperCase(t.orient)},renderSeries:function(){var t=this.options;this["cal"+t.orient](),this.__el||(this.__el=this.elContainer.append("g").attr({class:"virtual_axis",opacity:0}).call(this.axisx)),this.renderStyle(),this.renderLabel(),"function"==typeof t.afterRender&&t.afterRender.call(this),this.el.selectAll(".tick line").style("display",t.net?"block":"none"),this.isReset=!1},cut:function(t,e,i){var n=_slicedToArray(t,2),s=n[0],a=n[1],r=d3.format(i),o=this.options.maxNeedNice,l=((a=+a||0)-(s=+s||0))/(e-1);l=getStep({step:l,f:r,maxNeedNice:o,tickFormat:i}),t=[],+s==+r(s)&&t.push(s);for(var h=0;h<e-1;h++){var c=r(s+l*(h+1));(c<=a||o)&&t.push(c)}var d=(t=(t=_.uniq(t.map((function(t){return+t})).sort((function(t,e){return t-e})))).filter((function(t){return t<=(o?2*a:a)}))).length-e,u=r(a),f=r(s);return d>0?t.splice(e-1,t.length-e):0===d?t[t.length-1]<u&&(t[t.length-1]=u):d<0&&(t.push(u),t.push(f)),t},format:function(){var t=this,e=this.options,i=this.axisx,n=this.x;i.tickPadding(e.dy),"object"===_typeof(e.tickSize)?i.tickSize.apply(this,e.tickSize):i.tickSize(e.tickSize),e.tickValues&&i.tickValues(e.tickValues);var s=!1;if(e.ticks){if("Category"===e.type&&_.isNumber(e.ticks)){var a=this._data;e.tickFormat=function(t,i){var n=_.toNumber(e.ticks),s=a.length,r=parseInt((s-1)/(n-1));if(0===r)return t;var o=(s-1)%(n-1),l=parseInt(o%2&&o/2+1||o/2);return i<l||s-i<=o-l||(i-l)%r?"":t},i.ticks.apply(this,[e.ticks])}else if("array"==typeof e.ticks)i.ticks.apply(this,e.ticks);else if(_.isNumber(e.ticks))if("Time"!==e.type)if(e.ticks=_.toNumber(e.ticks),"string"==typeof e.tickFormat){var r=_.clone(n.domain());switch(e.ticks){case 0:i.tickValues([r[0]]);break;case 1:i.tickValues([r[1]]);break;default:if(e.tickFormat){var o=_slicedToArray(r,2),l=o[0],h=o[1];if(r=this.cut(r,e.ticks,e.tickFormat),"defaults"===e.type.toLocaleLowerCase()){var c=+d3.format(e.tickFormat)(h),d=+d3.format(e.tickFormat)(l);r=r.filter((function(t){return+t==+d3.format(e.tickFormat)(t)&&t<=c&&t>=d}))}}i.tickValues(r)}setTimeout((function(){var e=t.el&&t.el.selectAll(".tick")[0];if(e&&e.length>1){var i=e[e.length-2];isTicksOverlap(i,e[e.length-1])&&d3.select(i).remove()}}),0)}else i.ticks(e.ticks),s=!0;else{var u=_slicedToArray(this._getTimeAxisExtent(),2),f=u[0],p=u[1],m=Math.abs(p-f),y=Math.min(MAX_TICK_COUNT,e.ticks),g=y-1?m/(y-1):2*m;Object.keys(timeUnitsMSMap).every((function(t){return g>timeUnitsMSMap[t]&&t,g>timeUnitsMSMap[t]})),i.ticks(y),s=!0}}else if(_.isNumber(e.ticks)&&"time"===e.type.toLowerCase()){var x=5*e.tickFormat(new Date).length+5,k=Math.min(e.innerWidth/x||10,MAX_TICK_COUNT);if(this._data.length<k){var v=e.tickFormat;"function"!=typeof v&&(v=d3.format(v));var A=d3.time.format(e.format),b=[],C=[],S=e.key;this._data.map((function(t){var e=A.parse(t[S]);-1===C.indexOf(v(e))&&(C.push(v(e)),b.push(e))})),i.tickValues(b)}else i.ticks(k);s=!0}if("string"==typeof e.tickFormat)i.tickFormat(d3.format(e.tickFormat));else if("function"==typeof e.tickFormat){var N=this;i.tickFormat((function(t,i){return e.tickFormat.call(N._data[i],t,i)}))}s?setTimeout((function(){removeOverlapTicksOfTargetAxis(t.__el).then((function(s){if(s&&s.length){var a=d3.svg.axis().scale(n).orient(i.orient()).tickPadding(e.dy).tickFormat(i.tickFormat()).tickValues(s).tickSize(0);t.el.call(a),t.renderStyle()}}))}),0):this.el&&this.el.call(i)},_afterAxis:function(){var t=this.options;"function"==typeof t._afterAxis&&t._afterAxis.call(this)},renderLabel:function(){var t=this.options,e=this.alloptions;if(t.label){if(t.labelInAxis){var i=this.el.select(".axis-unit")[0][0]&&this.el.select(".axis-unit")||this.el.append("g").attr({class:"axis-unit"}),n=this.el.selectAll(".tick:nth-last-child(3)").select("text");n&&n.length&&n[0].length&&("Left"===t.orient||"Right"===t.orient?i.attr("transform","translate(0,"+-1.5*parseInt(n.style("font-size"))+")"):i.attr("transform","translate("+((t.innerWidth||e.innerWidth)+3*parseInt(n.style("font-size")))+", 0)"),(i.select("text")[0][0]&&i.select("text")||i.append("text")).attr({dy:n.attr("dy"),x:n.attr("x"),y:n.attr("y"),transform:n.attr("transform")}).text(t.label).style({"text-anchor":n.style("text-anchor"),"font-size":n.style("font-size"),"font-weight":n.style("font-weight"),fill:n.style("fill")}))}}else this.el.select(".axis-unit").remove()},calLeft:function(){var t=this.options,e=this.alloptions,i=this.x=this["axis"+t.type].call(this,[t.innerHeight||e.innerHeight,0]),n=this.axisx=d3.svg.axis().scale(i).orient("left");this.format(),this._afterAxis(),this.el&&-1!==this.el.attr("class").indexOf("axis")?this.el.call(n):this.el=this.elContainer.append("g").attr("class","axis").call(n),this.net=this.el.selectAll(".tick"+("Category"!==t.type&&1!==t.ticks?":not(:first-child)":"")).append("line").attr({class:"net-line",x2:t.innerWidth||e.innerWidth,y2:"0"}).style({"stroke-dasharray":"2 2",stroke:t.netColor})},updateLeft:function(){var t=this.options,e=this.alloptions;this["updateAxis"+t.type].call(this,[t.innerHeight||e.innerHeight,0]),this.format(),this._afterAxis(),this.__el&&this.__el.call(this.axisx),this.net=this.el.selectAll(".tick"+("Category"!==t.type&&1!==t.ticks?":not(:first-child)":"")).append("line").attr({class:"net-line",x2:t.innerWidth||e.innerWidth,y2:"0"}).style({"stroke-dasharray":"2 2",stroke:t.netColor})},calRight:function(){var t=this.options,e=this.alloptions,i=this.x=this["axis"+t.type].call(this,[t.innerHeight||e.innerHeight,0]),n=this.axisx=d3.svg.axis().scale(i).orient("right");this.format(),this._afterAxis(),this.el&&-1!==this.el.attr("class").indexOf("axis")?this.el.attr({transform:"translate("+(t.innerWidth||e.innerWidth)+", 0)"}).call(n):this.el=this.elContainer.append("g").attr({class:"axis",transform:"translate("+(t.innerWidth||e.innerWidth)+", 0)"}).call(n),this.net=this.el.selectAll(".tick"+("Category"!==t.type&&1!==t.ticks?":not(:first-child)":"")).append("line").attr({class:"net-line",x2:-t.innerWidth||-e.innerWidth,y2:"0"}).style({"stroke-dasharray":"2 2",stroke:t.netColor})},updateRight:function(){var t=this.options,e=this.alloptions;this["updateAxis"+t.type].call(this,[t.innerHeight||e.innerHeight,0]),this.format(),this._afterAxis(),this.__el&&this.__el.attr("transform","translate("+(t.innerWidth||e.innerWidth)+", 0)").call(this.axisx),this.el.attr("transform","translate("+(t.innerWidth||e.innerWidth)+", 0)"),this.net=this.el.selectAll(".tick"+("Category"!==t.type&&1!==t.ticks?":not(:first-child)":"")).append("line").attr({class:"net-line",x2:-t.innerWidth||-e.innerWidth,y2:"0"}).style({stroke:t.netColor})},calTop:function(){var t=this.options,e=this.alloptions,i=this.x=this["axis"+t.type].call(this,[0,t.innerWidth||e.innerWidth]),n=this.axisx=d3.svg.axis().scale(i).orient("top");this.format(),this._afterAxis(),this.el&&-1!==this.el.attr("class").indexOf("axis")?this.el.call(n):this.el=this.elContainer.append("g").attr("class","axis").call(n),this.net=this.el.selectAll(".tick"+("Category"!==t.type&&1!==t.ticks?":not(:first-child)":"")).append("line").attr({class:"net-line",y2:t.innerHeight||e.innerHeight,x2:"0"}).style({"stroke-dasharray":"2 2",stroke:t.netColor})},updateTop:function(){var t=this.options,e=this.alloptions;this["updateAxis"+t.type].call(this,[0,t.innerWidth||e.innerWidth]),this.format(),this._afterAxis(),this.__el&&this.__el.call(this.axisx),this.net=this.el.selectAll(".tick"+("Category"!==t.type&&1!==t.ticks?":not(:first-child)":"")).append("line").attr({class:"net-line",y2:t.innerHeight||e.innerHeight,x2:"0"}).style({"stroke-dasharray":"2 2",stroke:t.netColor})},calBottom:function(){var t=this.options,e=this.alloptions,i=this.x=this["axis"+t.type].call(this,[0,t.innerWidth||e.innerWidth]),n=this.axisx=d3.svg.axis().scale(i).orient("bottom");this.format(),this._afterAxis(),this.el&&-1!==this.el.attr("class").indexOf("axis")?this.el.attr({transform:"translate(0,"+(t.innerHeight||e.innerHeight)+")"}).call(n):this.el=this.elContainer.append("g").attr({class:"axis",transform:"translate(0,"+(t.innerHeight||e.innerHeight)+")"}).call(n),this.net=this.el.selectAll(".tick"+("Category"!==t.type&&1!==t.ticks?":not(:first-child)":"")).append("line").attr({class:"net-line",y2:-t.innerHeight||-e.innerHeight,x2:"0"}).style({"stroke-dasharray":"2 2",stroke:t.netColor})},updateBottom:function(){var t=this.options,e=this.alloptions;this["updateAxis"+t.type].call(this,[0,t.innerWidth||e.innerWidth]),this.format(),this._afterAxis(),this.__el&&this.__el.attr("transform","translate(0,"+(t.innerHeight||e.innerHeight)+")").call(this.axisx),this.el.attr("transform","translate(0,"+(t.innerHeight||e.innerHeight)+")"),this.net=this.el.selectAll(".tick"+("Category"!==t.type&&1!==t.ticks?":not(:first-child)":"")).append("line").attr({class:"net-line",y2:-t.innerHeight||-e.innerHeight,x2:"0"}).style({"stroke-dasharray":"2 2",stroke:t.netColor})},niceExtent:function(t,e){var i=this.options,n=Math.abs(e[1]-e[0]);t<=1&&(t=2);var s=numberUtil.nice(n/t,!0),a=numberUtil.getPrecisionSafe(s)+2,r=[i.minNeedNice?numberUtil.round(Math.floor(e[0]/s)*s,a):e[0],i.maxNeedNice?numberUtil.round(Math.ceil(e[1]/s)*s,a):e[1]];return _.toNumber(r[0])>_.toNumber(r[1])&&_.reverse(r),"defaults"===i.type.toLocaleLowerCase()&&i.tickFormat&&(r=d3.extent(this.cut(r,i.ticks,i.tickFormat).concat(r[0],r[1]))),r},axisDefaults:function(t){var e=this.x=d3.scale.linear().range(t),i=this.calExtent(),n=this.options,s=this.niceExtent(n.ticks,i);return e.domain(s),e},updateAxisDefaults:function(t){this.x.range(t);var e=this.calExtent(),i=this.options,n=this.niceExtent(i.ticks,e);return this.x.domain(n),this.x},axisCategory:function(t){var e,i=this.options;e=_.isArray(i.padding)?this.x=d3.scale.ordinal().rangeBands(t,i.padding[0],i.padding[1]):this.x=d3.scale.ordinal().rangeBands(t,i.padding/2,i.padding);var n=this.calExtent();return e.domain(n),e},updateAxisCategory:function(t){var e=this.options;return _.isArray(e.padding)?this.x.rangeBands(t,e.padding[0],e.padding[1]):this.x.rangeBands(t,e.padding/2,e.padding),this.x.domain(this.calExtent()),this.x},_setTimeAxisBoundaryGap:function(t){var e=this.options.blank?this.options.blankDis:0;if(e&&this._data&&this._data.length){var i=(+t[1]-t[0])/this._data.length,n=parseInt(i*e);t=[new Date(+t[0]-n),new Date(+t[1]+n)]}return t},_getTimeAxisExtent:function(){var t=this.options,e=d3.time.format(t.format),i=t.min,n=t.max,s=[i=i||"auto",n=n||"auto"],a=e.parse(i),r=e.parse(n),o=_.isDate(a),l=_.isDate(r);if(l&&o)s[0]=a,s[1]=r;else{var h=t.key,c=this._data.map((function(t){var i=t[h];return _.isDate(i)?+i:_.isString(i)?+e.parse(i):(console.log("date error: "+i+"is not a Date"),null)})),d=new Date(_.min(c)),u=new Date(_.max(c));s[0]=o?a:d,s[1]=l?r:u}return+(s=this._setTimeAxisBoundaryGap(s))[0]==+s[1]&&(s[1]=new Date(+s[1]+ONE_SECOND)),s},axisTime:function(t){var e=this._getTimeAxisExtent();return this.x=d3.time.scale().range(t).domain(e),this.x},updateAxisTime:function(t){var e=this._getTimeAxisExtent(),i=_.cloneDeep(this.x.domain());return+i[0]==+e[0]&&+i[1]==+e[1]||(this.__domain=i),this.x.range(t).domain(e),this.x},axisNondecile:function(t){var e=this.options,i=this.x=d3.scale.linear().range(t);e.max=_.sum(this._data,e.nondecile.key),i.domain(this.calExtent());var n=_.groupBy(this._data,e.key),s=this._data=[],a=0,r=s.length,o=(t[1]-t[0])/(i.domain()[1]-i.domain()[0]);for(var l in n){var h={sum:_.sum(n[l],e.nondecile.key),begin:a,end:0,center:0,radio:0};r--,h[e.key]=l,h.end=h.begin+h.sum,a+=h.sum,h.center=(h.begin+h.end)/2,e.nondecile.tickPadding&&0!==h.begin&&(h.begin=(i(h.begin)-e.nondecile.tickPadding/2-t[0])/o+i.domain()[0]),e.nondecile.tickPadding&&0!==r&&(h.end=(i(h.end)+e.nondecile.tickPadding/2-t[0])/o+i.domain()[0]),h.radio=(h.end-h.begin)/h.sum,s.push(h)}return e._afterAxis=function(){this.axisx.tickValues(_.pluck(this._data,"center"))},e.afterRender=function(){this.el.selectAll(".tick").data(this._data)},i},updateAxisNondecile:function(t){var e=this.options,i=this.x.range(t);e.max=_.sum(this._data,e.nondecile.key),i.domain(this.calExtent());var n=_.groupBy(this._data,e.key),s=this._data=[],a=0,r=s.length,o=(t[1]-t[0])/(i.domain()[1]-i.domain()[0]);for(var l in n){var h={sum:_.sum(n[l],e.nondecile.key),begin:a,end:0,center:0,radio:0};r--,h[e.key]=l,h.end=h.begin+h.sum,a+=h.sum,h.center=(h.begin+h.end)/2,e.nondecile.tickPadding&&0!==h.begin&&(h.begin=(i(h.begin)-e.nondecile.tickPadding/2-t[0])/o+i.domain()[0]),e.nondecile.tickPadding&&0!==r&&(h.end=(i(h.end)+e.nondecile.tickPadding/2-t[0])/o+i.domain()[0]),h.radio=(h.end-h.begin)/h.sum,s.push(h)}return i.domain(this.calExtent()),e._afterAxis=function(){this.axisx.tickValues(_.pluck(this._data,"center")),this.el&&this.el.selectAll(".tick").data(_.pluck(this._data,"center"))},i},calExtent:function(){var t=this,e=this.options,i=[];if("category"!==e.type.toLocaleLowerCase()){var n=[];this._data.forEach((function(i){var s=i[e.key];_.isArray(s)?("defaults"===e.type.toLocaleLowerCase()&&(s=_.map(s,(function(e){return _.toNumber(t._getValue(e))}))),n=_.union(n,s)):("defaults"===e.type.toLocaleLowerCase()&&(s=_.toNumber(t._getValue(s))),n.push(s))})),i=d3.extent(n),isFinite(e.min)&&null!==e.min&&(i[0]=e.min),i[1]=e.max||i[1]}else i=_.map(this._data,(function(i){return t._getValue(i[e.key])}));return i},_getValue:function(t){return _.isObject(t)&&t.hasOwnProperty("value")?t.value:t},getX:function(){return this.x},getAxisX:function(){return this.axisx},getMin:function(){return _.first(this.x.domain())},getMax:function(){return _.last(this.x.domain())},calGroupStep:function(t){var e=this.options.groupPadding;return Array.isArray(e)?this.groupX=d3.scale.ordinal().rangeBands([0,this.x.rangeBand()],_.isNumber(e[0])?e[0]:.4,_.isNumber(e[1])?e[1]:0):this.groupX=d3.scale.ordinal().rangeBands([0,this.x.rangeBand()],_.isNumber(e)?e:.4),Array.isArray(t)||(t=this._createCategory(parseInt(t))),this.groupX.domain(t),this.groupX},getGroupStep:function(t){return this.groupX||this.calGroupStep(t),this.groupX.rangeBand()},_createCategory:function(t){for(var e=[],i=0;i<t;i++)e.push(""+i);return e},getGroupX:function(){return this.groupX},updateSeries:function(){var t=this.options;this.el.selectAll(".net-line").remove(),this.isReset&&this["cal"+t.orient]()||this["update"+t.orient](),this.renderStyle(),this.renderLabel(),"function"==typeof t.afterRender&&t.afterRender.call(this),this.el.selectAll(".net-line").style("display",t.net?"block":"none"),this.isReset=!1},renderStyle:function(){var t=this.options,e=this.el.selectAll(".tick text").style({fill:t.fontColor,"font-size":t.fontSize,"font-weight":t.fontWeight,"stroke-width":0,display:t.textShow?"block":"none"});t.fontStrokeWidth&&e.style({stroke:t.fontColor,"stroke-width":t.fontStrokeWidth}),t.rotate&&_.isNumber(t.rotate)?e.each((function(e){var i=d3.select(this),n=_.toNumber(i.attr("x")),s=_.toNumber(i.attr("y")),a=t.rotate/360*2*Math.PI;i.attr("transform",(("Top"===t.orient||"Bottom"===t.orient)&&"translate(0 "+.5*Math.sin(a)*t.fontSize*("Bottom"===t.orient?.01:-1.99)+")"||"")+" rotate("+t.rotate+" "+n+" "+s+")").style({"text-anchor":"start"})})):e.attr("transform",""),this.el.selectAll(".domain, .tick line:not(.net-line)").style({display:t.assistLine?"block":"none",fill:"none",stroke:t.assistLineColor}),this.el.style("display",t.show?"block":"none")}}),module.exports=Axis;
"use strict";function _typeof(t){return(_typeof="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})(t)}function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function _iterableToArrayLimit(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var i=[],n=!0,s=!1,a=void 0;try{for(var r,o=t[Symbol.iterator]();!(n=(r=o.next()).done)&&(i.push(r.value),!e||i.length!==e);n=!0);}catch(t){s=!0,a=t}finally{try{n||null==o.return||o.return()}finally{if(s)throw a}}return i}}function _arrayWithHoles(t){if(Array.isArray(t))return t}var _=require("../util"),Com=require("./index"),d3=require("d3"),numberUtil=require("../util/number"),TICK_PADDING=2,MAX_TICK_COUNT=30,ONE_SECOND=1e3,timeUnitsMSMap={seconds:ONE_SECOND,minutes:60*ONE_SECOND,hours:60*ONE_SECOND*60,days:60*ONE_SECOND*60*24,months:60*ONE_SECOND*60*24*30,years:60*ONE_SECOND*60*24*30*12};function Axis(t,e,i){this.reset(),this.options={fontSize:12,fontColor:"#fff",fontWeight:"normal",fontStrokeWidth:0,key:"x",type:"defaults",orient:null,dy:0,padding:.4,groupPadding:[.4,.4],assistLine:!0,assistLineColor:"#fff",rotate:0,min:null,max:null,tickSize:0,tickValues:null,tickFormat:null,ticks:null,nondecile:{key:"y",tickPadding:10},format:"%Y-%m-%d",label:null,labelColor:"#aaa",labelInAxis:!0,labelFontSize:12,labelFontWeight:"normal",labelFontStrokeWidth:0,textAnchor:"middle",textShow:!0,net:!1,netColor:"#aaa",digit:0,show:!0},this.x=null,this.axisx=null,this.groupX=null,this.net=null,this.init(t,e,i),this._valid()}function getStep(t){var e=t.step,i=t.f,n=t.maxNeedNice,s=t.tickFormat,a="string"==typeof s?(s.split(".")[1]||"0f").split("f")[0]:0;return e=n?i(Math.ceil(Math.pow(10,a)*e)/Math.pow(10,a)):i(10*e)/10}function isTicksOverlap(t,e){if(t&&e&&t.getBoundingClientRect&&e.getBoundingClientRect){var i=t.getBoundingClientRect(),n=e.getBoundingClientRect();return i.left+i.width+TICK_PADDING>n.left&&n.left+n.width+TICK_PADDING>i.left&&i.top+i.height+TICK_PADDING>n.top&&n.top+n.height+TICK_PADDING>i.top}return!1}function removeOverlapTicksOfTargetAxis(t){return new Promise((function(e,i){if(!t)return e();for(var n=t.selectAll(".tick")[0],s=[],a=0;a<n.length;a++){var r=n[a],o=n[a+1];if(r&&o&&r.getBoundingClientRect&&o.getBoundingClientRect)for(;isTicksOverlap(r,o)&&(d3.select(o).remove(),o=n[++a+1]););}return t.selectAll(".tick")[0].forEach((function(t){s.push(t.__data__)})),e(s)}))}Axis=Com.extend(Axis,{init:function(t,e,i){if(!t&&!this.el)return!1;t&&(this.elContainer=d3.select(t)),this.options&&_.toLower(this.options.type)!==_.toLower(e.type)?this.isReset=!0:this.isReset=!1,this.options=_.deepMerge(this.options,e),this.alloptions=i||this.alloptions},_valid:function(){var t=this.options,e=["defaults","category","time","nondecile"];-1===_.indexOf(e,t.type.toLowerCase())&&(this.msg="axis arguments error. there is no "+t.type+" in types.",t.type=e[0],this.valid=!1),t.type=_.initialUpperCase(t.type);var i=["left","top","right","bottom"];-1===_.indexOf(i,t.orient.toLowerCase())&&(this.msg="axis arguments error. there is no "+t.orient+" in orients.",t.orient=i[0],this.valid=!1),t.orient=_.initialUpperCase(t.orient)},renderSeries:function(){var t=this.options;this["cal"+t.orient](),this.__el||(this.__el=this.elContainer.append("g").attr({class:"virtual_axis",opacity:0}).call(this.axisx)),this.renderStyle(),this.renderLabel(),"function"==typeof t.afterRender&&t.afterRender.call(this),this.el.selectAll(".tick line").style("display",t.net?"block":"none"),this.isReset=!1},cut:function(t,e,i){var n=_slicedToArray(t,2),s=n[0],a=n[1],r=d3.format(i),o=this.options.maxNeedNice,l=((a=+a||0)-(s=+s||0))/(e-1);l=getStep({step:l,f:r,maxNeedNice:o,tickFormat:i}),t=[],+s==+r(s)&&t.push(s);for(var h=0;h<e-1;h++){var c=r(s+l*(h+1));(c<=a||o)&&t.push(c)}var d=(t=(t=_.uniq(t.map((function(t){return+t})).sort((function(t,e){return t-e})))).filter((function(t){return t<=(o?2*a:a)}))).length-e,u=r(a),f=r(s);return d>0?t.splice(e-1,t.length-e):0===d?t[t.length-1]<u&&(t[t.length-1]=u):d<0&&(t.push(u),t.push(f)),t},format:function(){var t=this,e=this.options,i=this.axisx,n=this.x;i.tickPadding(e.dy),"object"===_typeof(e.tickSize)?i.tickSize.apply(this,e.tickSize):i.tickSize(e.tickSize),e.tickValues&&i.tickValues(e.tickValues);var s=!1;if(e.ticks){if("Category"===e.type&&_.isNumber(e.ticks)){var a=this._data;e.tickFormat=function(t,i){var n=_.toNumber(e.ticks),s=a.length,r=parseInt((s-1)/(n-1));if(0===r)return t;var o=(s-1)%(n-1),l=parseInt(o%2&&o/2+1||o/2);return i<l||s-i<=o-l||(i-l)%r?"":t},i.ticks.apply(this,[e.ticks])}else if("array"==typeof e.ticks)i.ticks.apply(this,e.ticks);else if(_.isNumber(e.ticks))if("Time"!==e.type)if(e.ticks=_.toNumber(e.ticks),"string"==typeof e.tickFormat){var r=_.clone(n.domain());switch(e.ticks){case 0:i.tickValues([r[0]]);break;case 1:i.tickValues([r[1]]);break;default:if(e.tickFormat){var o=_slicedToArray(r,2),l=o[0],h=o[1];if(r=this.cut(r,e.ticks,e.tickFormat),"defaults"===e.type.toLocaleLowerCase()){var c=+d3.format(e.tickFormat)(h),d=+d3.format(e.tickFormat)(l);r=r.filter((function(t){return+t==+d3.format(e.tickFormat)(t)&&t<=c&&t>=d}))}}i.tickValues(r)}setTimeout((function(){var e=t.el&&t.el.selectAll(".tick")[0];if(e&&e.length>1){var i=e[e.length-2];isTicksOverlap(i,e[e.length-1])&&d3.select(i).remove()}}),0)}else i.ticks(e.ticks),s=!0;else{var u=_slicedToArray(this._getTimeAxisExtent(),2),f=u[0],p=u[1],m=Math.abs(p-f),y=Math.min(MAX_TICK_COUNT,e.ticks),g=y-1?m/(y-1):2*m;Object.keys(timeUnitsMSMap).every((function(t){return g>timeUnitsMSMap[t]&&t,g>timeUnitsMSMap[t]})),i.ticks(y),s=!0}}else if(_.isNumber(e.ticks)&&"time"===e.type.toLowerCase()){var x=5*e.tickFormat(new Date).length+5,k=Math.min(e.innerWidth/x||10,MAX_TICK_COUNT);if(this._data.length<k){var v=e.tickFormat;"function"!=typeof v&&(v=d3.format(v));var A=d3.time.format(e.format),b=[],C=[],S=e.key;this._data.map((function(t){var e=A.parse(t[S]);-1===C.indexOf(v(e))&&(C.push(v(e)),b.push(e))})),i.tickValues(b)}else i.ticks(k);s=!0}if("string"==typeof e.tickFormat)i.tickFormat(d3.format(e.tickFormat));else if("function"==typeof e.tickFormat){var N=this;i.tickFormat((function(t,i){return e.tickFormat.call(N._data[i],t,i)}))}s?setTimeout((function(){removeOverlapTicksOfTargetAxis(t.__el).then((function(s){if(s&&s.length){var a=d3.svg.axis().scale(n).orient(i.orient()).tickPadding(e.dy).tickFormat(i.tickFormat()).tickValues(s).tickSize(0);t.el.call(a),t.renderStyle()}}))}),0):this.el&&this.el.call(i)},_afterAxis:function(){var t=this.options;"function"==typeof t._afterAxis&&t._afterAxis.call(this)},renderLabel:function(){var t=this.options,e=this.alloptions;if(t.label){if(t.labelInAxis){var i=this.el.select(".axis-unit")[0][0]&&this.el.select(".axis-unit")||this.el.append("g").attr({class:"axis-unit"}),n=this.el.selectAll(".tick:nth-last-child(3)").select("text");n&&n.length&&n[0].length&&("Left"===t.orient||"Right"===t.orient?i.attr("transform","translate(0,"+-1.5*parseInt(n.style("font-size"))+")"):i.attr("transform","translate("+((t.innerWidth||e.innerWidth)+3*parseInt(n.style("font-size")))+", 0)"),(i.select("text")[0][0]&&i.select("text")||i.append("text")).attr({dy:n.attr("dy"),x:n.attr("x"),y:n.attr("y"),transform:n.attr("transform")}).text(t.label).style({"text-anchor":n.style("text-anchor"),"font-size":n.style("font-size"),"font-weight":n.style("font-weight"),fill:n.style("fill")}))}}else this.el.select(".axis-unit").remove()},calLeft:function(){var t=this.options,e=this.alloptions,i=this.x=this["axis"+t.type].call(this,[t.innerHeight||e.innerHeight,0]),n=this.axisx=d3.svg.axis().scale(i).orient("left");this.format(),this._afterAxis(),this.el&&-1!==this.el.attr("class").indexOf("axis")?this.el.call(n):this.el=this.elContainer.append("g").attr("class","axis").call(n),this.net=this.el.selectAll(".tick"+("Category"!==t.type&&1!==t.ticks?":not(:first-child)":"")).append("line").attr({class:"net-line",x2:t.innerWidth||e.innerWidth,y2:"0"}).style({"stroke-dasharray":"2 2",stroke:t.netColor})},updateLeft:function(){var t=this.options,e=this.alloptions;this["updateAxis"+t.type].call(this,[t.innerHeight||e.innerHeight,0]),this.format(),this._afterAxis(),this.__el&&this.__el.call(this.axisx),this.net=this.el.selectAll(".tick"+("Category"!==t.type&&1!==t.ticks?":not(:first-child)":"")).append("line").attr({class:"net-line",x2:t.innerWidth||e.innerWidth,y2:"0"}).style({"stroke-dasharray":"2 2",stroke:t.netColor})},calRight:function(){var t=this.options,e=this.alloptions,i=this.x=this["axis"+t.type].call(this,[t.innerHeight||e.innerHeight,0]),n=this.axisx=d3.svg.axis().scale(i).orient("right");this.format(),this._afterAxis(),this.el&&-1!==this.el.attr("class").indexOf("axis")?this.el.attr({transform:"translate("+(t.innerWidth||e.innerWidth)+", 0)"}).call(n):this.el=this.elContainer.append("g").attr({class:"axis",transform:"translate("+(t.innerWidth||e.innerWidth)+", 0)"}).call(n),this.net=this.el.selectAll(".tick"+("Category"!==t.type&&1!==t.ticks?":not(:first-child)":"")).append("line").attr({class:"net-line",x2:-t.innerWidth||-e.innerWidth,y2:"0"}).style({"stroke-dasharray":"2 2",stroke:t.netColor})},updateRight:function(){var t=this.options,e=this.alloptions;this["updateAxis"+t.type].call(this,[t.innerHeight||e.innerHeight,0]),this.format(),this._afterAxis(),this.__el&&this.__el.attr("transform","translate("+(t.innerWidth||e.innerWidth)+", 0)").call(this.axisx),this.el.attr("transform","translate("+(t.innerWidth||e.innerWidth)+", 0)"),this.net=this.el.selectAll(".tick"+("Category"!==t.type&&1!==t.ticks?":not(:first-child)":"")).append("line").attr({class:"net-line",x2:-t.innerWidth||-e.innerWidth,y2:"0"}).style({stroke:t.netColor})},calTop:function(){var t=this.options,e=this.alloptions,i=this.x=this["axis"+t.type].call(this,[0,t.innerWidth||e.innerWidth]),n=this.axisx=d3.svg.axis().scale(i).orient("top");this.format(),this._afterAxis(),this.el&&-1!==this.el.attr("class").indexOf("axis")?this.el.call(n):this.el=this.elContainer.append("g").attr("class","axis").call(n),this.net=this.el.selectAll(".tick"+("Category"!==t.type&&1!==t.ticks?":not(:first-child)":"")).append("line").attr({class:"net-line",y2:t.innerHeight||e.innerHeight,x2:"0"}).style({"stroke-dasharray":"2 2",stroke:t.netColor})},updateTop:function(){var t=this.options,e=this.alloptions;this["updateAxis"+t.type].call(this,[0,t.innerWidth||e.innerWidth]),this.format(),this._afterAxis(),this.__el&&this.__el.call(this.axisx),this.net=this.el.selectAll(".tick"+("Category"!==t.type&&1!==t.ticks?":not(:first-child)":"")).append("line").attr({class:"net-line",y2:t.innerHeight||e.innerHeight,x2:"0"}).style({"stroke-dasharray":"2 2",stroke:t.netColor})},calBottom:function(){var t=this.options,e=this.alloptions,i=this.x=this["axis"+t.type].call(this,[0,t.innerWidth||e.innerWidth]),n=this.axisx=d3.svg.axis().scale(i).orient("bottom");this.format(),this._afterAxis(),this.el&&-1!==this.el.attr("class").indexOf("axis")?this.el.attr({transform:"translate(0,"+(t.innerHeight||e.innerHeight)+")"}).call(n):this.el=this.elContainer.append("g").attr({class:"axis",transform:"translate(0,"+(t.innerHeight||e.innerHeight)+")"}).call(n),this.net=this.el.selectAll(".tick"+("Category"!==t.type&&1!==t.ticks?":not(:first-child)":"")).append("line").attr({class:"net-line",y2:-t.innerHeight||-e.innerHeight,x2:"0"}).style({"stroke-dasharray":"2 2",stroke:t.netColor})},updateBottom:function(){var t=this.options,e=this.alloptions;this["updateAxis"+t.type].call(this,[0,t.innerWidth||e.innerWidth]),this.format(),this._afterAxis(),this.__el&&this.__el.attr("transform","translate(0,"+(t.innerHeight||e.innerHeight)+")").call(this.axisx),this.el.attr("transform","translate(0,"+(t.innerHeight||e.innerHeight)+")"),this.net=this.el.selectAll(".tick"+("Category"!==t.type&&1!==t.ticks?":not(:first-child)":"")).append("line").attr({class:"net-line",y2:-t.innerHeight||-e.innerHeight,x2:"0"}).style({"stroke-dasharray":"2 2",stroke:t.netColor})},niceExtent:function(t,e){var i=this.options,n=Math.abs(e[1]-e[0]);t<=1&&(t=2);var s=numberUtil.nice(n/t,!0),a=numberUtil.getPrecisionSafe(s)+2,r=[i.minNeedNice?numberUtil.round(Math.floor(e[0]/s)*s,a):e[0],i.maxNeedNice?numberUtil.round(Math.ceil(e[1]/s)*s,a):e[1]];return _.toNumber(r[0])>_.toNumber(r[1])&&_.reverse(r),"defaults"===i.type.toLocaleLowerCase()&&i.tickFormat&&(r=d3.extent(this.cut(r,i.ticks,i.tickFormat).concat(r[0],r[1]))),r},axisDefaults:function(t){var e=this.x=d3.scale.linear().range(t),i=this.calExtent(),n=this.options,s=this.niceExtent(n.ticks,i);return e.domain(s),e},updateAxisDefaults:function(t){this.x.range(t);var e=this.calExtent(),i=this.options,n=this.niceExtent(i.ticks,e);return this.x.domain(n),this.x},axisCategory:function(t){var e,i=this.options;e=_.isArray(i.padding)?this.x=d3.scale.ordinal().rangeBands(t,i.padding[0],i.padding[1]):this.x=d3.scale.ordinal().rangeBands(t,i.padding/2,i.padding);var n=this.calExtent();return e.domain(n),e},updateAxisCategory:function(t){var e=this.options;return _.isArray(e.padding)?this.x.rangeBands(t,e.padding[0],e.padding[1]):this.x.rangeBands(t,e.padding/2,e.padding),this.x.domain(this.calExtent()),this.x},_setTimeAxisBoundaryGap:function(t){var e=this.options.blank?this.options.blankDis:0;if(e&&this._data&&this._data.length){var i=(+t[1]-t[0])/this._data.length,n=parseInt(i*e);t=[new Date(+t[0]-n),new Date(+t[1]+n)]}return t},_getTimeAxisExtent:function(){var t=this.options,e=d3.time.format(t.format),i=t.min,n=t.max,s=[i=i||"auto",n=n||"auto"],a=e.parse(i),r=e.parse(n),o=_.isDate(a),l=_.isDate(r);if(l&&o)s[0]=a,s[1]=r;else{var h=t.key,c=this._data.map((function(t){var i=t[h];return _.isDate(i)?+i:_.isString(i)?+e.parse(i):(console.log("date error: "+i+"is not a Date"),null)})),d=new Date(_.min(c)),u=new Date(_.max(c));s[0]=o?a:d,s[1]=l?r:u}return+(s=this._setTimeAxisBoundaryGap(s))[0]==+s[1]&&(s[1]=new Date(+s[1]+ONE_SECOND)),s},axisTime:function(t){var e=this._getTimeAxisExtent();return this.x=d3.time.scale().range(t).domain(e),this.x},updateAxisTime:function(t){var e=this._getTimeAxisExtent(),i=_.cloneDeep(this.x.domain());return+i[0]==+e[0]&&+i[1]==+e[1]||(this.__domain=i),this.x.range(t).domain(e),this.x},axisNondecile:function(t){var e=this.options,i=this.x=d3.scale.linear().range(t);e.max=_.sum(this._data,e.nondecile.key),i.domain(this.calExtent());var n=_.groupBy(this._data,e.key),s=this._data=[],a=0,r=s.length,o=(t[1]-t[0])/(i.domain()[1]-i.domain()[0]);for(var l in n){var h={sum:_.sum(n[l],e.nondecile.key),begin:a,end:0,center:0,radio:0};r--,h[e.key]=l,h.end=h.begin+h.sum,a+=h.sum,h.center=(h.begin+h.end)/2,e.nondecile.tickPadding&&0!==h.begin&&(h.begin=(i(h.begin)-e.nondecile.tickPadding/2-t[0])/o+i.domain()[0]),e.nondecile.tickPadding&&0!==r&&(h.end=(i(h.end)+e.nondecile.tickPadding/2-t[0])/o+i.domain()[0]),h.radio=(h.end-h.begin)/h.sum,s.push(h)}return e._afterAxis=function(){this.axisx.tickValues(_.pluck(this._data,"center"))},e.afterRender=function(){this.el.selectAll(".tick").data(this._data)},i},updateAxisNondecile:function(t){var e=this.options,i=this.x.range(t);e.max=_.sum(this._data,e.nondecile.key),i.domain(this.calExtent());var n=_.groupBy(this._data,e.key),s=this._data=[],a=0,r=s.length,o=(t[1]-t[0])/(i.domain()[1]-i.domain()[0]);for(var l in n){var h={sum:_.sum(n[l],e.nondecile.key),begin:a,end:0,center:0,radio:0};r--,h[e.key]=l,h.end=h.begin+h.sum,a+=h.sum,h.center=(h.begin+h.end)/2,e.nondecile.tickPadding&&0!==h.begin&&(h.begin=(i(h.begin)-e.nondecile.tickPadding/2-t[0])/o+i.domain()[0]),e.nondecile.tickPadding&&0!==r&&(h.end=(i(h.end)+e.nondecile.tickPadding/2-t[0])/o+i.domain()[0]),h.radio=(h.end-h.begin)/h.sum,s.push(h)}return i.domain(this.calExtent()),e._afterAxis=function(){this.axisx.tickValues(_.pluck(this._data,"center")),this.el&&this.el.selectAll(".tick").data(_.pluck(this._data,"center"))},i},calExtent:function(){var t=this,e=this.options,i=[];if("category"!==e.type.toLocaleLowerCase()){var n=[];this._data.forEach((function(i){var s=i[e.key];_.isArray(s)?("defaults"===e.type.toLocaleLowerCase()&&(s=_.map(s,(function(e){return _.toNumber(t._getValue(e))}))),n=_.union(n,s)):("defaults"===e.type.toLocaleLowerCase()&&(s=_.toNumber(t._getValue(s))),n.push(s))})),i=d3.extent(n),isFinite(e.min)&&null!==e.min&&(i[0]=e.min),i[1]=e.max||i[1]}else i=_.map(this._data,(function(i){return t._getValue(i[e.key])}));return i},_getValue:function(t){return _.isObject(t)&&t.hasOwnProperty("value")?t.value:t},getX:function(){return this.x},getAxisX:function(){return this.axisx},getMin:function(){return _.first(this.x.domain())},getMax:function(){return _.last(this.x.domain())},calGroupStep:function(t){var e=this.options.groupPadding;return Array.isArray(e)?this.groupX=d3.scale.ordinal().rangeBands([0,this.x.rangeBand()],_.isNumber(e[0])?e[0]:.4,_.isNumber(e[1])?e[1]:0):this.groupX=d3.scale.ordinal().rangeBands([0,this.x.rangeBand()],_.isNumber(e)?e:.4),Array.isArray(t)||(t=this._createCategory(parseInt(t))),this.groupX.domain(t),this.groupX},getGroupStep:function(t){return this.groupX||this.calGroupStep(t),this.groupX.rangeBand()},_createCategory:function(t){for(var e=[],i=0;i<t;i++)e.push(""+i);return e},getGroupX:function(){return this.groupX},updateSeries:function(){var t=this.options;this.el.selectAll(".net-line").remove(),this.isReset&&this["cal"+t.orient]()||this["update"+t.orient](),this.renderStyle(),this.renderLabel(),"function"==typeof t.afterRender&&t.afterRender.call(this),this.el.selectAll(".net-line").style("display",t.net?"block":"none"),this.isReset=!1},renderStyle:function(){var t=this.options,e=this.el.selectAll(".tick text").style({fill:t.fontColor,"font-size":t.fontSize,"font-weight":t.fontWeight,"stroke-width":0,display:t.textShow?"block":"none"});t.fontStrokeWidth&&e.style({stroke:t.fontColor,"stroke-width":t.fontStrokeWidth}),t.rotate&&_.isNumber(t.rotate)?e.each((function(e){var i=d3.select(this),n=_.toNumber(i.attr("x")),s=_.toNumber(i.attr("y")),a=t.rotate/360*2*Math.PI;i.attr("transform",(("Top"===t.orient||"Bottom"===t.orient)&&"translate(0 "+.5*Math.sin(a)*t.fontSize*("Bottom"===t.orient?.01:-1.99)+")"||"")+" rotate("+t.rotate+" "+n+" "+s+")").style({"text-anchor":"start"})})):e.attr("transform",""),this.el.selectAll(".domain, .tick line:not(.net-line)").style({display:t.assistLine?"block":"none",fill:"none",stroke:t.assistLineColor}),this.el.style("display",t.show?"block":"none")}}),module.exports=Axis;

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

"use strict";function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,o=new Array(e);i<e;i++)o[i]=t[i];return o}function _iterableToArrayLimit(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var i=[],o=!0,r=!1,s=void 0;try{for(var n,a=t[Symbol.iterator]();!(o=(n=a.next()).done)&&(i.push(n.value),!e||i.length!==e);o=!0);}catch(t){r=!0,s=t}finally{try{o||null==a.return||a.return()}finally{if(r)throw s}}return i}}function _arrayWithHoles(t){if(Array.isArray(t))return t}var _=require("../util"),Com=require("./index"),d3=require("d3"),TRIGGER_AXIS="axis",STROKE_DASH_MAP={solid:"none",dashed:"10, 10",dotted:"2, 2"},ITEM_TRIGGER_METHOD_MAP={click:{show:"click",hide:"dblclick"},hover:{show:"mouseover",hide:"mouseout"}},AXIS_TRIGGER_METHOD_MAP={click:"click",hover:"mousemove"},_defaultFormatterMap={xyzAxisChart:_xyzAxisChartFormatter,xyAxisChart:_xyAxisChartFormatter,doubleLineChart:_doubelLineChartFormatter,pieChart:_pieChartFormatter,horiBarChart:_horiBarFormatter};function Tooltip(t,e,i,o){this.reset(),this.comObj=e,this.options={show:"true",formatter:{},trigger:"item",enterFocus:!1,hideDelay:100,axisPointer:"line",autoSize:!0,backgroundColor:"rgba(0,0,0,0.65)",color:"#fff",beforeFormat:null,padding:10,lineStyle:{color:"#f00",width:1,_type:"solid"}},this.init(t,i,o),this._valid()}function getTrans(t,e){if(!t&&!e)return{transX:0,transY:0};var i=getXY(t),o=i.x,r=i.y,s=getXY(e);return{transX:o+s.x,transY:r+s.y}}function getXY(t){if(!t||-1===t.indexOf("(")||-1===t.indexOf(")"))return{x:0,y:0};var e=_slicedToArray(t.split("(")[1].split(")")[0].split(","),2);return{x:+e[0],y:+e[1]}}function _creatToolTipSerieRow(t){var e=t.serie,i=t.color,o=t.value,r=t.key,s=t.format;return'<div><span style="display:inline-block; margin-right:5px; border-radius:2px; width:10px; height:10px;\n background:'.concat(i||e&&e.color&&(e.color.gradientValue||e.color.value)||"#ccc",'"></span>\n ').concat(r?r+": ":"").concat(_.isFunction(s)&&s(o)||o,"</div>")}function _xyAxisChartFormatter(t,e,i){var o=this.options.trigger,r='<div class="dchart-tooltip">',s=this.alloptions.series,n=this.alloptions.hiddenEmptyData,a=[],l=this.alloptions.yaxis.format?d3.format(this.alloptions.yaxis.format):function(t){return t};if(o===TRIGGER_AXIS)t.x&&a.push("<b>".concat(t.x.toString(),"</b>")),t.y&&t.y.forEach&&t.y.forEach((function(t,e){return!(n&&t.__isNull)&&a.push(_creatToolTipSerieRow({serie:s[e],value:t.value,format:l}))}));else{var h=Array.isArray(t.y)?t.y[e]:t.y;n&&h.__isNull||a.push(_creatToolTipSerieRow({serie:s[e],value:h.value&&h.value.toString()||0,key:t.x.toString(),format:l}))}return r+="".concat(a.join(""),"</div>")}function _doubelLineChartFormatter(t,e,i){var o='<div class="dchart-tooltip">',r=this.alloptions,s=r.series,n=r.series2,a=[],l=(this.data()||[]).length;return this.options.trigger===TRIGGER_AXIS?(t.x&&a.push("<b>".concat(t.x.toString(),"</b>")),t.y&&t.y.forEach((function(t,e){return a.push(_creatToolTipSerieRow({color:s[e]&&s[e].line.color,value:t}))})),t.z&&t.z.forEach((function(t,e){return a.push(_creatToolTipSerieRow({color:n[e]&&n[e].line.color,value:t}))}))):a.push(_creatToolTipSerieRow({color:(i/l>=1?s:n)[0].point.color,value:i/l>=1?t.y&&t.y.toString()||0:t.z&&t.z.toString()||0,key:t.x.toString()})),o+="".concat(a.join(""),"</div>")}function _pieChartFormatter(t,e,i){var o='<div class="dchart-tooltip">',r=this.alloptions,s=r.series,n=r.label,a=this._data.map((function(t){return t.y})).reduce((function(t,e){return t+e}),0),l=(t.y/a*100).toFixed(n.account.decimal)+"%";return t.y&&(o+=_creatToolTipSerieRow({color:s[e].color.value,key:t.x,value:"".concat(t.y," (").concat(l,")")})),o}function _xyzAxisChartFormatter(t,e,i){var o='<div class="dchart-tooltip">',r=this.alloptions.series,s=this._data.length,n=[];t.x&&n.push("<b>".concat(t.x.toString(),"</b>"));var a=this.options.trigger===TRIGGER_AXIS,l=d3.format(this.alloptions.yaxis.format),h=d3.format(this.alloptions.zaxis.format);return(a||i/s<1)&&t.y&&(t.y=[].concat(t.y))&&t.y.forEach((function(t,e){return n.push(_creatToolTipSerieRow({serie:r[e]&&r[e].bar,value:t.value,format:l}))})),(a||i/s>1)&&t.z&&t.z.forEach&&t.z.forEach((function(t,e){return n.push(_creatToolTipSerieRow({serie:r[e]&&r[e].line,value:t.value,format:h}))})),o+="".concat(n.join(""),"</div>")}function _horiBarFormatter(t,e,i,o){var r=this.options.trigger,s='<div class="dchart-tooltip">',n=this.alloptions.series,a=[],l=this.alloptions.xaxis.format?d3.format(this.alloptions.xaxis.format):function(t){return t};if(r===TRIGGER_AXIS)t.x&&a.push("<b>".concat(t.x.toString(),"</b>")),t.y&&t.y.forEach&&t.y.forEach((function(t,e){return(0===t||t)&&a.push(_creatToolTipSerieRow({format:l,serie:n[e],value:t.value}))}));else{var h=Array.isArray(t.y)?t.y[e]:t.y,c=+o.select("rect").attr("order");a.push(_creatToolTipSerieRow({format:l,serie:n[c],value:h.value&&h.value.toString()||0,key:t.x.toString()}))}return s+="".concat(a.join(""),"</div>")}function clearListenersOnSelector(t){t&&t.on&&t.on("mouseover",(function(){})).on("mousemove",(function(){})).on("mouseleave",(function(){})).on("click",(function(){})).on("mouseout",(function(){})).on("dblclick",(function(){}))}function getLeft(t,e){return t.getBBox().width-(e.options.net?e.options.innerWidth:0)}Tooltip=Com.extend(Tooltip,{init:function(t,e,i){return!(!t&&!this.el)&&(t&&(this.el=d3.select(t)),this.options=_.deepMerge(this.options,e),this.alloptions=i||this.alloptions,this)},_valid:function(){},renderSeries:function(){var t=this.options,e=this.alloptions;this.layer={};var i=this.el.select(".con-svg");this.layer.width=e.innerWidth,this.layer.height=e.innerHeight,this.layer.svgContainer=i,this.layer.x=this.comObj.getComs("axis","xaxis"),this.layer.y=this.comObj.getComs("axis","yaxis"),this.dispatch=d3.dispatch("elementMouseover","elementMouseout"),this.tooltip=this.el.select(".dc-tooltip")[0][0]?this.el.select(".dc-tooltip"):this.el.append("div").attr("class","dc-tooltip").style({display:"none",position:"absolute",color:t.color,background:t.backgroundColor,padding:t.padding+"px","border-radius":"5%"});var o=this;this.tooltip.on("mouseenter",(function(){o.options.enterFocus&&clearTimeout(o._hideTimeout)})).on("mouseout",(function(){o.options.trigger&&(clearTimeout(this._hideTimeout),o.hide(o.options.hideDelay))})),this.initGuildLayer()},show:function(){clearTimeout(this._hideTimeout),this.options.trigger===TRIGGER_AXIS&&this.isAxisChart()?this.showAxis.apply(this,arguments):this.showItem.apply(this,arguments)},showItem:function(t,e,i,o,r,s){"function"==typeof i&&(t=i.call(this,t,o,r,s));var n=this.defaultFormatter(t),a=this.options.formatter;"string"==typeof a?n=_defaultFormatterMap[a]&&_defaultFormatterMap[a].call(this,t,o,r,s):"function"==typeof a&&(n=a(t,o,r,s)),this.tooltip.html(n),this.tooltip.transition().duration(20).style("display","block");var l=d3.event||window.event,h=this.getTipPosition(l);this.tooltip.style("left",+h.x+"px").style("top",+h.y+"px")},showAxis:function(t,e,i){"function"==typeof i&&(t=i.call(this,t));var o=this.defaultFormatter(t),r=this.options.formatter;"string"==typeof r?o=_defaultFormatterMap[r]&&_defaultFormatterMap[r].call(this,t):"function"==typeof r&&(o=r(t));var s,n,a,l,h,c=d3.mouse(e[0][0]),u=this.alloptions,d=this.isVertical();d?(s=this.layer.x.getX(),n=u.xaxis.key,a=u.xaxis.type,l=this.layer.y,h=u.yaxis.orient):(s=this.layer.y.getX(),n=u.yaxis.key,a=u.yaxis.type,l=this.layer.x,h=u.xaxis.orient);var p=l.el[0][0],f=0;if(d){var y=t[n];if("time"===a)y=s(d3.time.format(u.xaxis.format).parse(t[n]));else y=s(t[n]);f=y+ +u.margin.left+(u.margin.containLabel&&"left"===h?getLeft(p,l):0)}else f=c[0]+u.margin.left;var m=d&&c[1]+u.margin.top||s("time"===a&&new Date(t[n])||t[n])+u.margin.top+(u.margin.containLabel&&"top"===h?p.getBBox().height:0);this.tooltip.html(o),this.tooltip.transition().duration(20).style("display","block");var g=this.options,x=this.getTipPositionAxis({left:f+(d&&s.rangeBand&&s.rangeBand()/2||0)+2*+g.xOffset,top:m+(d?0:s.rangeBand&&s.rangeBand()/2||0)+ +g.yOffset});this.tooltip.style("left",x.left+"px").style("top",x.top+"px")},getBoxSize:function(){var t=150,e=50;if(this.options.autoSize){var i=this.tooltip&&this.tooltip.node();i&&(t=i.offsetWidth||t,e=i.offsetHeight||e)}else t=this.options.width,e=this.options.height;return{boxWidth:t,boxHeight:e}},getTipPositionAxis:function(t){var e=t.left,i=t.top,o=document.body,r=o.offsetWidth,s=o.offsetHeight,n=this.el.node().parentElement.parentElement,a=n.offsetLeft,l=n.offsetTop,h=this.getBoxSize(),c=h.boxWidth,u=h.boxHeight;return a+e+c>r&&(e=Math.max(e-c,0)),l+i+u>s&&(i=Math.max(i-u)),{top:i,left:e}},getTipPosition:function(t){var e=this.options,i=e.xOffset,o=e.yOffset,r=t.offsetX,s=t.offsetY,n={x:r+i,y:s+o},a=document.body,l=a.offsetWidth,h=a.offsetHeight,c=this.getBoxSize(),u=c.boxWidth,d=c.boxHeight,p=this.el.node().parentElement.parentElement,f=p.offsetLeft,y=p.offsetTop;return f+r+u+i>l&&(n.x=Math.max(r-u,0)),y+s+d+o>h&&(n.y=Math.max(s-d)),n},hide:function(){this.options.enterFocus=!0,this.options.enterFocus?this._delayHide():this._contentHide()},_contentHide:function(){this.tooltip.style("display","none")},_delayHide:function(){var t=this;this.options.enterFocus&&(clearTimeout(this._hideTimeout),this._hideTimeout=setTimeout((function(){t._contentHide()}),this.options.hideDelay))},defaultFormatter:function(t){var e='<div class="dchart-tooltip">',i=0;return _.forIn(t,(function(t,o,r){e+=(0!==i?"<br>":"")+o+": "+(t=t||0).toString(),i++})),e+="</div>"},initGuildLayer:function(){var t=this.alloptions;this.wrap=this.el.select(".guildLayer")[0][0]?this.el.select(".guildLayer"):this.el.select(".con-svg").append("g").attr({class:"guildLayer",transform:"translate("+t.margin.left+","+t.margin.top+")"});var e=this.wrap.select(".guildLineLayer")[0][0]?this.wrap.select(".guildLineLayer"):this.wrap.append("g").attr("class","guildLineLayer");e.style("pointer-events","none"),e.select(".guildLine")[0][0]?e.select(".guildLine"):e.append("g").attr("class","guildLine")},triggerAxis:function(){var t=this,e=this,i=(this.options,this.layer.width),o=this.layer.height,r=this.layer.y,s=this.layer.x,n=this.dispatch,a=this.alloptions.margin,l=this,h=this.alloptions,c=this.options.triggerMethod,u=this.layer.svgContainer,d=getTrans(this.el.select(".con-g").attr("transform"),this.el.select(".series").attr("transform")),p=d.transX;d.transY;u.on(AXIS_TRIGGER_METHOD_MAP[c]||"mousemove",(function(){if(e.isAxisChart()&&e.options.trigger===TRIGGER_AXIS){var t=d3.event,c=t.offsetX,u=t.offsetY,d=e.isVertical(),f=d&&s.getX()||r.getX(),y=d&&f.range()||_.clone(f.range()).reverse(),m=d&&f.domain()||_.clone(f.domain()).reverse();if(c-=a.left,u-=a.top,a.containLabel&&("top"===h.xaxis.orient&&(u-=s.options.__height),"left"===h.yaxis.orient&&(c-=p)),c+10<0||u+10<0||c-10>i||u-10>o)return n.elementMouseout({mouseX:c,mouseY:u}),void l.renderGuildLayer(null);l.renderGuildLayer(null);var g="function"==typeof f.rangeBands,x=void 0,v=d?c:u;if(g){var T=d3.bisect(y,v),b=f.rangeBand(),A=y.length;if(0===T)x=m[T];else if(T===A)x=m[T-1];else{var S=Math.abs(y[T]-v);Math.abs(v-y[T-1]-b)<S&&(T-=1),x=m[T]}}else x=f.invert(v);n.elementMouseover({mouseX:c,mouseY:u,pointValue:x})}})),u.on("mouseleave",(function(){"hover"===c&&(t.renderGuildLayer(null),t.hide())}))},hideGuidLine:function(){this.el.select(".guildLine").selectAll("line").attr("display","none")},renderGuildLayer:function(t){if(0!==t&&!t)return this.hideGuidLine(),!1;var e=getTrans(this.el.select(".con-g").attr("transform"),this.el.select(".series").attr("transform")),i=e.transX,o=e.transY;this.el.select(".guildLayer").attr("transform","translate(".concat(i,", ").concat(o,")"));var r=this.options.lineStyle,s=this.isVertical(),n=this.el.select(".guildLine").selectAll("line").data(null!=t?[t]:[],String);n.enter().append("line");var a=this.layer.y.options,l=this.alloptions;n.attr("display","block").attr("class","tooltip-guideline").attr("x1",(function(t){return s&&_.isNumber(t)?t:0})).attr("x2",(function(t){return s&&_.isNumber(t)?t:a.innerWidth})).attr("y1",(function(t){return s?a.innerHeight||l.innerHeight:t})).attr("y2",(function(t){return!s&&_.isNumber(t)?t:0})).attr("stroke",r.color).attr("stroke-width",r.width).attr("stroke-dasharray",STROKE_DASH_MAP[r._type]).style("cursor","pointer"),n.exit().remove()},isVertical:function(){var t=this.alloptions;return"time"===t.xaxis.type||"category"===t.xaxis.type||"time"!==t.yaxis.type&&"category"!==t.yaxis.type},isAxisChart:function(){var t=this.alloptions;return t&&t.xaxis&&t.yaxis},updateItem:function(t){var e=this,i=this.selector,o=this.selectorText,r=this.options.triggerMethod,s=this.layer.svgContainer.select(".con-g");if(i){clearListenersOnSelector(i);var n=this.options.beforeFormat;i.on(ITEM_TRIGGER_METHOD_MAP[r].show||"mouseover",(function(t,i,o){clearTimeout(e._hideTimeout),(t||void 0!==i||void 0!==o)&&e.show(t&&t.data||t,s,n,i,o,d3.select(this))})).on(ITEM_TRIGGER_METHOD_MAP[r].hide||"mouseout",(function(){clearTimeout(e._hideTimeout),e.hide()}))}if(o){clearListenersOnSelector(o);var a=this.options.beforeFormat;o.on(ITEM_TRIGGER_METHOD_MAP[r].show||"mouseover",(function(t,i,o){clearTimeout(e._hideTimeout),(t||void 0!==i||void 0!==o)&&e.show(t&&t.data||t,s,a,i,o,d3.select(this))})).on(ITEM_TRIGGER_METHOD_MAP[r].hide||"mouseout",(function(){clearTimeout(e._hideTimeout),e.hide()}))}},updateAxis:function(){this.triggerAxis();var t,e,i,o,r=this,s=this.alloptions,n=this.options,a=this.isVertical(),l=s.xaxis.key,h=s.yaxis.key,c=s.zaxis&&s.zaxis.key,u=null;a?(t=l,e=s.xaxis.type,i=this.comObj.getComs("axis","xaxis").getX(),u=this.comObj.getComs("axis","xaxis").getX(),o=s.xaxis.format):(t=h,e=s.yaxis.type,i=this.comObj.getComs("axis","yaxis").getX(),u=this.comObj.getComs("axis","xaxis").getX(),o=s.yaxis.format);var d=a?this.layer.width:this.layer.height,p=this.layer.svgContainer.select(".con-g"),f=r.data();this.dispatch.on("elementMouseover",(function(s){var a,y,m,g=0,x=(a=s,y=d,m=0,f.forEach((function(r,s){var n=r[t];"time"===e&&o&&(n=d3.time.format(o).parse(r[t])),diff=Math.abs(i(n)-i(a.pointValue)),u(r[t]),diff<y&&(y=diff,m=s,g=n)})),f[m]);if(r.show(x,p,n.beforeFormat||function(t){var e={};return e[l]=t[l],e[h]=t[h],c&&(e[c]=t[c]),e}),"line"===n.axisPointer){var v=i(g)+("category"===e?i.rangeBand()/2:0);r.renderGuildLayer(v)}})),this.dispatch.on("elementMouseout",(function(){r.hide()}))},updateEvent:function(t){var e=this.options,i=e.trigger;if(t&&"function"==typeof t){var o=t();o&&(this.selector=o,this.selectorText=d3.select(".series").selectAll(".series-group").selectAll(".serie-label-text"))}if(this.selector&&this.selector.style("cursor",e.show?"pointer":"default"),this.selectorText&&this.selectorText.style("cursor",e.show?"pointer":"default"),this.clearListeners(),this.renderGuildLayer(null),e.show){this.isAxisChart()&&i===TRIGGER_AXIS?this.updateAxis():this.updateItem(t);var r=this.el.select(".dc-tooltip");r.style({display:"none",position:"absolute",color:e.color,background:e.backgroundColor,padding:"".concat(e.padding,"px"),"border-radius":"5%","border-color":e.borderColor,"border-width":"".concat(e.borderWidth,"px"),"border-style":"solid","font-size":e.fontSize,"font-weight":e.fontWeight,"font-family":e.fontFamily,"pointer-events":"none"}),e.autoSize?(r[0]&&(r[0][0].style.height=""),r.style("white-space","nowrap"),r.style("width","fit-content")):r.style({width:"".concat(e.width,"px"),height:"".concat(e.height,"px"),"word-break":"break-all","white-space":"normal"})}},clearListeners:function(){clearListenersOnSelector(this.layer.svgContainer),this.selector&&clearListenersOnSelector(this.selector)},destroy:function(){this.clearListeners(),this.tooltip&&this.tooltip.remove()}}),module.exports=Tooltip;
"use strict";function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,o=new Array(e);i<e;i++)o[i]=t[i];return o}function _iterableToArrayLimit(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var i=[],o=!0,r=!1,s=void 0;try{for(var n,a=t[Symbol.iterator]();!(o=(n=a.next()).done)&&(i.push(n.value),!e||i.length!==e);o=!0);}catch(t){r=!0,s=t}finally{try{o||null==a.return||a.return()}finally{if(r)throw s}}return i}}function _arrayWithHoles(t){if(Array.isArray(t))return t}var _=require("../util"),Com=require("./index"),d3=require("d3"),TRIGGER_AXIS="axis",STROKE_DASH_MAP={solid:"none",dashed:"10, 10",dotted:"2, 2"},ITEM_TRIGGER_METHOD_MAP={click:{show:"click",hide:"dblclick"},hover:{show:"mouseover",hide:"mouseout"}},AXIS_TRIGGER_METHOD_MAP={click:"click",hover:"mousemove"},_defaultFormatterMap={xyzAxisChart:_xyzAxisChartFormatter,xyAxisChart:_xyAxisChartFormatter,doubleLineChart:_doubelLineChartFormatter,pieChart:_pieChartFormatter,horiBarChart:_horiBarFormatter};function Tooltip(t,e,i,o){this.reset(),this.comObj=e,this.options={show:"true",formatter:{},trigger:"item",enterFocus:!1,hideDelay:100,axisPointer:"line",autoSize:!0,backgroundColor:"rgba(0,0,0,0.65)",color:"#fff",beforeFormat:null,padding:10,lineStyle:{color:"#f00",width:1,_type:"solid"}},this.init(t,i,o),this._valid()}function getTrans(t,e){if(!t&&!e)return{transX:0,transY:0};var i=getXY(t),o=i.x,r=i.y,s=getXY(e);return{transX:o+s.x,transY:r+s.y}}function getXY(t){if(!t||-1===t.indexOf("(")||-1===t.indexOf(")"))return{x:0,y:0};var e=_slicedToArray(t.split("(")[1].split(")")[0].split(","),2);return{x:+e[0],y:+e[1]}}function _creatToolTipSerieRow(t){var e=t.serie,i=t.color,o=t.value,r=t.key,s=t.format;return'<div><span style="display:inline-block; margin-right:5px; border-radius:2px; width:10px; height:10px;\n background:'.concat(i||e&&e.color&&(e.color.gradientValue||e.color.value)||"#ccc",'"></span>\n ').concat(r?r+": ":"").concat(_.isFunction(s)&&s(o)||o,"</div>")}function _xyAxisChartFormatter(t,e,i){var o=this.options.trigger,r='<div class="dchart-tooltip">',s=this.alloptions.series,n=this.alloptions.hiddenEmptyData,a=[],l=this.alloptions.yaxis.format?d3.format(this.alloptions.yaxis.format):function(t){return t};if(o===TRIGGER_AXIS)t.x&&a.push("<b>".concat(t.x.toString(),"</b>")),t.y&&t.y.forEach&&t.y.forEach((function(t,e){return!(n&&t.__isNull)&&a.push(_creatToolTipSerieRow({serie:s[e],value:t.value,format:l}))}));else{var h=Array.isArray(t.y)?t.y[e]:t.y;n&&h.__isNull||a.push(_creatToolTipSerieRow({serie:s[e],value:h.value&&h.value.toString()||0,key:t.x.toString(),format:l}))}return r+="".concat(a.join(""),"</div>")}function _doubelLineChartFormatter(t,e,i){var o='<div class="dchart-tooltip">',r=this.alloptions,s=r.series,n=r.series2,a=[],l=(this.data()||[]).length;return this.options.trigger===TRIGGER_AXIS?(t.x&&a.push("<b>".concat(t.x.toString(),"</b>")),t.y&&t.y.forEach((function(t,e){return a.push(_creatToolTipSerieRow({color:s[e]&&s[e].line.color,value:t}))})),t.z&&t.z.forEach((function(t,e){return a.push(_creatToolTipSerieRow({color:n[e]&&n[e].line.color,value:t}))}))):a.push(_creatToolTipSerieRow({color:(i/l>=1?s:n)[0].point.color,value:i/l>=1?t.y&&t.y.toString()||0:t.z&&t.z.toString()||0,key:t.x.toString()})),o+="".concat(a.join(""),"</div>")}function _pieChartFormatter(t,e,i){var o='<div class="dchart-tooltip">',r=this.alloptions,s=r.series,n=r.label,a=this._data.map((function(t){return t.y})).reduce((function(t,e){return t+e}),0),l=(t.y/a*100).toFixed(n.account.decimal)+"%";return t.y&&(o+=_creatToolTipSerieRow({color:s[e].color.value,key:t.x,value:"".concat(t.y," (").concat(l,")")})),o}function _xyzAxisChartFormatter(t,e,i){var o='<div class="dchart-tooltip">',r=this.alloptions.series,s=this._data.length,n=[];t.x&&n.push("<b>".concat(t.x.toString(),"</b>"));var a=this.options.trigger===TRIGGER_AXIS,l=d3.format(this.alloptions.yaxis.format),h=d3.format(this.alloptions.zaxis.format);return(a||i/s<1)&&t.y&&(t.y=[].concat(t.y))&&t.y.forEach((function(t,e){return n.push(_creatToolTipSerieRow({serie:r[e]&&r[e].bar,value:t.value,format:l}))})),(a||i/s>1)&&t.z&&t.z.forEach&&t.z.forEach((function(t,e){return n.push(_creatToolTipSerieRow({serie:r[e]&&r[e].line,value:t.value,format:h}))})),o+="".concat(n.join(""),"</div>")}function _horiBarFormatter(t,e,i,o){var r=this.options.trigger,s='<div class="dchart-tooltip">',n=this.alloptions.series,a=[],l=this.alloptions.xaxis.format?d3.format(this.alloptions.xaxis.format):function(t){return t};if(r===TRIGGER_AXIS)t.x&&a.push("<b>".concat(t.x.toString(),"</b>")),t.y&&t.y.forEach&&t.y.forEach((function(t,e){return(0===t||t)&&a.push(_creatToolTipSerieRow({format:l,serie:n[e],value:t.value}))}));else{var h=Array.isArray(t.y)?t.y[e]:t.y,c=+o.select("rect").attr("order");a.push(_creatToolTipSerieRow({format:l,serie:n[c],value:h.value&&h.value.toString()||0,key:t.x.toString()}))}return s+="".concat(a.join(""),"</div>")}function clearListenersOnSelector(t){t&&t.on&&t.on("mouseover",(function(){})).on("mousemove",(function(){})).on("mouseleave",(function(){})).on("click",(function(){})).on("mouseout",(function(){})).on("dblclick",(function(){}))}function getLeft(t,e){return t.getBBox().width-(e.options.net?e.options.innerWidth:0)}Tooltip=Com.extend(Tooltip,{init:function(t,e,i){return!(!t&&!this.el)&&(t&&(this.el=d3.select(t)),this.options=_.deepMerge(this.options,e),this.alloptions=i||this.alloptions,this)},_valid:function(){},renderSeries:function(){var t=this.options,e=this.alloptions;this.layer={};var i=this.el.select(".con-svg");this.layer.width=e.innerWidth,this.layer.height=e.innerHeight,this.layer.svgContainer=i,this.layer.x=this.comObj.getComs("axis","xaxis"),this.layer.y=this.comObj.getComs("axis","yaxis"),this.dispatch=d3.dispatch("elementMouseover","elementMouseout"),this.tooltip=this.el.select(".dc-tooltip")[0][0]?this.el.select(".dc-tooltip"):this.el.append("div").attr("class","dc-tooltip").style({display:"none",position:"absolute",color:t.color,background:t.backgroundColor,padding:t.padding+"px","border-radius":"5%"});var o=this;this.tooltip.on("mouseenter",(function(){o.options.enterFocus&&clearTimeout(o._hideTimeout)})).on("mouseout",(function(){o.options.trigger&&(clearTimeout(this._hideTimeout),o.hide(o.options.hideDelay))})),this.initGuildLayer()},show:function(){clearTimeout(this._hideTimeout),this.options.trigger===TRIGGER_AXIS&&this.isAxisChart()?this.showAxis.apply(this,arguments):this.showItem.apply(this,arguments)},showItem:function(t,e,i,o,r,s){"function"==typeof i&&(t=i.call(this,t,o,r,s));var n=this.defaultFormatter(t),a=this.options.formatter;"string"==typeof a?n=_defaultFormatterMap[a]&&_defaultFormatterMap[a].call(this,t,o,r,s):"function"==typeof a&&(n=a(t,o,r,s)),this.tooltip.html(n),this.tooltip.transition().duration(20).style("display","block");var l=d3.event||window.event,h=this.getTipPosition(l);this.tooltip.style("left",+h.x+"px").style("top",+h.y+"px")},showAxis:function(t,e,i){"function"==typeof i&&(t=i.call(this,t));var o=this.defaultFormatter(t),r=this.options.formatter;"string"==typeof r?o=_defaultFormatterMap[r]&&_defaultFormatterMap[r].call(this,t):"function"==typeof r&&(o=r(t));var s,n,a,l,h,c=d3.mouse(e[0][0]),u=this.alloptions,d=this.isVertical();d?(s=this.layer.x.getX(),n=u.xaxis.key,a=u.xaxis.type,l=this.layer.y,h=u.yaxis.orient):(s=this.layer.y.getX(),n=u.yaxis.key,a=u.yaxis.type,l=this.layer.x,h=u.xaxis.orient);var p=l.el[0][0],f=0;if(d){var y=t[n];if("time"===a)y=s(d3.time.format(u.xaxis.format).parse(t[n]));else y=s(t[n]);f=y+ +u.margin.left+(u.margin.containLabel&&"left"===h?getLeft(p,l):0)}else f=c[0]+u.margin.left;var m=d&&c[1]+u.margin.top||s("time"===a&&new Date(t[n])||t[n])+u.margin.top+(u.margin.containLabel&&"top"===h?p.getBBox().height:0);this.tooltip.html(o),this.tooltip.transition().duration(20).style("display","block");var g=this.options,x=this.getTipPositionAxis({left:f+(d&&s.rangeBand&&s.rangeBand()/2||0)+2*+g.xOffset,top:m+(d?0:s.rangeBand&&s.rangeBand()/2||0)+ +g.yOffset});this.tooltip.style("left",x.left+"px").style("top",x.top+"px")},getBoxSize:function(){var t=150,e=50;if(this.options.autoSize){var i=this.tooltip&&this.tooltip.node();i&&(t=i.offsetWidth||t,e=i.offsetHeight||e)}else t=this.options.width,e=this.options.height;return{boxWidth:t,boxHeight:e}},getTipPositionAxis:function(t){var e=t.left,i=t.top,o=document.body,r=o.offsetWidth,s=o.offsetHeight,n=this.el.node().parentElement.parentElement,a=n.offsetLeft,l=n.offsetTop,h=this.getBoxSize(),c=h.boxWidth,u=h.boxHeight;return a+e+c>r&&(e=Math.max(e-c,0)),l+i+u>s&&(i=Math.max(i-u)),{top:i,left:e}},getTipPosition:function(t){var e=this.options,i=e.xOffset,o=e.yOffset,r=t.offsetX,s=t.offsetY,n={x:r+i,y:s+o},a=document.body,l=a.offsetWidth,h=a.offsetHeight,c=this.getBoxSize(),u=c.boxWidth,d=c.boxHeight,p=this.el.node().parentElement.parentElement,f=p.offsetLeft,y=p.offsetTop;return f+r+u+i>l&&(n.x=Math.max(r-u,0)),y+s+d+o>h&&(n.y=Math.max(s-d)),n},hide:function(){this.options.enterFocus=!0,this.options.enterFocus?this._delayHide():this._contentHide()},_contentHide:function(){this.tooltip.style("display","none")},_delayHide:function(){var t=this;this.options.enterFocus&&(clearTimeout(this._hideTimeout),this._hideTimeout=setTimeout((function(){t._contentHide()}),this.options.hideDelay))},defaultFormatter:function(t){var e='<div class="dchart-tooltip">',i=0;return _.forIn(t,(function(t,o,r){e+=(0!==i?"<br>":"")+o+": "+(t=t||0).toString(),i++})),e+="</div>"},initGuildLayer:function(){var t=this.alloptions;this.wrap=this.el.select(".guildLayer")[0][0]?this.el.select(".guildLayer"):this.el.select(".con-svg").append("g").attr({class:"guildLayer",transform:"translate("+t.margin.left+","+t.margin.top+")"});var e=this.wrap.select(".guildLineLayer")[0][0]?this.wrap.select(".guildLineLayer"):this.wrap.append("g").attr("class","guildLineLayer");e.style("pointer-events","none"),e.select(".guildLine")[0][0]?e.select(".guildLine"):e.append("g").attr("class","guildLine")},triggerAxis:function(){var t=this,e=this,i=(this.options,this.layer.width),o=this.layer.height,r=this.layer.y,s=this.layer.x,n=this.dispatch,a=this.alloptions.margin,l=this,h=this.alloptions,c=this.options.triggerMethod,u=this.layer.svgContainer,d=getTrans(this.el.select(".con-g").attr("transform"),this.el.select(".series").attr("transform")),p=d.transX;d.transY;u.on(AXIS_TRIGGER_METHOD_MAP[c]||"mousemove",(function(){if(e.isAxisChart()&&e.options.trigger===TRIGGER_AXIS){var t=d3.event,c=t.offsetX,u=t.offsetY,d=e.isVertical(),f=d&&s.getX()||r.getX(),y=d&&f.range()||_.clone(f.range()).reverse(),m=d&&f.domain()||_.clone(f.domain()).reverse();if(c-=a.left,u-=a.top,a.containLabel&&("top"===h.xaxis.orient&&(u-=s.options.__height),"left"===h.yaxis.orient&&(c-=p)),c+10<0||u+10<0||c-10>i||u-10>o)return n.elementMouseout({mouseX:c,mouseY:u}),void l.renderGuildLayer(null);l.renderGuildLayer(null);var g="function"==typeof f.rangeBands,x=void 0,v=d?c:u;if(g){var T=d3.bisect(y,v),b=f.rangeBand(),A=y.length;if(0===T)x=m[T];else if(T===A)x=m[T-1];else{var S=Math.abs(y[T]-v);Math.abs(v-y[T-1]-b)<S&&(T-=1),x=m[T]}}else x=f.invert(v);n.elementMouseover({mouseX:c,mouseY:u,pointValue:x})}})),u.on("mouseleave",(function(){"hover"===c&&(t.renderGuildLayer(null),t.hide())}))},hideGuidLine:function(){this.el.select(".guildLine").selectAll("line").attr("display","none")},renderGuildLayer:function(t){if(0!==t&&!t)return this.hideGuidLine(),!1;var e=getTrans(this.el.select(".con-g").attr("transform"),this.el.select(".series").attr("transform")),i=e.transX,o=e.transY;this.el.select(".guildLayer").attr("transform","translate(".concat(i,", ").concat(o,")"));var r=this.options.lineStyle,s=this.isVertical(),n=this.el.select(".guildLine").selectAll("line").data(null!=t?[t]:[],String);n.enter().append("line");var a=this.layer.y.options,l=this.alloptions;n.attr("display","block").attr("class","tooltip-guideline").attr("x1",(function(t){return s&&_.isNumber(t)?t:0})).attr("x2",(function(t){return s&&_.isNumber(t)?t:a.innerWidth})).attr("y1",(function(t){return s?a.innerHeight||l.innerHeight:t})).attr("y2",(function(t){return!s&&_.isNumber(t)?t:0})).attr("stroke",r.color).attr("stroke-width",r.width).attr("stroke-dasharray",STROKE_DASH_MAP[r._type]).style("cursor","pointer"),n.exit().remove()},isVertical:function(){var t=this.alloptions;return"time"===t.xaxis.type||"category"===t.xaxis.type||"time"!==t.yaxis.type&&"category"!==t.yaxis.type},isAxisChart:function(){var t=this.alloptions;return t&&t.xaxis&&t.yaxis},updateItem:function(t){var e=this,i=this.selector,o=this.selectorText,r=this.options.triggerMethod,s=this.layer.svgContainer.select(".con-g");if(i){clearListenersOnSelector(i);var n=this.options.beforeFormat;i.on(ITEM_TRIGGER_METHOD_MAP[r].show||"mouseover",(function(t,i,o){clearTimeout(e._hideTimeout),(t||void 0!==i||void 0!==o)&&e.show(t&&t.data||t,s,n,i,o,d3.select(this))})).on(ITEM_TRIGGER_METHOD_MAP[r].hide||"mouseout",(function(){clearTimeout(e._hideTimeout),e.hide()}))}if(o){clearListenersOnSelector(o);var a=this.options.beforeFormat;o.on(ITEM_TRIGGER_METHOD_MAP[r].show||"mouseover",(function(t,i,o){clearTimeout(e._hideTimeout),(t||void 0!==i||void 0!==o)&&e.show(t&&t.data||t,s,a,i,o,d3.select(this))})).on(ITEM_TRIGGER_METHOD_MAP[r].hide||"mouseout",(function(){clearTimeout(e._hideTimeout),e.hide()}))}},updateAxis:function(){this.triggerAxis();var t,e,i,o,r=this,s=this.alloptions,n=this.options,a=this.isVertical(),l=s.xaxis.key,h=s.yaxis.key,c=s.zaxis&&s.zaxis.key,u=null;a?(t=l,e=s.xaxis.type,i=this.comObj.getComs("axis","xaxis").getX(),u=this.comObj.getComs("axis","xaxis").getX(),o=s.xaxis.format):(t=h,e=s.yaxis.type,i=this.comObj.getComs("axis","yaxis").getX(),u=this.comObj.getComs("axis","xaxis").getX(),o=s.yaxis.format);var d=a?this.layer.width:this.layer.height,p=this.layer.svgContainer.select(".con-g"),f=r.data();this.dispatch.on("elementMouseover",(function(s){var a,y,m,g=0,x=(a=s,y=d,m=0,f.forEach((function(r,s){var n=r[t];"time"===e&&o&&(n=d3.time.format(o).parse(r[t])),diff=Math.abs(i(n)-i(a.pointValue)),u(r[t]),diff<y&&(y=diff,m=s,g=n)})),f[m]);if(r.show(x,p,n.beforeFormat||function(t){var e={};return e[l]=t[l],e[h]=t[h],c&&(e[c]=t[c]),e}),"line"===n.axisPointer){var v=i(g)+("category"===e?i.rangeBand()/2:0);r.renderGuildLayer(v)}})),this.dispatch.on("elementMouseout",(function(){r.hide()}))},updateEvent:function(t){var e=this.options,i=e.trigger;if(t&&"function"==typeof t){var o=t();o&&(this.selector=o,this.selectorText=d3.select(".series").selectAll(".series-group").selectAll(".serie-label-text"))}if(this.selector&&this.selector.style("cursor",e.show?"pointer":"default"),this.selectorText&&this.selectorText.style("cursor",e.show?"pointer":"default"),this.clearListeners(),this.renderGuildLayer(null),e.show){this.isAxisChart()&&i===TRIGGER_AXIS?this.updateAxis():this.updateItem(t);var r=this.el.select(".dc-tooltip");r.style({display:"none",position:"absolute",color:e.color,background:e.backgroundColor,padding:"".concat(e.padding,"px"),"border-radius":"5%","border-color":e.borderColor,"border-width":"".concat(e.borderWidth,"px"),"border-style":"solid","font-size":e.fontSize,"font-weight":e.fontWeight,"font-family":e.fontFamily,"pointer-events":"none"}),e.autoSize?(r[0]&&(r[0][0].style.height=""),r.style("white-space","nowrap"),r.style("width","fit-content")):r.style({width:"".concat(e.width,"px"),height:"".concat(e.height,"px"),"word-break":"break-all","white-space":"normal"})}},clearListeners:function(){clearListenersOnSelector(this.layer.svgContainer),this.selector&&clearListenersOnSelector(this.selector)},destroy:function(){this.clearListeners(),this.tooltip&&this.tooltip.remove()}}),module.exports=Tooltip;

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

"use strict";function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function _iterableToArrayLimit(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var r=[],n=!0,a=!1,o=void 0;try{for(var i,l=t[Symbol.iterator]();!(n=(i=l.next()).done)&&(r.push(i.value),!e||r.length!==e);n=!0);}catch(t){a=!0,o=t}finally{try{n||null==l.return||l.return()}finally{if(a)throw o}}return r}}function _arrayWithHoles(t){if(Array.isArray(t))return t}var _exports=module.exports,_=require("../util"),d3=require("d3"),SERIES_INDEX=_.SERIES_INDEX,AXIS_NAME=_.AXIS_NAME,HIGHLIGHT_ATTR_BACKUP=_.HIGHLIGHT_ATTR_BACKUP,interactionHandlerSelector=_.interactionHandlerSelector,otherAxisMap=_.otherAxisMap,TARGET_KEY=["x","y","z","s"],defaultHightStyle={stroke:"#f00"};function setTargetStyle(t,e){if(!t)return null;e||(e=defaultHightStyle);var r=d3.select(t),n=t.attributes;if(n&&n.style){var a=getStylesFromStr(n.style.value),o=r.attr(HIGHLIGHT_ATTR_BACKUP),i=o?JSON.parse(o):{};Object.keys(e).forEach((function(t){a.hasOwnProperty(t)&&!i.hasOwnProperty(t)?i[t]=a[t]:a.hasOwnProperty(t)||(i[t]=getDefaultStyle(t))})),r.attr(HIGHLIGHT_ATTR_BACKUP,JSON.stringify(i))}return r.style(e)}function recoverStyleFromBackUp(t){if(!t)return null;if(""===t.getAttribute(HIGHLIGHT_ATTR_BACKUP))return null;var e=JSON.parse(t.getAttribute(HIGHLIGHT_ATTR_BACKUP));e&&d3.select(t).attr(HIGHLIGHT_ATTR_BACKUP,null).style(e)}function getStylesFromStr(t){if(!t)return{};var e={};return"".concat(t).split(";").forEach((function(t){var r=_slicedToArray(t.split(":"),2),n=r[0],a=r[1];n="".concat(n).trim(),a="".concat(a).trim(),n&&(e[n]=a)})),e}function isItemDataEqualTargetData(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.targetData,r=t.item;if(!r||!r.__data__)return!1;var n=r.__data__,a=r.getAttribute(AXIS_NAME)||"y",o=r.getAttribute(SERIES_INDEX),i=_.clone(n)[a],l=Array.isArray(i)?i[o]:i,u=l&&l.data||{};return TARGET_KEY.every((function(t){return!e.hasOwnProperty(t)||e[t]===u[t]}))}function getDefaultStyle(t){return{opacity:1,fill:"none",stroke:"none","stroke-width":0}[t]||null}_exports.highlight=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.targetData,r=t.filter,n=t.options,a=void 0===n?{style:{},mode:"single"}:n;this._setCustomStyle({targetData:e,options:a,filter:r,execMethod:setTargetStyle})},_exports.cancelHighlight=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.targetData,r=t.filter,n=t.options,a=void 0===n?{style:{},mode:"single"}:n;if(e)return this._setCustomStyle({targetData:e,options:a,filter:r,execMethod:recoverStyleFromBackUp}),!0;this._cancelAllHighlight()},_exports._cancelAllHighlight=function(){var t=this.svg.selectAll(".".concat(interactionHandlerSelector));t&&t[0]&&t[0].forEach((function(t){return t&&recoverStyleFromBackUp(t)}))},_exports._setCustomStyle=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.targetData,r=t.filter,n=t.options,a=t.execMethod;if(!(e||r&&_.isFunction(r)))return null;var o=this.svg.selectAll(".".concat(interactionHandlerSelector)),i=[];if(e){var l="all"===n.mode?"filter":"find";i=o[0][l]((function(t){return isItemDataEqualTargetData({targetData:e,item:t})}))}else r&&_.isFunction(r)&&(i=o[0].filter((function(t){return r(t.__data__)})));i&&[].concat(i).forEach((function(t){return t&&a(t,n.style)}))};
"use strict";function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function _iterableToArrayLimit(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var r=[],n=!0,a=!1,o=void 0;try{for(var i,l=t[Symbol.iterator]();!(n=(i=l.next()).done)&&(r.push(i.value),!e||r.length!==e);n=!0);}catch(t){a=!0,o=t}finally{try{n||null==l.return||l.return()}finally{if(a)throw o}}return r}}function _arrayWithHoles(t){if(Array.isArray(t))return t}var _exports=module.exports,_=require("../util"),d3=require("d3"),SERIES_INDEX=_.SERIES_INDEX,AXIS_NAME=_.AXIS_NAME,HIGHLIGHT_ATTR_BACKUP=_.HIGHLIGHT_ATTR_BACKUP,interactionHandlerSelector=_.interactionHandlerSelector,otherAxisMap=_.otherAxisMap,TARGET_KEY=["x","y","z","s"],defaultHightStyle={stroke:"#f00"};function setTargetStyle(t,e){if(!t)return null;e||(e=defaultHightStyle);var r=d3.select(t),n=t.attributes;if(n&&n.style){var a=getStylesFromStr(n.style.value),o=r.attr(HIGHLIGHT_ATTR_BACKUP),i=o?JSON.parse(o):{};Object.keys(e).forEach((function(t){a.hasOwnProperty(t)&&!i.hasOwnProperty(t)?i[t]=a[t]:a.hasOwnProperty(t)||(i[t]=getDefaultStyle(t))})),r.attr(HIGHLIGHT_ATTR_BACKUP,JSON.stringify(i))}return r.style(e)}function recoverStyleFromBackUp(t){if(!t)return null;if(""===t.getAttribute(HIGHLIGHT_ATTR_BACKUP))return null;var e=JSON.parse(t.getAttribute(HIGHLIGHT_ATTR_BACKUP));e&&d3.select(t).attr(HIGHLIGHT_ATTR_BACKUP,null).style(e)}function getStylesFromStr(t){if(!t)return{};var e={};return"".concat(t).split(";").forEach((function(t){var r=_slicedToArray(t.split(":"),2),n=r[0],a=r[1];n="".concat(n).trim(),a="".concat(a).trim(),n&&(e[n]=a)})),e}function isItemDataEqualTargetData(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.targetData,r=t.item;if(!r||!r.__data__)return!1;var n=r.__data__,a=r.getAttribute(AXIS_NAME)||"y",o=r.getAttribute(SERIES_INDEX),i=_.clone(n)[a],l=Array.isArray(i)?i[o]:i,u=l&&l.data||{};return TARGET_KEY.every((function(t){return!e.hasOwnProperty(t)||e[t]===u[t]}))}function getDefaultStyle(t){return{opacity:1,fill:"none",stroke:"none","stroke-width":0}[t]||null}_exports.highlight=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.targetData,r=t.filter,n=t.options,a=void 0===n?{style:{},mode:"single"}:n;this._setCustomStyle({targetData:e,options:a,filter:r,execMethod:setTargetStyle})},_exports.cancelHighlight=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.targetData,r=t.filter,n=t.options,a=void 0===n?{style:{},mode:"single"}:n;if(e)return this._setCustomStyle({targetData:e,options:a,filter:r,execMethod:recoverStyleFromBackUp}),!0;this._cancelAllHighlight()},_exports._cancelAllHighlight=function(){var t=this.svg.selectAll(".".concat(interactionHandlerSelector));t&&t[0]&&t[0].forEach((function(t){return t&&recoverStyleFromBackUp(t)}))},_exports._setCustomStyle=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.targetData,r=t.filter,n=t.options,a=t.execMethod;if(!(e||r&&_.isFunction(r)))return null;var o=this.svg.selectAll(".".concat(interactionHandlerSelector)),i=[];if(e){var l="all"===n.mode?"filter":"find";i=o[0][l]((function(t){return isItemDataEqualTargetData({targetData:e,item:t})}))}else r&&_.isFunction(r)&&(i=o[0].filter((function(t){return r(t.__data__)})));i&&[].concat(i).forEach((function(t){return t&&a(t,n.style)}))};
{
"name": "dchart-core",
"version": "2.7.3",
"version": "2.7.5",
"description": "",

@@ -5,0 +5,0 @@ "scripts": {

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