dchart-core
Advanced tools
Comparing version 2.6.39 to 2.6.40
@@ -1,1 +0,1 @@ | ||
"use strict";function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var DataV=require("../datav"),d3=require("d3"),_=require("../util"),animationController=_.animationController,SERIES_INDEX=_.SERIES_INDEX,interactionHandlerSelector=_.interactionHandlerSelector;function BarMulti(e,t){var r={xaxis:{type:"category",orient:"bottom"},groupLabel:null,yaxis:{key:"y"},label:{show:!1,pos:"top",dx:"0",dy:"-0.26em",anchor:"middle",strokeWidth:0},series:[{label:{}},{label:{}}]};r=_.deepMerge(r,t),DataV.call(this,e,r)}BarMulti=DataV.extend(BarMulti,{data:function(e){if(!e)return this._data;var t=this.options.yaxis.key;e.forEach(function(e){_.isArray(e[t])||(e[t]=[e[t]]),e[t]=_.map(e[t],function(e){return"string"==typeof e&&(e=_.toNumber(e)),e||(e=0),e})}),this._data=e},trans:function(e){var t=this.options,r=[],i=t.yaxis.key,s=t.xaxis.key;return _.map(e[i],function(t){var l={};l[s]=e[s],l[i]=t,r.push(l)}),r},getSelector:function(){return this.svg.select(".series").selectAll(".series-group").selectAll(".serie-single")},afterRender:function(){var e=this.options,t=this.getComs("tooltip","tooltip");t&&t.update(this.data(),e.tooltip,e),t&&t.updateEvent(this.getSelector.bind(this)),e.tooltip&&!e.tooltip.show&&t&&t.clearListeners()},updateAfterRender:function(){BarMulti.prototype.afterRender.call(this)},renderSeries:function(){this.svg.classed("bar-chart-g",!0);var e,t,r=this.options,i=this,s=this.data(),l=r.xaxis.key,n=r.yaxis.key;e=this.getComs("axis","xaxis"),t=this.getComs("axis","yaxis");var a=e.getX(),o=t.getX(),u=_.maxBy(s,function(e){return e[n].length})[n].length,c=e.calGroupStep(r.groupLabel||u),d=this._getYValue,f=(r.tooltip&&this.getComs("tooltip","tooltip"),this.series.selectAll(".series-group").data(this._data,function(e){return e[l]}));this.enterSeries=f.enter().append("g").attr("class","series-group"),this.outerSeries=f.exit().remove();var h=f.selectAll(".serie-single").data(function(e){return i.trans(e)});h.exit().remove(),h.enter().append("g").attr("class","serie-single");var p=h.selectAll("rect.serie").data(function(e){return[e]});p.enter().append("rect").attr(_defineProperty({class:function(e,t){return interactionHandlerSelector+" serie serie"+(t+1)},x:function(e,t){var r=c(""+t)||c("0");return a(e[l])+r},y:o(t.getMin()),width:c.rangeBand(),height:0},SERIES_INDEX,function(e,t){return t})),p.exit().remove();var b=h.selectAll(".serie-label").data(function(e){return[e]});b.exit().remove(),b.enter().append("text").attr({class:function(e,t){return"serie-label serie"+(t+1)+"-label"},x:function(e,t){var r=c(""+t)||c("0");return a(e[l])+r+c.rangeBand()/2},y:function(e,r){return o(t.getMin())},dx:function(e,t){return r.series[t]&&r.series[t].label&&r.series[t].label.dx||r.label.dx||0},dy:function(e,t){return r.series[t]&&r.series[t].label&&r.series[t].label.dy||r.label.dy||0}}),this.series.selectAll(".series-group").each(function(e,s){!function(e,s,u){e.each(function(e,f){var h=d3.select(this),p=h.selectAll(".serie"),b=h.selectAll(".serie-label"),g=c(""+f)||c("0"),y={x:a(e[l])+g,y:o(d(e[n])),width:c.rangeBand(),height:o(t.getMin())-o(d(e[n]))},m={x:a(e[l])+g+c.rangeBand()/2,y:function(){var e=r.label.pos;return y.y+y.height*("top"===e?0:"center"===e?.5:1)},dx:r.series[f]&&r.series[f].label&&r.series[f].label.dx||r.label.dx||0,dy:r.series[f]&&r.series[f].label&&r.series[f].label.dy||r.label.dy||0};animationController({options:r,animationHandler:function(e){var t=e.duration,r=e.ease;e.delay,p.transition().duration(t).ease(r).attr(y),b.transition().duration(t).ease(r).attr(m)},notAnimationHandler:function(){p.attr(y),b.attr(m)},animationFromOriginHandler:function(){p.attr({y:o(0),height:0}),b.attr({y:o(0)})},index:f}),p.style({fill:function(){return r.series[f]&&r.series[f].color&&r.series[f].color.res||r.color&&r.color.res},stroke:function(){return r.series[f]&&r.series[f].frameColor&&r.series[f].frameColor.res||r.frameColor&&r.frameColor.res},"stroke-width":function(){return r.series[f]&&r.series[f].frameColorWidth||r.frameColorWidth}}),b.html(function(){var t=r.series[f]&&r.series[f].label&&r.series[f].label.format||r.label.format||null;if(t)return t.call(i,e,u);if(s&&s[n]&&s[n][f]){var l=s[n][f];return l.hasOwnProperty("value")?l.value:l}return""}).style({"text-anchor":function(){return r.series[f]&&r.series[f].label&&r.series[f].label.anchor||r.label.anchor||"middle"},display:function(){return(r.series[f]&&"boolean"==typeof r.series[f].show?r.series[f].show:"boolean"==typeof r.label.show&&r.label.show)?"block":"none"},"font-size":function(){return(r.series[f]&&r.series[f].label&&r.series[f].label.fontSize||r.label.fontSize||"10")+"px"},"font-weight":function(){return r.series[f]&&r.series[f].label&&r.series[f].label.fontWeight||r.label.fontWeight},fill:r.series[f]&&r.series[f].label&&r.series[f].label.color||r.label.color,stroke:r.label.strokeWidth&&r.series[f]&&r.series[f].label&&r.series[f].label.color||r.label.color||"#fff","stroke-width":r.label.strokeWidth})})}(d3.select(this).selectAll(".serie-single"),e,s)})},updateBeforeRender:function(){BarMulti.prototype.beforeRender.call(this)},beforeRender:function(){var e=this.options,t=this;this.dealColor(e,"color"),this.dealColor(e,"frameColor"),e.series&&e.series.length&&e.series.forEach(function(r,i){r.color&&t.dealColor(e,"series["+i+"].color"),r.frameColor&&t.dealColor(e,"series["+i+"].frameColor")})},updateSeries:function(){BarMulti.prototype.renderSeries.call(this)},_getYValue:function(e){return _.isObject(e)?+e.value:+e}}),module.exports=BarMulti; | ||
"use strict";function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var DataV=require("../datav"),d3=require("d3"),_=require("../util"),animationController=_.animationController,SERIES_INDEX=_.SERIES_INDEX,interactionHandlerSelector=_.interactionHandlerSelector;function BarMulti(e,t){var r={xaxis:{type:"category",orient:"bottom"},groupLabel:null,yaxis:{key:"y"},label:{show:!1,pos:"top",dx:"0",dy:"-0.26em",anchor:"middle",strokeWidth:0},series:[{label:{}},{label:{}}]};r=_.deepMerge(r,t),DataV.call(this,e,r)}BarMulti=DataV.extend(BarMulti,{data:function(e){if(!e)return this._data;var t=this.options.yaxis.key;e.forEach(function(e){_.isArray(e[t])||(e[t]=[e[t]]),e[t]=_.map(e[t],function(e){return"string"==typeof e&&(e=_.toNumber(e)),e||(e=0),e})}),this._data=e},trans:function(e){var t=this.options,r=[],i=t.yaxis.key,s=t.xaxis.key;return _.map(e[i],function(t){var l={};l[s]=e[s],l[i]=t,r.push(l)}),r},getSelector:function(){return this.svg.select(".series").selectAll(".series-group").selectAll(".serie-single")},afterRender:function(){var e=this.options,t=this.getComs("tooltip","tooltip");t&&t.update(this.data(),e.tooltip,e),t&&t.updateEvent(this.getSelector.bind(this)),e.tooltip&&!e.tooltip.show&&t&&t.clearListeners()},updateAfterRender:function(){BarMulti.prototype.afterRender.call(this)},renderSeries:function(){this.svg.classed("bar-chart-g",!0);var e,t,r=this.options,i=this,s=this.data(),l=r.xaxis.key,n=r.yaxis.key;e=this.getComs("axis","xaxis"),t=this.getComs("axis","yaxis");var a=e.getX(),o=t.getX(),u=_.maxBy(s,function(e){return e[n].length})[n].length,c=e.calGroupStep(r.groupLabel||u),d=this._getYValue,f=(r.tooltip&&this.getComs("tooltip","tooltip"),this.series.selectAll(".series-group").data(this._data,function(e){return e[l]}));this.enterSeries=f.enter().append("g").attr("class","series-group"),this.outerSeries=f.exit().remove();var h=f.selectAll(".serie-single").data(function(e){return i.trans(e)});h.exit().remove(),h.enter().append("g").attr("class","serie-single");var p=h.selectAll("rect.serie").data(function(e){return[e]});p.enter().append("rect").attr(_defineProperty({class:function(e,t){return interactionHandlerSelector+" serie serie"+(t+1)},x:function(e,t){var r=c(""+t)||c("0");return a(e[l])+r},y:o(t.getMin()),width:c.rangeBand(),height:0},SERIES_INDEX,function(e,t){return t})),p.exit().remove();var b=h.selectAll(".serie-label").data(function(e){return[e]});b.exit().remove(),b.enter().append("text").attr({class:function(e,t){return"serie-label serie"+(t+1)+"-label"},x:function(e,t){var r=c(""+t)||c("0");return a(e[l])+r+c.rangeBand()/2},y:function(e,r){return o(t.getMin())},dx:function(e,t){return r.series[t]&&r.series[t].label&&r.series[t].label.dx||r.label.dx||0},dy:function(e,t){return r.series[t]&&r.series[t].label&&r.series[t].label.dy||r.label.dy||0}}),this.series.selectAll(".series-group").each(function(e,s){!function(e,s,u){e.each(function(e,f){var h=d3.select(this),p=h.selectAll(".serie"),b=h.selectAll(".serie-label"),g=c(""+f)||c("0"),y={x:a(e[l])+g,y:o(d(e[n])),width:c.rangeBand(),height:o(t.getMin())-o(d(e[n]))},m={x:a(e[l])+g+c.rangeBand()/2,y:function(){var e=r.label.pos;return y.y+y.height*("top"===e?0:"center"===e?.5:1)},dx:r.series[f]&&r.series[f].label&&r.series[f].label.dx||r.label.dx||0,dy:r.series[f]&&r.series[f].label&&r.series[f].label.dy||r.label.dy||0};animationController({options:r,animationHandler:function(e){var t=e.duration,r=e.ease;e.delay;p.transition().duration(t).ease(r).attr(y),b.transition().duration(t).ease(r).attr(m)},notAnimationHandler:function(){p.attr(y),b.attr(m)},animationFromOriginHandler:function(){p.attr({y:o(0),height:0}),b.attr({y:o(0)})},index:f}),p.style({fill:function(){return r.series[f]&&r.series[f].color&&r.series[f].color.res||r.color&&r.color.res},stroke:function(){return r.series[f]&&r.series[f].frameColor&&r.series[f].frameColor.res||r.frameColor&&r.frameColor.res},"stroke-width":function(){return r.series[f]&&r.series[f].frameColorWidth||r.frameColorWidth}}),b.html(function(){var t=r.series[f]&&r.series[f].label&&r.series[f].label.format||r.label.format||null;if(t)return t.call(i,e,u);if(s&&s[n]&&s[n][f]){var l=s[n][f];return l.hasOwnProperty("value")?l.value:l}return""}).style({"text-anchor":function(){return r.series[f]&&r.series[f].label&&r.series[f].label.anchor||r.label.anchor||"middle"},display:function(){return(r.series[f]&&"boolean"==typeof r.series[f].show?r.series[f].show:"boolean"==typeof r.label.show&&r.label.show)?"block":"none"},"font-size":function(){return(r.series[f]&&r.series[f].label&&r.series[f].label.fontSize||r.label.fontSize||"10")+"px"},"font-weight":function(){return r.series[f]&&r.series[f].label&&r.series[f].label.fontWeight||r.label.fontWeight},fill:r.series[f]&&r.series[f].label&&r.series[f].label.color||r.label.color,stroke:r.label.strokeWidth&&r.series[f]&&r.series[f].label&&r.series[f].label.color||r.label.color||"#fff","stroke-width":r.label.strokeWidth})})}(d3.select(this).selectAll(".serie-single"),e,s)})},updateBeforeRender:function(){BarMulti.prototype.beforeRender.call(this)},beforeRender:function(){var e=this.options,t=this;this.dealColor(e,"color"),this.dealColor(e,"frameColor"),e.series&&e.series.length&&e.series.forEach(function(r,i){r.color&&t.dealColor(e,"series["+i+"].color"),r.frameColor&&t.dealColor(e,"series["+i+"].frameColor")})},updateSeries:function(){BarMulti.prototype.renderSeries.call(this)},_getYValue:function(e){return _.isObject(e)?+e.value:+e}}),module.exports=BarMulti; |
@@ -1,1 +0,1 @@ | ||
"use strict";function _defineProperty(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var DataV=require("./barHorizontal"),d3=require("d3"),_=require("../util"),animationController=_.animationController,SERIES_INDEX=_.SERIES_INDEX,interactionHandlerSelector=_.interactionHandlerSelector;function BarMultiHoriColumn(e,r){var t={xaxis:{orient:"bottom",key:"y",min:0},yaxis:{type:"category",key:"x"},label:{pos:"center",dy:"0"}};this.enterSerie=[],this.outerSerie=[],t=_.deepMerge(t,r),DataV.call(this,e,t)}BarMultiHoriColumn=DataV.extend(BarMultiHoriColumn,{renderSeries:function(){this.svg.classed("bar-chart-g",!0);var e,r,t=this.options,i=this.data(),s=this,a=t.xaxis.key,l=t.yaxis.key;e=this.getComs("axis","xaxis"),r=this.getComs("axis","yaxis");var n=e.getX(),o=r.getX(),u=(_.maxBy(i,function(e){return e[a].length})[a].length,this._getYValue),d=this.series.selectAll(".series-group").data(this._data,function(e){return e[l]});this.outerSeries=d.exit().remove(),this.enterSeries=d.enter().append("g").attr("class","series-group"),d.each(function(r,i){var d=d3.select(this);d.selectAll(".serie-text").remove();var c=d.append("g").attr("class","serie-text"),m=d.selectAll(".serie-single").data(s.trans(r)),h=m.enter().insert("g",":first-child").attr("class","serie serie-single");h.append("rect"),m.each(function(r,i){var s;d3.select(this).select("rect").attr((_defineProperty(s={class:"serie serie"+(i+1)+" "+interactionHandlerSelector},SERIES_INDEX,i),_defineProperty(s,"x",n(e.getMin())),_defineProperty(s,"y",o(r[l])),_defineProperty(s,"width",0),_defineProperty(s,"height",o.rangeBand()),s)),c.append("text").attr({class:"serie-label serie"+(i+1)+"-label",x:n(e.getMin()),y:o(r[l])+o.rangeBand()/2,dx:t.series[i]&&t.series[i].label&&t.series[i].label.dx||t.label.dx||0,dy:t.series[i]&&t.series[i].label&&t.series[i].label.dy||t.label.dy||0})}),function(e,r,i){e.each(function(e,d){var c=d3.select(this),m=c.selectAll(".serie"),h=d3.select(c.node().parentNode).select(".serie-label:nth-child("+(d+1)+")"),f=u(e[a]),b=Math.abs(n(0)-n(f)),x=0,y=0;f>=0?x=n(Math.max(r.maxSum,t.xaxis.min)):(r.minSum+=f,x=n(r.minSum)),t.xaxis.min>r.maxSum?(r.maxSum+=f,y=Math.abs(n(t.xaxis.min)-f)):(r.maxSum+=f,y=b);var g=o.rangeBand(),p={x:x,y:o(e[l]),width:y,height:g,class:interactionHandlerSelector+" serie serie"+(d+1)},S={x:function(){var e=t.label.pos;return"left"===e?f>=0&&n(r.maxSum)-b||n(r.minSum):"center"===e?f>=0&&n(r.maxSum)-b/2||n(r.minSum)+b/2:f>=0&&n(r.maxSum)||n(r.minSum)-b},y:o(e[l])+g/2,dx:t.series[d]&&t.series[d].label&&t.series[d].label.dx||t.label.dx||0,dy:t.series[d]&&t.series[d].label&&t.series[d].label.dy||t.label.dy||0};m.attr({__width:y,__x:x,order:d}),animationController({options:t,animationHandler:function(e){var r=e.duration,t=e.ease,i=e.delay;m.transition().duration(r).delay(i).ease(t).attr(p),h.transition().duration(r).delay(i).ease(t).attr(S)},notAnimationHandler:function(){m.attr(p),h.attr(S)},animationFromOriginHandler:function(){m.attr({x:0,y:o(0),width:0}),h.attr({x:0,y:o(0)})},index:d}),m.style({fill:function(){return t.series[d]&&t.series[d].color&&t.series[d].color.res||t.color&&t.color.res},stroke:function(){return t.series[d]&&t.series[d].frameColor&&t.series[d].frameColor.res||t.frameColor&&t.frameColor.res},"stroke-width":function(){return t.series[d]&&t.series[d].frameColorWidth||t.frameColorWidth}}),h.html(function(){var l=t.series[d]&&t.series[d].label&&t.series[d].label.format||t.label.format||null;if(l)return l.call(s,e,i);var n=r[a][d];return n.hasOwnProperty("value")?n.value:n}).style({"text-anchor":function(){return t.series[d]&&t.series[d].label&&t.series[d].label.anchor||t.label.anchor||"middle"},display:function(){return(t.series[d]&&"boolean"==typeof t.series[d].show?t.series[d].show:"boolean"==typeof t.label.show&&t.label.show)?"block":"none"},"font-size":function(){return(t.series[d]&&t.series[d].label&&t.series[d].label.fontSize||t.label.fontSize||"10")+"px"},"font-weight":function(){return t.series[d]&&t.series[d].label&&t.series[d].label.fontWeight||t.label.fontWeight},fill:function(){return t.series[d]&&t.series[d].label&&t.series[d].label.color||t.label.color},stroke:t.label.strokeWidth&&t.series[d]&&t.series[d].label&&t.series[d].label.color||t.label.color||"#fff","stroke-width":t.label.strokeWidth,"vertical-align":"middle","alignment-baseline":"middle","line-height":g,height:g})})}(m,r,i),s.enterSerie[i]=h,s.outerSerie[i]=m.exit().remove()})},updateSeries:function(){BarMultiHoriColumn.prototype.renderSeries.call(this)}}),module.exports=BarMultiHoriColumn; | ||
"use strict";function _defineProperty(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var DataV=require("./barHorizontal"),d3=require("d3"),_=require("../util"),animationController=_.animationController,SERIES_INDEX=_.SERIES_INDEX,interactionHandlerSelector=_.interactionHandlerSelector;function BarMultiHoriColumn(e,r){var t={xaxis:{orient:"bottom",key:"y",min:0},yaxis:{type:"category",key:"x"},label:{pos:"center",dy:"0"}};this.enterSerie=[],this.outerSerie=[],t=_.deepMerge(t,r),DataV.call(this,e,t)}BarMultiHoriColumn=DataV.extend(BarMultiHoriColumn,{renderSeries:function(){this.svg.classed("bar-chart-g",!0);var e,r,t=this.options,i=this.data(),s=this,a=t.xaxis.key,l=t.yaxis.key;e=this.getComs("axis","xaxis"),r=this.getComs("axis","yaxis");var n=e.getX(),o=r.getX(),u=(_.maxBy(i,function(e){return e[a].length})[a].length,this._getYValue),d=this.series.selectAll(".series-group").data(this._data,function(e){return e[l]});this.outerSeries=d.exit().remove(),this.enterSeries=d.enter().append("g").attr("class","series-group"),d.each(function(r,i){var d=d3.select(this);d.selectAll(".serie-text").remove();var c=d.append("g").attr("class","serie-text"),m=d.selectAll(".serie-single").data(s.trans(r)),h=m.enter().insert("g",":first-child").attr("class","serie serie-single");h.append("rect"),m.each(function(r,i){var s;d3.select(this).select("rect").attr((_defineProperty(s={class:"serie serie"+(i+1)+" "+interactionHandlerSelector},SERIES_INDEX,i),_defineProperty(s,"x",n(e.getMin())),_defineProperty(s,"y",o(r[l])),_defineProperty(s,"width",0),_defineProperty(s,"height",o.rangeBand()),s)),c.append("text").attr({class:"serie-label serie"+(i+1)+"-label",x:n(e.getMin()),y:o(r[l])+o.rangeBand()/2,dx:t.series[i]&&t.series[i].label&&t.series[i].label.dx||t.label.dx||0,dy:t.series[i]&&t.series[i].label&&t.series[i].label.dy||t.label.dy||0})}),function(e,r,i){e.each(function(e,d){var c=d3.select(this),m=c.selectAll(".serie"),h=d3.select(c.node().parentNode).select(".serie-label:nth-child("+(d+1)+")"),f=u(e[a]),b=Math.abs(n(0)-n(f)),x=0,y=0;f>=0?x=n(Math.max(r.maxSum,t.xaxis.min)):(r.minSum+=f,x=n(r.minSum)),t.xaxis.min>r.maxSum?(r.maxSum+=f,y=Math.abs(n(t.xaxis.min)-f)):(r.maxSum+=f,y=b);var g=o.rangeBand(),p={x:x,y:o(e[l]),width:y,height:g,class:interactionHandlerSelector+" serie serie"+(d+1)},S={x:function(){var e=t.label.pos;return"left"===e?f>=0&&n(r.maxSum)-b||n(r.minSum):"center"===e?f>=0&&n(r.maxSum)-b/2||n(r.minSum)+b/2:f>=0&&n(r.maxSum)||n(r.minSum)-b},y:o(e[l])+g/2,dx:t.series[d]&&t.series[d].label&&t.series[d].label.dx||t.label.dx||0,dy:t.series[d]&&t.series[d].label&&t.series[d].label.dy||t.label.dy||0};m.attr({__width:y,__x:x,order:d});animationController({options:t,animationHandler:function(e){var r=e.duration,t=e.ease,i=e.delay;m.transition().duration(r).delay(i).ease(t).attr(p),h.transition().duration(r).delay(i).ease(t).attr(S)},notAnimationHandler:function(){m.attr(p),h.attr(S)},animationFromOriginHandler:function(){m.attr({x:0,y:o(0),width:0}),h.attr({x:0,y:o(0)})},index:d}),m.style({fill:function(){return t.series[d]&&t.series[d].color&&t.series[d].color.res||t.color&&t.color.res},stroke:function(){return t.series[d]&&t.series[d].frameColor&&t.series[d].frameColor.res||t.frameColor&&t.frameColor.res},"stroke-width":function(){return t.series[d]&&t.series[d].frameColorWidth||t.frameColorWidth}}),h.html(function(){var l=t.series[d]&&t.series[d].label&&t.series[d].label.format||t.label.format||null;if(l)return l.call(s,e,i);var n=r[a][d];return n.hasOwnProperty("value")?n.value:n}).style({"text-anchor":function(){return t.series[d]&&t.series[d].label&&t.series[d].label.anchor||t.label.anchor||"middle"},display:function(){return(t.series[d]&&"boolean"==typeof t.series[d].show?t.series[d].show:"boolean"==typeof t.label.show&&t.label.show)?"block":"none"},"font-size":function(){return(t.series[d]&&t.series[d].label&&t.series[d].label.fontSize||t.label.fontSize||"10")+"px"},"font-weight":function(){return t.series[d]&&t.series[d].label&&t.series[d].label.fontWeight||t.label.fontWeight},fill:function(){return t.series[d]&&t.series[d].label&&t.series[d].label.color||t.label.color},stroke:t.label.strokeWidth&&t.series[d]&&t.series[d].label&&t.series[d].label.color||t.label.color||"#fff","stroke-width":t.label.strokeWidth,"vertical-align":"middle","alignment-baseline":"middle","line-height":g,height:g})})}(m,r,i),s.enterSerie[i]=h,s.outerSerie[i]=m.exit().remove()})},updateSeries:function(){BarMultiHoriColumn.prototype.renderSeries.call(this)}}),module.exports=BarMultiHoriColumn; |
@@ -1,1 +0,1 @@ | ||
"use strict";function _defineProperty(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var DataV=require("./bar"),d3=require("d3"),_=require("../util"),animationController=_.animationController,SERIES_INDEX=_.SERIES_INDEX,interactionHandlerSelector=_.interactionHandlerSelector;function BarMultiVerti(e,r){var t={xaxis:{type:"category",orient:"bottom"},groupLabel:null,yaxis:{},label:{show:!1,pos:"center",dx:"0",dy:".4em",anchor:"middle",strokeWidth:0},series:[{label:{}},{label:{}}]};t=_.deepMerge(t,r),DataV.call(this,e,t)}BarMultiVerti=DataV.extend(BarMultiVerti,{renderSeries:function(){var e,r,t=this.options,i=this,s=this.data(),a=t.xaxis.key,l=t.yaxis.key;this.svg.classed("bar-chart-g",!0),e=this.getComs("axis","xaxis"),r=this.getComs("axis","yaxis");var n=e.getX(),o=r.getX(),c=_.maxBy(s,function(e){return e[l].length})[l].length,u=this._getYValue,d=this.series.selectAll(".series-group").data(this._data,function(e){return e[a]});this.enterSeries=d.enter().append("g").attr("class","series-group"),this.outerSeries=d.exit().remove(),d.each(function(e,s){var c=d3.select(this).selectAll(".serie-single").data(i.trans(e)),d=c.enter().append("g").attr("class","serie serie-single");d.append("rect"),d.append("text"),c.each(function(e,i){var s=d3.select(this);s.select("rect").attr(_defineProperty({class:interactionHandlerSelector+" serie serie"+(i+1),x:n(e[a]),y:o(r.getMin()),width:n.rangeBand(),height:0},SERIES_INDEX,i)),s.select("text").attr({class:"serie-label serie"+(i+1)+"-label",x:n(e[a])+n.rangeBand()/2,y:o(r.getMin()),dx:t.series[i]&&t.series[i].label&&t.series[i].label.dx||t.label.dx||0,dy:t.series[i]&&t.series[i].label&&t.series[i].label.dy||t.label.dy||0})}),function(e,r,s){e.each(function(e,c){var d=d3.select(this),b=d.selectAll(".serie"),h=d.selectAll(".serie-label"),m=Math.abs(o(0)-o(u(e[l]))),f=0;u(e[l])>=0?(r.maxSum+=u(e[l]),f=o(r.maxSum)):(r.minSum+=u(e[l]),f=o(r.minSum)-m);var x=r.maxSum-u(e[l])<t.yaxis.min?Math.abs(o(t.yaxis.min)-o(u(e[l]))):m,y={x:n(e[a]),y:f,width:n.rangeBand(),height:x,class:interactionHandlerSelector+" serie serie"+(c+1)},g={x:n(e[a])+n.rangeBand()/2,y:function(){var i=t.label.pos;return"top"===i?u(e[l])>=0?o(r.maxSum):o(r.minSum)-m:"center"===i?u(e[l])>=0&&o(r.maxSum)+m/2||o(r.minSum)-m/2:u(e[l])>=0&&o(r.maxSum)+m||o(r.minSum)},dx:t.series[c]&&t.series[c].label&&t.series[c].label.dx||t.label.dx||0,dy:t.series[c]&&t.series[c].label&&t.series[c].label.dy||t.label.dy||0};b.attr({__y:f,__height:x}),animationController({options:t,animationHandler:function(e){var r=e.duration,t=e.ease,i=e.delay;b.transition().duration(r).delay(i).ease(t).attr(y),h.transition().duration(r).delay(i).ease(t).attr(g)},notAnimationHandler:function(){b.attr(y),h.attr(g)},animationFromOriginHandler:function(){b.attr({y:o(0),height:0}),h.attr({y:o(0)})},index:c}),b.style({fill:function(){return t.series[c]&&t.series[c].color&&t.series[c].color.res||t.color&&t.color.res},stroke:function(){return t.series[c]&&t.series[c].frameColor&&t.series[c].frameColor.res||t.frameColor&&t.frameColor.res},"stroke-width":function(){return t.series[c]&&t.series[c].frameColorWidth||t.frameColorWidth}}),h.html(function(){var r=t.series[c]&&t.series[c].label&&t.series[c].label.format||t.label.format||null;return r?r.call(i,e,s):u(e[l])}).style({"text-anchor":function(){return t.series[c]&&t.series[c].label&&t.series[c].label.anchor||t.label.anchor||"middle"},display:function(){return(t.series[c]&&"boolean"==typeof t.series[c].show?t.series[c].show:"boolean"==typeof t.label.show&&t.label.show)?"block":"none"},"font-size":function(){return(t.series[c]&&t.series[c].label&&t.series[c].label.fontSize||t.label.fontSize||"10")+"px"},"font-weight":function(){return t.series[c]&&t.series[c].label&&t.series[c].label.fontWeight||t.label.fontWeight},fill:function(){return t.series[c]&&t.series[c].label&&t.series[c].label.color||t.label.color},stroke:t.label.strokeWidth?t.series[c]&&t.series[c].label&&t.series[c].label.color||t.label.color:"#fff","stroke-width":t.label.strokeWidth||0})})}(c,e,s),i.outerSerie=c.exit().remove()}),d.selectAll(".serie.serie"+c+" ~ .serie").remove()},updateSeries:function(){BarMultiVerti.prototype.renderSeries.call(this)}}),module.exports=BarMultiVerti; | ||
"use strict";function _defineProperty(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var DataV=require("./bar"),d3=require("d3"),_=require("../util"),animationController=_.animationController,SERIES_INDEX=_.SERIES_INDEX,interactionHandlerSelector=_.interactionHandlerSelector;function BarMultiVerti(e,r){var t={xaxis:{type:"category",orient:"bottom"},groupLabel:null,yaxis:{},label:{show:!1,pos:"center",dx:"0",dy:".4em",anchor:"middle",strokeWidth:0},series:[{label:{}},{label:{}}]};t=_.deepMerge(t,r),DataV.call(this,e,t)}BarMultiVerti=DataV.extend(BarMultiVerti,{renderSeries:function(){var e,r,t=this.options,i=this,s=this.data(),a=t.xaxis.key,l=t.yaxis.key;this.svg.classed("bar-chart-g",!0),e=this.getComs("axis","xaxis"),r=this.getComs("axis","yaxis");var n=e.getX(),o=r.getX(),c=_.maxBy(s,function(e){return e[l].length})[l].length,u=this._getYValue,d=this.series.selectAll(".series-group").data(this._data,function(e){return e[a]});this.enterSeries=d.enter().append("g").attr("class","series-group"),this.outerSeries=d.exit().remove(),d.each(function(e,s){var c=d3.select(this).selectAll(".serie-single").data(i.trans(e)),d=c.enter().append("g").attr("class","serie serie-single");d.append("rect"),d.append("text"),c.each(function(e,i){var s=d3.select(this);s.select("rect").attr(_defineProperty({class:interactionHandlerSelector+" serie serie"+(i+1),x:n(e[a]),y:o(r.getMin()),width:n.rangeBand(),height:0},SERIES_INDEX,i)),s.select("text").attr({class:"serie-label serie"+(i+1)+"-label",x:n(e[a])+n.rangeBand()/2,y:o(r.getMin()),dx:t.series[i]&&t.series[i].label&&t.series[i].label.dx||t.label.dx||0,dy:t.series[i]&&t.series[i].label&&t.series[i].label.dy||t.label.dy||0})}),function(e,r,s){e.each(function(e,c){var d=d3.select(this),b=d.selectAll(".serie"),h=d.selectAll(".serie-label"),m=Math.abs(o(0)-o(u(e[l]))),f=0;u(e[l])>=0?(r.maxSum+=u(e[l]),f=o(r.maxSum)):(r.minSum+=u(e[l]),f=o(r.minSum)-m);var x=r.maxSum-u(e[l])<t.yaxis.min?Math.abs(o(t.yaxis.min)-o(u(e[l]))):m,y={x:n(e[a]),y:f,width:n.rangeBand(),height:x,class:interactionHandlerSelector+" serie serie"+(c+1)},g={x:n(e[a])+n.rangeBand()/2,y:function(){var i=t.label.pos;return"top"===i?u(e[l])>=0?o(r.maxSum):o(r.minSum)-m:"center"===i?u(e[l])>=0&&o(r.maxSum)+m/2||o(r.minSum)-m/2:u(e[l])>=0&&o(r.maxSum)+m||o(r.minSum)},dx:t.series[c]&&t.series[c].label&&t.series[c].label.dx||t.label.dx||0,dy:t.series[c]&&t.series[c].label&&t.series[c].label.dy||t.label.dy||0};b.attr({__y:f,__height:x});animationController({options:t,animationHandler:function(e){var r=e.duration,t=e.ease,i=e.delay;b.transition().duration(r).delay(i).ease(t).attr(y),h.transition().duration(r).delay(i).ease(t).attr(g)},notAnimationHandler:function(){b.attr(y),h.attr(g)},animationFromOriginHandler:function(){b.attr({y:o(0),height:0}),h.attr({y:o(0)})},index:c}),b.style({fill:function(){return t.series[c]&&t.series[c].color&&t.series[c].color.res||t.color&&t.color.res},stroke:function(){return t.series[c]&&t.series[c].frameColor&&t.series[c].frameColor.res||t.frameColor&&t.frameColor.res},"stroke-width":function(){return t.series[c]&&t.series[c].frameColorWidth||t.frameColorWidth}}),h.html(function(){var r=t.series[c]&&t.series[c].label&&t.series[c].label.format||t.label.format||null;return r?r.call(i,e,s):u(e[l])}).style({"text-anchor":function(){return t.series[c]&&t.series[c].label&&t.series[c].label.anchor||t.label.anchor||"middle"},display:function(){return(t.series[c]&&"boolean"==typeof t.series[c].show?t.series[c].show:"boolean"==typeof t.label.show&&t.label.show)?"block":"none"},"font-size":function(){return(t.series[c]&&t.series[c].label&&t.series[c].label.fontSize||t.label.fontSize||"10")+"px"},"font-weight":function(){return t.series[c]&&t.series[c].label&&t.series[c].label.fontWeight||t.label.fontWeight},fill:function(){return t.series[c]&&t.series[c].label&&t.series[c].label.color||t.label.color},stroke:t.label.strokeWidth?t.series[c]&&t.series[c].label&&t.series[c].label.color||t.label.color:"#fff","stroke-width":t.label.strokeWidth||0})})}(c,e,s),i.outerSerie=c.exit().remove()}),d.selectAll(".serie.serie"+c+" ~ .serie").remove()},updateSeries:function(){BarMultiVerti.prototype.renderSeries.call(this)}}),module.exports=BarMultiVerti; |
@@ -1,1 +0,1 @@ | ||
"use strict";function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(t,e){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;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(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=[];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}))});else{var l=Array.isArray(t.y)?t.y[e]:t.y;n&&l.__isNull||a.push(_creatToolTipSerieRow({serie:s[e],value:l.value&&l.value.toString()||0,key:t.x.toString()}))}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;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}))}),(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}))}),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=[];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({serie:n[e],value:t.value}))});else{var l=Array.isArray(t.y)?t.y[e]:t.y,h=+o.select("rect").attr("order");a.push(_creatToolTipSerieRow({serie:n[h],value:l.value&&l.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 g=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 m=this.options,x=this.getTipPositionAxis({left:f+(d&&s.rangeBand&&s.rangeBand()/2||0)+2*+m.xOffset,top:g+(d?0:s.rangeBand&&s.rangeBand()/2||0)+ +m.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=10,d=this.layer.svgContainer,p=getTrans(this.el.select(".con-g").attr("transform"),this.el.select(".series").attr("transform")),f=p.transX;p.transY;d.on(AXIS_TRIGGER_METHOD_MAP[c]||"mousemove",function(){if(e.isAxisChart()&&e.options.trigger===TRIGGER_AXIS){var t=d3.event,c=t.offsetX,d=t.offsetY,p=e.isVertical(),y=p&&s.getX()||r.getX(),g=p&&y.range()||_.clone(y.range()).reverse(),m=p&&y.domain()||_.clone(y.domain()).reverse();if(c-=a.left,d-=a.top,a.containLabel&&("top"===h.xaxis.orient&&(d-=s.options.__height),"left"===h.yaxis.orient&&(c-=f)),c+u<0||d+u<0||c-u>i||d-u>o)return n.elementMouseout({mouseX:c,mouseY:d}),void l.renderGuildLayer(null);l.renderGuildLayer(null);var x="function"==typeof y.rangeBands,v=void 0,T=p?c:d;if(x){var b=d3.bisect(g,T),S=y.rangeBand(),w=g.length;if(0===b)v=m[b];else if(b===w)v=m[b-1];else{var A=Math.abs(g[b]-T),L=Math.abs(T-g[b-1]-S);L<A&&(b-=1),v=m[b]}}else v=y.invert(T);n.elementMouseover({mouseX:c,mouseY:d,pointValue:v})}}),d.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.options.triggerMethod,r=this.layer.svgContainer.select(".con-g");if(i){clearListenersOnSelector(i);var s=this.options.beforeFormat;i.on(ITEM_TRIGGER_METHOD_MAP[o].show||"mouseover",function(t,i,o){clearTimeout(e._hideTimeout),(t||void 0!==i||void 0!==o)&&e.show(t&&t.data||t,r,s,i,o,d3.select(this))}).on(ITEM_TRIGGER_METHOD_MAP[o].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,g,m=0,x=(a=s,y=d,g=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,g=s,m=n)}),f[g]);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(m)+("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)}if(this.selector&&this.selector.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)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(t,e){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=[];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({serie:n[e],value:t.value}))});else{var l=Array.isArray(t.y)?t.y[e]:t.y,h=+o.select("rect").attr("order");a.push(_creatToolTipSerieRow({serie:n[h],value:l.value&&l.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 g=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 m=this.options,x=this.getTipPositionAxis({left:f+(d&&s.rangeBand&&s.rangeBand()/2||0)+2*+m.xOffset,top:g+(d?0:s.rangeBand&&s.rangeBand()/2||0)+ +m.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=10,d=this.layer.svgContainer,p=getTrans(this.el.select(".con-g").attr("transform"),this.el.select(".series").attr("transform")),f=p.transX;p.transY;d.on(AXIS_TRIGGER_METHOD_MAP[c]||"mousemove",function(){if(e.isAxisChart()&&e.options.trigger===TRIGGER_AXIS){var t=d3.event,c=t.offsetX,d=t.offsetY,p=e.isVertical(),y=p&&s.getX()||r.getX(),g=p&&y.range()||_.clone(y.range()).reverse(),m=p&&y.domain()||_.clone(y.domain()).reverse();if(c-=a.left,d-=a.top,a.containLabel&&("top"===h.xaxis.orient&&(d-=s.options.__height),"left"===h.yaxis.orient&&(c-=f)),c+u<0||d+u<0||c-u>i||d-u>o)return n.elementMouseout({mouseX:c,mouseY:d}),void l.renderGuildLayer(null);l.renderGuildLayer(null);var x="function"==typeof y.rangeBands,v=void 0,T=p?c:d;if(x){var b=d3.bisect(g,T),S=y.rangeBand(),w=g.length;if(0===b)v=m[b];else if(b===w)v=m[b-1];else{var A=Math.abs(g[b]-T);Math.abs(T-g[b-1]-S)<A&&(b-=1),v=m[b]}}else v=y.invert(T);n.elementMouseover({mouseX:c,mouseY:d,pointValue:v})}}),d.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.options.triggerMethod,r=this.layer.svgContainer.select(".con-g");if(i){clearListenersOnSelector(i);var s=this.options.beforeFormat;i.on(ITEM_TRIGGER_METHOD_MAP[o].show||"mouseover",function(t,i,o){clearTimeout(e._hideTimeout),(t||void 0!==i||void 0!==o)&&e.show(t&&t.data||t,r,s,i,o,d3.select(this))}).on(ITEM_TRIGGER_METHOD_MAP[o].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,g,m=0,x=(a=s,y=d,g=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,g=s,m=n)}),f[g]);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(m)+("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)}if(this.selector&&this.selector.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; |
{ | ||
"name": "dchart-core", | ||
"version": "2.6.39", | ||
"version": "2.6.40", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -1,1 +0,1 @@ | ||
"use strict";function _defineProperty(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var DataV=require("../datav"),d3=require("d3"),_=require("../util"),SERIES_INDEX=_.SERIES_INDEX,interactionHandlerSelector=_.interactionHandlerSelector;function Pie(t,e){var r={arc:{startAngle:function(t){return t.startAngle},endAngle:function(t){return t.endAngle},net:!1,netColor:"#aaa"},pyaxis:{key:"y"},color:"#fff",paxis:null,defaultColor:"#1F6086",colors:[]};r=_.deepMerge(r,e),DataV.call(this,t,r)}Pie=DataV.extend(Pie,{data:function(t){null!=t&&(this._data=t);var e=this.options.pyaxis.key;return this._data.forEach(function(t){var r=t[e];r.value=_.toNumber(r.value)}),this._data},beforeRender:function(){var t=this.options;t.arc.radius?t.arc._radius=t.arc.radius:t.arc._radius=Math.min(t.innerHeight,t.innerWidth)/2;var e=this;this.dealColor(t,"defaultColor"),t.colors&&t.colors.length&&t.colors.forEach(function(r,a){e.dealColor(t.colors,"["+a+"]")})},updateBeforeRender:function(){Pie.prototype.beforeRender.call(this)},changeSeries:function(){var t=this,e=this.options,r=this.data(),a=_.sum(r.map(function(t){return t.y.hasOwnProperty("value")?t.y.value:t.y})),i=d3.layout.pie().sort(null).value(function(t){if(!a)return 1;var r=t[e.pyaxis.key];return _.isObject(r)&&r.hasOwnProperty("value")&&(r=r.value),"string"==typeof r?_.toNumber(r):r||0}),n=this.getComs("arc","arc").getArc(),s=this._pieData=i(r);s.forEach(function(t){return Object.assign(t,t.data)});var l=this.pies.attr("transform","translate("+e.innerWidth/2+","+e.innerHeight/2+")").selectAll(".serie").data(s),o=this.labels.attr("transform","translate("+e.innerWidth/2+","+e.innerHeight/2+")").selectAll(".serie-label").data(s),c=function(t){if(!e.paxis._dr)return"translate("+n.centroid(t)+")";var r=e.paxis._dr,a=(t.startAngle+t.endAngle)/2;return"translate("+r*Math.sin(a)+", "+-r*Math.cos(a)+")"},u=function(t,r){return"function"==typeof e.paxis.label?e.paxis.label.call(t,t.data,r):e.paxis.label&&e.paxis.label.length?e.paxis.label[r]:t.data[e.paxis.key]};l.enter().append("path").attr(_defineProperty({class:interactionHandlerSelector+" serie serie1"},SERIES_INDEX,function(t,e){return e})),o.enter().append("text").attr({class:"serie-label",dy:".35em"}).style("text-anchor","middle");var d=function(){t.pies.selectAll(".serie").each(function(t,r){var a=d3.select(this);(function(t,r){var a=e.isFirst,i=e.animationAfterPreviousSeries,s=e.animationDuration,l=e.animationDurationUpdate,o=e.animationEasing;e.animation?this.transition().duration(e.isFirst?s:l).ease(o).delay(i?l*r:0).attrTween("d",function(){this._cur=this._cur||t;var i=d3.interpolate(getAnimationStartInfo(a,e,this._cur,t),t);return this._cur=t,function(t){return n(i(t),r)}}):this.attr({d:n(t,r)}),this.style({fill:e.colors[r]&&e.colors[r].res||e.defaultColor.res||"#fff"})}).call(a,t,r)}),t.labels.selectAll(".serie-label").each(function(t,r){var a=d3.select(this);(function(t,r){var a=e.isFirst,i=e.animationDuration,n=e.animationEasing,s=e.animationDurationUpdate,l=e.animationAfterPreviousSeries;e.animation?e.paxis&&(this.attr("transform",c.bind(null,t)).html(u.bind(null,t,r)),this.html(u.bind(null,t,r)).transition().duration(a?i:s).ease(n).delay(l?s*r:0).attrTween("transform",function(){this._cur=this._cur||t;var r=d3.interpolate(getAnimationStartInfo(a,e,this._cur,t),t);return this._cur=t,function(t){return c(r(t))}})):e.paxis&&this.attr("transform",c.bind(null,t)).html(u.bind(null,t,r))}).call(a,t,r)})};d(),this.addResumeTween(d),l.exit().remove(),o.exit().remove();var h=this.svg.select(".net-g");if(e.arc.net){h[0][0]||(h=this.svg.insert("g",".series").attr("class","net-g"));var f=this._calNet(e.arc._radius),p=h.style("display","block").attr("transform","translate("+e.innerWidth/2+","+e.innerHeight/2+")").selectAll(".net-path").data(f);p.enter().append("circle").attr({class:"net-path",cx:0,cy:0}),p.exit().remove(),p.attr({r:function(t){return t}}).style({stroke:e.arc.netColor,fill:"none","stroke-dasharray":"4 4"})}else h[0][0]&&h.style("display","none")},_calNet:function(t){return _.isNumber(t)?[t/4,t/2,t/4*3,t]:[]},renderSeries:function(){this.svg.classed("pie-chart-g",!0);var t=this.options;this.renderCom("arc","arc",this.svg[0][0],t.arc).getArc();this.pies=this.series.append("g").attr("class","series-pies"),this.labels=this.series.append("g").attr("class","series-labels"),this.labels.style("pointer-events","none"),this.changeSeries()},updateSeries:function(){var t=this.options,e=this.data();this.getComs("arc","arc").update(e,t.arc),this.changeSeries()},getSelector:function(){return this.svg.select(".series").selectAll(".serie")},afterRender:function(){var t=this.options,e=this.getComs("tooltip","tooltip");e&&e.update(this.data(),t.tooltip,t),e&&e.updateEvent(this.getSelector.bind(this)),t.tooltip&&!t.tooltip.show&&e&&e.clearListeners()},updateAfterRender:function(){Pie.prototype.afterRender.call(this)}});var getAnimationStartInfo=function(t,e,r,a){var i=e.animationAllFromZero,n=e.animationUpdateFromPrevious,s={startAngle:0,endAngle:0},l={startAngle:a.startAngle,endAngle:a.startAngle};return t?i?s:l:n?r:i?s:l};module.exports=Pie; | ||
"use strict";function _defineProperty(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var DataV=require("../datav"),d3=require("d3"),_=require("../util"),SERIES_INDEX=_.SERIES_INDEX,interactionHandlerSelector=_.interactionHandlerSelector;function Pie(t,e){var r={arc:{startAngle:function(t){return t.startAngle},endAngle:function(t){return t.endAngle},net:!1,netColor:"#aaa"},pyaxis:{key:"y"},color:"#fff",paxis:null,defaultColor:"#1F6086",colors:[]};r=_.deepMerge(r,e),DataV.call(this,t,r)}Pie=DataV.extend(Pie,{data:function(t){null!=t&&(this._data=t);var e=this.options.pyaxis.key;return this._data.forEach(function(t){var r=t[e];r.value=_.toNumber(r.value)}),this._data},beforeRender:function(){var t=this.options;t.arc.radius?t.arc._radius=t.arc.radius:t.arc._radius=Math.min(t.innerHeight,t.innerWidth)/2;var e=this;this.dealColor(t,"defaultColor"),t.colors&&t.colors.length&&t.colors.forEach(function(r,a){e.dealColor(t.colors,"["+a+"]")})},updateBeforeRender:function(){Pie.prototype.beforeRender.call(this)},changeSeries:function(){var t=this,e=this.options,r=this.data(),a=_.sum(r.map(function(t){return t.y.hasOwnProperty("value")?t.y.value:t.y})),i=d3.layout.pie().sort(null).value(function(t){if(!a)return 1;var r=t[e.pyaxis.key];return _.isObject(r)&&r.hasOwnProperty("value")&&(r=r.value),"string"==typeof r?_.toNumber(r):r||0}),n=this.getComs("arc","arc").getArc(),s=this._pieData=i(r);s.forEach(function(t){return Object.assign(t,t.data)});var l=this.pies.attr("transform","translate("+e.innerWidth/2+","+e.innerHeight/2+")").selectAll(".serie").data(s),o=this.labels.attr("transform","translate("+e.innerWidth/2+","+e.innerHeight/2+")").selectAll(".serie-label").data(s),c=function(t){if(!e.paxis._dr)return"translate("+n.centroid(t)+")";var r=e.paxis._dr,a=(t.startAngle+t.endAngle)/2;return"translate("+r*Math.sin(a)+", "+-r*Math.cos(a)+")"},u=function(t,r){return"function"==typeof e.paxis.label?e.paxis.label.call(t,t.data,r):e.paxis.label&&e.paxis.label.length?e.paxis.label[r]:t.data[e.paxis.key]},d=function(t,r){var a=e.isFirst,i=e.animationAfterPreviousSeries,s=e.animationDuration,l=e.animationDurationUpdate,o=e.animationEasing;e.animation?this.transition().duration(e.isFirst?s:l).ease(o).delay(i?l*r:0).attrTween("d",function(){this._cur=this._cur||t;var i=d3.interpolate(getAnimationStartInfo(a,e,this._cur,t),t);return this._cur=t,function(t){return n(i(t),r)}}):this.attr({d:n(t,r)}),this.style({fill:e.colors[r]&&e.colors[r].res||e.defaultColor.res||"#fff"})},h=function(t,r){var a=e.isFirst,i=e.animationDuration,n=e.animationEasing,s=e.animationDurationUpdate,l=e.animationAfterPreviousSeries;e.animation?e.paxis&&(this.attr("transform",c.bind(null,t)).html(u.bind(null,t,r)),this.html(u.bind(null,t,r)).transition().duration(a?i:s).ease(n).delay(l?s*r:0).attrTween("transform",function(){this._cur=this._cur||t;var r=d3.interpolate(getAnimationStartInfo(a,e,this._cur,t),t);return this._cur=t,function(t){return c(r(t))}})):e.paxis&&this.attr("transform",c.bind(null,t)).html(u.bind(null,t,r))};l.enter().append("path").attr(_defineProperty({class:interactionHandlerSelector+" serie serie1"},SERIES_INDEX,function(t,e){return e})),o.enter().append("text").attr({class:"serie-label",dy:".35em"}).style("text-anchor","middle");var f=function(){t.pies.selectAll(".serie").each(function(t,e){var r=d3.select(this);d.call(r,t,e)}),t.labels.selectAll(".serie-label").each(function(t,e){var r=d3.select(this);h.call(r,t,e)})};f(),this.addResumeTween(f),l.exit().remove(),o.exit().remove();var p=this.svg.select(".net-g");if(e.arc.net){p[0][0]||(p=this.svg.insert("g",".series").attr("class","net-g"));var g=this._calNet(e.arc._radius),v=p.style("display","block").attr("transform","translate("+e.innerWidth/2+","+e.innerHeight/2+")").selectAll(".net-path").data(g);v.enter().append("circle").attr({class:"net-path",cx:0,cy:0}),v.exit().remove(),v.attr({r:function(t){return t}}).style({stroke:e.arc.netColor,fill:"none","stroke-dasharray":"4 4"})}else p[0][0]&&p.style("display","none")},_calNet:function(t){return _.isNumber(t)?[t/4,t/2,t/4*3,t]:[]},renderSeries:function(){this.svg.classed("pie-chart-g",!0);var t=this.options;this.renderCom("arc","arc",this.svg[0][0],t.arc).getArc();this.pies=this.series.append("g").attr("class","series-pies"),this.labels=this.series.append("g").attr("class","series-labels"),this.labels.style("pointer-events","none"),this.changeSeries()},updateSeries:function(){var t=this.options,e=this.data();this.getComs("arc","arc").update(e,t.arc),this.changeSeries()},getSelector:function(){return this.svg.select(".series").selectAll(".serie")},afterRender:function(){var t=this.options,e=this.getComs("tooltip","tooltip");e&&e.update(this.data(),t.tooltip,t),e&&e.updateEvent(this.getSelector.bind(this)),t.tooltip&&!t.tooltip.show&&e&&e.clearListeners()},updateAfterRender:function(){Pie.prototype.afterRender.call(this)}});var getAnimationStartInfo=function(t,e,r,a){var i=e.animationAllFromZero,n=e.animationUpdateFromPrevious,s={startAngle:0,endAngle:0},l={startAngle:a.startAngle,endAngle:a.startAngle};return t?i?s:l:n?r:i?s:l};module.exports=Pie; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
150165