diff --git a/dist/dimple.v1.js b/dist/dimple.v1.js index b2154f1..7eb84a6 100644 --- a/dist/dimple.v1.js +++ b/dist/dimple.v1.js @@ -2138,6 +2138,7 @@ dimple.plot.bar = { var height = parseFloat(selectedShape.attr("height")); var opacity = selectedShape.attr("opacity"); var fill = selectedShape.attr("fill"); + var dropDest = series._dropLineOrigin(); // Fade the popup stroke mixing the shape fill with 60% white var popupStrokeColor = d3.rgb( @@ -2158,12 +2159,12 @@ dimple.plot.bar = { .attr("class", "hoverShapes"); // Add a drop line to the x axis - if (!series.x._hasCategories()) { + if (!series.x._hasCategories() && dropDest.y !== null) { g.append("line") - .attr("x1", (x < series.x._origin ? x : x + width ) - 1) - .attr("y1", (y < series.y._origin ? y + height : y )) - .attr("x2", (x < series.x._origin ? x : x + width ) - 1) - .attr("y2", (y < series.y._origin ? y + height : y )) + .attr("x1", (x < series.x._origin ? x + 1 : x + width - 1)) + .attr("y1", (y < dropDest.y ? y + height : y )) + .attr("x2", (x < series.x._origin ? x + 1 : x + width - 1)) + .attr("y2", (y < dropDest.y ? y + height : y )) .style("fill", "none") .style("stroke", fill) .style("stroke-width", 2) @@ -2173,16 +2174,16 @@ dimple.plot.bar = { .delay(animDuration / 2) .duration(animDuration / 2) .ease("linear") - .attr("y2", series.y._origin); + .attr("y2", dropDest.y); } // Add a drop line to the y axis - if (!series.y._hasCategories()) { + if (!series.y._hasCategories() && dropDest.x !== null) { g.append("line") - .attr("x1", (x < series.x._origin ? x + width : x )) - .attr("y1", (y < series.y._origin ? y : y + height ) + 1) - .attr("x2", (x < series.x._origin ? x + width : x )) - .attr("y2", (y < series.y._origin ? y : y + height ) + 1) + .attr("x1", (x < dropDest.x ? x + width : x )) + .attr("y1", (y < series.y._origin ? y + 1 : y + height - 1 )) + .attr("x2", (x < dropDest.x ? x + width : x )) + .attr("y2", (y < series.y._origin ? y + 1 : y + height - 1 )) .style("fill", "none") .style("stroke", fill) .style("stroke-width", 2) @@ -2192,7 +2193,7 @@ dimple.plot.bar = { .delay(animDuration / 2) .duration(animDuration / 2) .ease("linear") - .attr("x2", series.x._origin); + .attr("x2", dropDest.x); } // Add a group for text @@ -2432,6 +2433,7 @@ dimple.plot.bubble = { var r = parseFloat(selectedShape.attr("r")); var opacity = selectedShape.attr("opacity"); var fill = selectedShape.attr("fill"); + var dropDest = series._dropLineOrigin(); // Fade the popup stroke mixing the shape fill with 60% white var popupStrokeColor = d3.rgb( @@ -2468,38 +2470,42 @@ dimple.plot.bubble = { .style("stroke-width", 2); // Add a drop line to the x axis - g.append("line") - .attr("x1", cx) - .attr("y1", (cy < series.y._origin ? cy + r + 4 : cy - r - 4 )) - .attr("x2", cx) - .attr("y2", (cy < series.y._origin ? cy + r + 4 : cy - r - 4 )) - .style("fill", "none") - .style("stroke", fill) - .style("stroke-width", 2) - .style("stroke-dasharray", ("3, 3")) - .style("opacity", opacity) - .transition() - .delay(animDuration / 2) - .duration(animDuration / 2) - .ease("linear") - .attr("y2", series.y._origin); + if (dropDest.y !== null) { + g.append("line") + .attr("x1", cx) + .attr("y1", (cy < dropDest.y ? cy + r + 4 : cy - r - 4 )) + .attr("x2", cx) + .attr("y2", (cy < dropDest.y ? cy + r + 4 : cy - r - 4 )) + .style("fill", "none") + .style("stroke", fill) + .style("stroke-width", 2) + .style("stroke-dasharray", ("3, 3")) + .style("opacity", opacity) + .transition() + .delay(animDuration / 2) + .duration(animDuration / 2) + .ease("linear") + .attr("y2", dropDest.y); + } // Add a drop line to the y axis - g.append("line") - .attr("x1", (cx < series.x._origin ? cx + r + 4 : cx - r - 4 )) - .attr("y1", cy) - .attr("x2", (cx < series.x._origin ? cx + r + 4 : cx - r - 4 )) - .attr("y2", cy) - .style("fill", "none") - .style("stroke", fill) - .style("stroke-width", 2) - .style("stroke-dasharray", ("3, 3")) - .style("opacity", opacity) - .transition() - .delay(animDuration / 2) - .duration(animDuration / 2) - .ease("linear") - .attr("x2", series.x._origin); + if (dropDest.x !== null) { + g.append("line") + .attr("x1", (cx < dropDest.x ? cx + r + 4 : cx - r - 4 )) + .attr("y1", cy) + .attr("x2", (cx < dropDest.x ? cx + r + 4 : cx - r - 4 )) + .attr("y2", cy) + .style("fill", "none") + .style("stroke", fill) + .style("stroke-width", 2) + .style("stroke-dasharray", ("3, 3")) + .style("opacity", opacity) + .transition() + .delay(animDuration / 2) + .duration(animDuration / 2) + .ease("linear") + .attr("x2", dropDest.x); + } // Add a group for text var t = g.append("g"); diff --git a/dist/dimple.v1.min.js b/dist/dimple.v1.min.js index b2b8e99..df76231 100644 --- a/dist/dimple.v1.min.js +++ b/dist/dimple.v1.min.js @@ -1,2 +1,2 @@ -var dimple={version:"1.0.0",plot:{},aggregateMethod:{}};(function(){"use strict";dimple.axis=function(t,e,i,a){this.chart=t,this.position=e,this.categoryFields=i,this.measure=a,this.hidden=!1,this.showPercent=!1,this.colors=null,this.overrideMin=null,this.overrideMax=null,this.shapes=null,this.showGridlines=null,this.gridlineShapes=null,this.titleShape=null,this._scale=null,this._min=0,this._max=0,this._previousOrigin=null,this._origin=null,this._draw=null,this._getFormat=function(){var t,e,i,a,r,s,n;return this.showPercent?t=d3.format("%"):null!==this.measure?(e=""+Math.floor(Math.abs(this._max),0),i=""+Math.floor(Math.abs(this._min),0),a=Math.max(i.length,e.length),a>3?(r=Math.min(Math.floor((a-1)/3),4),s="kmBT".substring(r-1,r),n=2>=a-3*r?1:0,t=function(t){return 0===t?0:d3.format(",."+n+"f")(t/Math.pow(1e3,r))+s}):(n=2>=a?1:0,t=d3.format(",."+n+"f"))):t=function(t){return t},t},this._hasCategories=function(){return null!=this.categoryFields&&void 0!=this.categoryFields&&this.categoryFields.length>0},this._hasMeasure=function(){return null!=this.measure&&void 0!=this.measure},this._update=function(e){if(this._min=this.showPercent&&-1>this._min?this._min=-1:this._min,this._max=this.showPercent&&this._max>1?this._max=1:this._max,this._min=null!=this.overrideMin?this.overrideMin:this._min,this._max=null!=this.overrideMax?this.overrideMax:this._max,this.position.length>0&&"x"==this.position[0]){if(null==this.measure||void 0==this.measure){var i=[];this.chart.data.forEach(function(t){-1==i.indexOf(t[this.categoryFields[0]])&&i.push(t[this.categoryFields[0]])},this),this._scale=d3.scale.ordinal().rangePoints([this.chart.x,this.chart.x+this.chart.width]).domain(i.concat([""]))}else this._scale=d3.scale.linear().range([this.chart.x,this.chart.x+this.chart.width]).domain([this._min,this._max]).nice();if(!this.hidden)switch(t._axisIndex(this,"x")){case 0:this._draw=d3.svg.axis().orient("bottom").scale(this._scale);break;case 1:this._draw=d3.svg.axis().orient("top").scale(this._scale);break;default:}}else if(this.position.length>0&&"y"==this.position[0]){if(null==this.measure||void 0==this.measure){var i=[];this.chart.data.forEach(function(t){-1==i.indexOf(t[this.categoryFields[0]])&&i.push(t[this.categoryFields[0]])},this),this._scale=d3.scale.ordinal().rangePoints([this.chart.y+this.chart.height,this.chart.y]).domain(i.concat([""]))}else this._scale=d3.scale.linear().range([this.chart.y+this.chart.height,this.chart.y]).domain([this._min,this._max]).nice();if(!this.hidden)switch(t._axisIndex(this,"y")){case 0:this._draw=d3.svg.axis().orient("left").scale(this._scale);break;case 1:this._draw=d3.svg.axis().orient("right").scale(this._scale);break;default:}}else this.position.length>0&&"z"==this.position[0]?this._scale=d3.scale.linear().range([this.chart.height/300,this.chart.height/10]).domain([this._min,this._max]):this.position.length>0&&"c"==this.position[0]&&(this._scale=d3.scale.linear().range([0,null==this.colors||1==this.colors.length?1:this.colors.length-1]).domain([this._min,this._max]));if((null==e||void 0==e||0==e)&&null!=this._scale&&null!=this._scale.ticks&&this._scale.ticks(10).length>0){var a=this._scale.ticks(10),r=a[1]-a[0],s=((this._max-this._min)%r).toFixed(0);0!=s&&(this._max=Math.ceil(this._max/r)*r,this._min=Math.floor(this._min/r)*r,this._update(!0))}var n=this._scale.copy()(0);return this._origin!=n&&(this._previousOrigin=null==this._origin?n:this._origin,this._origin=n),this}},dimple.chart=function(t,e){this.svg=t,this.x=.1*t[0][0].width.baseVal.value,this.y=.1*t[0][0].height.baseVal.value,this.width=.8*t[0][0].width.baseVal.value,this.height=.8*t[0][0].height.baseVal.value,this.data=e,this.noFormats=!1,this.axes=[],this.series=[],this.legends=[],this.storyboard=null,this.titleShape=null,this.shapes=null,this._assignedColors={},this._nextColor=0,this._axisIndex=function(t,e){var i=0,a=0;for(i=0;this.axes.length>i;i++){if(this.axes[i]==t)return a;(null==e||void 0==e||e[0]==this.axes[i].position[0])&&a++}return-1},this._getSeriesData=function(){null!==this.series&&void 0!==this.series&&this.series.forEach(function(t){var e=[],i=function(t,e){var i=[];return null!=t&&t._hasCategories()&&t.categoryFields.forEach(function(t){i.push(e[t])},this),i},a={x:!1,y:!1,z:!1,c:!1},r={x:[],y:[]};this.data.forEach(function(s){var n=-1,l=i(t.x,s),o=i(t.y,s),h=i(t.z,s),c=[];null==t.categoryFields||void 0==t.categoryFields||0==t.categoryFields.length?c=["All"]:1==t.categoryFields.length&&void 0==s[t.categoryFields[0]]?c=[t.categoryFields[0]]:t.categoryFields.forEach(function(t){c.push(s[t])},this);for(var u=c.join("/")+"_"+l.join("/")+"_"+o.join("/")+"_"+h.join("/"),d=0;e.length>d;d++)if(e[d].key==u){n=d;break}if(-1==n){var g={key:u,aggField:c,xField:l,xValue:null,xCount:0,yField:o,yValue:null,yCount:0,zField:h,zValue:null,zCount:0,cValue:0,cCount:0,x:0,y:0,xOffset:0,yOffset:0,width:0,height:0,cx:0,cy:0,xBound:0,yBound:0,xValueList:[],yValueList:[],zValueList:[],cValueList:[],fill:{},stroke:{}};e.push(g),n=e.length-1}var y=function(i,l,o){var h=!0;if(null!=o){var c=o.getFrameValue(),u="";o.categoryFields.forEach(function(t,e){e>0&&(u+="/"),u+=s[t],h=u==c},this)}if(null!=i&&void 0!=i&&null!=i.measure&&void 0!=i.measure&&h){var d=e[n];-1==d[i.position+"ValueList"].indexOf(s[i.measure])&&d[i.position+"ValueList"].push(s[i.measure]),isNaN(parseFloat(s[i.measure]))&&(a[i.position]=!0),d[i.position+"Value"]=t.aggregate(d[i.position+"Value"],d[i.position+"Count"],s[i.measure],1),d[i.position+"Count"]++}null!=i&&void 0!=i&&i._hasCategories()&&i.categoryFields.length>1&&void 0!=r[i.position]&&-1==r[i.position].indexOf(s[i.categoryFields[1]])&&r[i.position].push(s[i.categoryFields[1]])};y(t.x,this.data,this.storyboard),y(t.y,this.data,this.storyboard),y(t.z,this.data,this.storyboard),y(t.c,this.data,this.storyboard)},this);var s={x:[],y:[],z:[]},n={min:null,max:null};e.forEach(function(e){if(null!=t.x){1==a.x&&(e.xValue=e.xValueList.length);var i=(null==s.x[e.xField.join("/")]?0:s.x[e.xField.join("/")])+(t.y._hasMeasure()?Math.abs(e.yValue):0);s.x[e.xField.join("/")]=i}if(null!=t.y){1==a.y&&(e.yValue=e.yValueList.length);var i=(null==s.y[e.yField.join("/")]?0:s.y[e.yField.join("/")])+(t.x._hasMeasure()?Math.abs(e.xValue):0);s.y[e.yField.join("/")]=i}if(null!=t.z){1==a.z&&(e.zValue=e.zValueList.length);var i=(null==s.z[e.zField.join("/")]?0:s.z[e.zField.join("/")])+(t.z._hasMeasure()?Math.abs(e.zValue):0);s.z[e.zField.join("/")]=i}null!=t.c&&((null==n.min||e.cValuen.max)&&(n.max=e.cValue))},this),e.sort(function(t,e){return t.aggField!=e.aggField?t.aggField.join("/")0?h[o[o.length-1]]:0),o.push(d));var y=e[u+"Bound"]=e["c"+u]="x"!=u&&"y"!=u||!t.stacked?g:h[d];e[n]=g,e[u]=y-("x"==u&&g>=0||"y"==u&&0>=g?g:0)}else e[u]=e["c"+u]=e[u+"Field"][0],e[n]=1,void 0!=r[u]&&null!=r[u]&&r[u].length>=2&&(e[u+"Offset"]=r[u].indexOf(e[u+"Field"][1]),e[n]=1/r[u].length);else{var g=i.showPercent?e[u+"Value"]/s[a][e[a+"Field"].join("/")]:e[u+"Value"],d=e[a+"Field"].join("/")+(e[u+"Value"]>=0),f=l[u][d]=(null==l[u][d]||"z"==u?0:l[u][d])+g,y=e[u+"Bound"]=e["c"+u]="x"!=u&&"y"!=u||!t.stacked?g:f;e[n]=g,e[u]=y-("x"==u&&g>=0||"y"==u&&0>=g?g:0)}}};if(i(t.x,"y","width"),i(t.y,"x","height"),i(t.z,"z","r"),null!=t.c&&n.min!=n.max){var a,u;e.cValue=e.cValue>n.max?n.max:e.cValue1?(a=d3.rgb(t.c.colors[Math.floor(g)]),u=d3.rgb(t.c.colors[Math.ceil(g)])):(a=d3.rgb("white"),u=d3.rgb(this.getColor(e.aggField.slice(-1)[0]).fill)),a.r=Math.floor(a.r+(u.r-a.r)*y),a.g=Math.floor(a.g+(u.g-a.g)*y),a.b=Math.floor(a.b+(u.b-a.b)*y),e.fill=""+a,e.stroke=""+a.darker(.5)}},this),t._positionData=e},this)},this._registerEventHandlers=function(t){null!=t._eventHandlers&&t._eventHandlers.length>0&&t._eventHandlers.forEach(function(e){null!=e.handler&&"function"==typeof e.handler&&t.shapes.on(e.event,function(i){var a=new dimple.eventArgs;null!=t.chart.storyboard&&(a.frameValue=t.chart.storyboard.getFrameValue()),a.seriesValue=i.aggField,a.xValue=i.x,a.yValue=i.y,a.zValue=i.z,a.colorValue=i.cValue,a.seriesShapes=t.shapes,a.selectedShape=d3.select(this),e.handler(a)})},this)},this.addAxis=function(t,e,i){null!=e&&void 0!=e&&(e=[].concat(e));var a=new dimple.axis(this,t,e,i);return this.axes.push(a),a},this.addCategoryAxis=function(t,e){return this.addAxis(t,e,null)},this.addColorAxis=function(t,e){var i=this.addAxis("c",null,t);return i.colors=null==e||void 0==e?null:[].concat(e),i},this.addLegend=function(t,e,i,a,r,s){s=null==s||void 0==s?this.series:[].concat(s),r=null==r||void 0==r?"left":r;var n=new dimple.legend(this,t,e,i,a,r,s);return this.legends.push(n),n},this.addMeasureAxis=function(t,e){return this.addAxis(t,null,e)},this.addPctAxis=function(t,e){var i=this.addMeasureAxis(t,e);return i.showPercent=!0,i},this.addSeries=function(t,e,i){null==i&&(i=this.axes),null==e&&(e=dimple.plot.bubble);var a=null,r=null,s=null,n=null;i.forEach(function(t){null!=t&&e.supportedAxes.indexOf(t.position)>-1&&(null==a&&"x"==t.position[0]?a=t:null==r&&"y"==t.position[0]?r=t:null==s&&"z"==t.position[0]?s=t:null==n&&"c"==t.position[0]&&(n=t))},this),null!=t&&void 0!=t&&(t=[].concat(t));var l=new dimple.series(this,t,a,r,s,n,e,dimple.aggregateMethod.sum,e.stacked);return this.series.push(l),l},this.assignColor=function(t,e,i,a){return this._assignedColors[t]=new dimple.color(e,i,a),this._assignedColors[t]},this.defaultColors=[new dimple.color("#80B1D3"),new dimple.color("#FB8072"),new dimple.color("#FDB462"),new dimple.color("#B3DE69"),new dimple.color("#FFED6F"),new dimple.color("#BC80BD"),new dimple.color("#8DD3C7"),new dimple.color("#CCEBC5"),new dimple.color("#FFFFB3"),new dimple.color("#BEBADA"),new dimple.color("#FCCDE5"),new dimple.color("#D9D9D9")],this.draw=function(t){t=null==t||void 0==t?0:t;var e=null,i=null;this._getSeriesData(),this.axes.forEach(function(t){if(t._min=0,t._max=0,null!=t.measure&&void 0!=t.measure){var a=!1;this.series.forEach(function(e){if(e[t.position]==t){var i=e._axisBounds(t.position);t._min>i.min&&(t._min=i.min),t._maxe[t.measure]&&(t._min=e[t.measure]),t._max0&&(s!=e||null!=i.categoryFields&&0!=i.categoryFields.length||c(s.shapes.selectAll(".axis text")).attr("y",this.y+this.height-i._scale(0)+9),s!=i||null!=e.categoryFields&&0!=e.categoryFields.length||c(s.shapes.selectAll(".axis text")).attr("x",-1*(e._scale(0)-this.x)-9))),this.noFormats||(c(s.shapes.selectAll(".axis text")).style("font-family","sans-serif").style("font-size",(this.height/35>10?this.height/35:10)+"px"),c(s.shapes.selectAll(".axis path, .axis line")).style("fill","none").style("stroke","black").style("shape-rendering","crispEdges"),null!=s.gridlineShapes&&c(s.gridlineShapes.selectAll(".gridlines line")).style("fill","none").style("stroke","lightgray").style("opacity",.8));var u=!1;if(null==s.measure||void 0==s.measure)if(s==e){var d=0;s.shapes.selectAll(".axis text").each(function(){var t=this.getComputedTextLength();d=t>d?t:d}),d>this.width/s._max&&(u=!0,this.width/s._max/2,s.shapes.selectAll(".axis text").style("text-anchor","start").each(function(){var t=this.getBBox();d3.select(this).attr("transform","rotate(90,"+t.x+","+(t.y+t.height/2)+") translate(-5, 0)")}))}else if("x"==s.position){var d=0;s.shapes.selectAll(".axis text").each(function(){var t=this.getComputedTextLength();d=t>d?t:d}),d>this.width/s._max&&(this.width/s._max/2,s.shapes.selectAll(".axis text").style("text-anchor","end").each(function(){var t=this.getBBox();d3.select(this).attr("transform","rotate(90,"+(t.x+t.width)+","+(t.y+t.height/2)+") translate(5, 0)")}))}if(null==s.titleShape&&null!=s.shapes&&null!=s.shapes.node().firstChild){var g={l:null,t:null,r:null,b:null};s.shapes.selectAll(".axis text").each(function(){var t=this.getBBox();g.l=null==g.l||t.xg.r?t.x+t.width:g.r,g.b=u?null==g.b||t.y+t.width>g.b?t.y+t.width:g.b:null==g.b||t.y+t.height>g.b?t.y+t.height:g.b});var y=0,f=0,p="";"x"==s.position?(f=s==e?this.y+this.height+g.b+10:this.y+g.l+g.t-5,y=this.x+this.width/2):"y"==s.position&&(y=s==i?this.x+g.l-10:this.x+this.width+g.r+10,f=this.y+this.height/2,p="rotate(270, "+y+", "+f+")"),s.titleShape=this.svg.append("text").attr("class","axis title");var x=this;s.titleShape.attr("x",y).attr("y",f).attr("text-anchor","middle").attr("transform",p).text(null==s.categoryFields||void 0==s.categoryFields||0==s.categoryFields.length?s.measure:s.categoryFields.join("/")).each(function(){x.noFormats||d3.select(this).style("font-family","sans-serif").style("font-size",(x.height/35>10?x.height/35:10)+"px")}),s==e?s.titleShape.each(function(){d3.select(this).attr("y",f+this.getBBox().height/1.65)}):s==i&&s.titleShape.each(function(){d3.select(this).attr("x",y+this.getBBox().height/1.65)})}},this),this.series.forEach(function(e){e.plot.draw(this,e,t),this._registerEventHandlers(e)},this),this.legends.forEach(function(e){e._draw(t)},this),null!=this.storyboard&&void 0!=this.storyboard&&(this.storyboard._drawText(),this.storyboard.autoplay&&this.storyboard.startAnimation()),this},this.getColor=function(t){return(null==this._assignedColors[t]||void 0==this._assignedColors[t])&&(this._assignedColors[t]=this.defaultColors[this._nextColor],this._nextColor=(this._nextColor+1)%this.defaultColors.length),this._assignedColors[t]},this.setBounds=function(t,e,i,a){return this.x=t,this.y=e,this.width=i,this.height=a,this.axes.forEach(function(t){t._update()},this),this},this.setStoryboard=function(t,e){return this.storyboard=new dimple.storyboard(this,t),null!=e&&void 0!=e&&(this.storyboard.onTick=e),this.storyboard}},dimple.color=function(t,e,i){this.fill=t,this.stroke=null==e||void 0==e?""+d3.rgb(t).darker(.5):e,this.opacity=null==i||void 0==i?.8:i},dimple.eventArgs=function(){this.seriesValue=null,this.xValue=null,this.yValue=null,this.zValue=null,this.colorValue=null,this.frameValue=null,this.seriesShapes=null,this.selectedShape=null},dimple.legend=function(t,i,a,r,s,n,l){this.chart=t,this.series=l,this.x=i,this.y=a,this.width=r,this.height=s,this.horizontalAlign=n,this.shapes=null,this._draw=function(i){var a=this._getEntries();(null!=this.shapes||void 0!=this.shapes)&&this.shapes.transition().duration(.2*i).attr("opacity",0).remove();var r=0,s=0,n=0,l=0,o=15,h=9,c=this,u=t.svg.selectAll(".dontSelectAny").data(a).enter().append("g").attr("class","legend").attr("opacity",0);u.append("text").attr("id",function(t){return"legend_"+t.key}).attr("class","legendText").text(function(t){return t.key}).call(function(){t.noFormats||this.style("font-family","sans-serif").style("font-size",(t.height/35>10?t.height/35:10)+"px").style("shape-rendering","crispEdges")}).each(function(){var t=this.getBBox();t.width>r&&(r=t.width),t.height>s&&(s=t.height)}),u.append("rect").attr("class","legendKey").attr("height",h).attr("width",o),s=(h>s?h:s)+2,r+=o+20,u.each(function(t){n+r>c.width&&(n=0,l+=s),l>c.height?d3.select(this).remove():(d3.select(this).select("text").attr("x","left"==c.horizontalAlign?c.x+o+5+n:c.x+(c.width-n-r)+o+5).attr("y",function(){return c.y+l+this.getBBox().height/1.65}).attr("width",c.width).attr("height",c.height),d3.select(this).select("rect").attr("class","legend legendKey").attr("x","left"==c.horizontalAlign?c.x+n:c.x+(c.width-n-r)).attr("y",c.y+l).attr("height",h).attr("width",o).style("fill",function(){return e.fill(t,c.chart,t.series)}).style("stroke",function(){return e.stroke(t,c.chart,t.series)}).style("opacity",function(){return e.opacity(t,c.chart,t.series)}).style("shape-rendering","crispEdges"),n+=r)}),u.transition().delay(.2*i).duration(.8*i).attr("opacity",1),this.shapes=u},this._getEntries=function(){var t=[];return null!=this.series&&void 0!=this.series&&this.series.forEach(function(e){var i=e._positionData;i.forEach(function(i){for(var a=-1,r=0;t.length>r;r++)if(t[r].key==i.aggField.slice(-1)[0]){a=r;break}-1==a&&(t.push({key:i.aggField.slice(-1)[0],fill:i.fill,stroke:i.stroke,series:e,aggField:i.aggField}),a=t.length-1)})},this),t}},dimple.series=function(t,e,i,a,r,s,n,l,o){this.chart=t,this.x=i,this.y=a,this.z=r,this.c=s,this.plot=n,this.categoryFields=e,this.aggregate=l,this.stacked=o,this.barGap=.2,this.clusterBarGap=.1,this.lineWeight=2,this.lineMarkers=!1,this._eventHandlers=[],this._positionData=[],this._axisBounds=function(t){var e={min:0,max:0},n=null,l=null,o=[],h=0;"x"==t[0]?(n=i,l=a):"y"==t[0]?(n=a,l=i):"z"==t[0]?n=r:"c"==t[0]&&(n=s);var c=this._positionData;if(n.showPercent)c.forEach(function(t){t[n.position+"Bound"]e.max&&(e.max=t[n.position+"Bound"])},this);else if(null==l||null==l.categoryFields||0==l.categoryFields.length)c.forEach(function(t){!this.stacked||"x"!=n.position&&"y"!=n.position?(t[n.position+"Value"]e.max&&(e.max=t[n.position+"Value"])):0>t[n.position+"Value"]?e.min=e.min+t[n.position+"Value"]:e.max=e.max+t[n.position+"Value"]},this);else{var u=n.position+"Value",d=l.position+"Field",g=[];c.forEach(function(t){var e=t[d].join("/"),i=g.indexOf(e);-1==i&&(g.push(e),i=g.length-1),void 0==o[i]&&(o[i]={min:0,max:0},i>=h&&(h=i+1)),this.stacked?0>t[u]?o[i].min=o[i].min+t[u]:o[i].max=o[i].max+t[u]:(t[u]o[i].max&&(o[i].max=t[u]))},this),o.forEach(function(t){void 0!=t&&(t.mine.max&&(e.max=t.max))},this)}return e},this._dropLineOrigin=function(){var t=0,e=0,i={x:null,y:null},a={x:null,y:null};return this.chart.axes.forEach(function(t){"x"==t.position&&null===a.x?a.x=t._origin:"y"==t.position&&null===a.y&&(a.y=t._origin)},this),this.chart.axes.forEach(function(r){"x"!=r.position||this.x.hidden?"y"!=r.position||this.y.hidden||(r===this.y&&(0==e?i.x=a.x:1==e&&(i.x=this.chart.x+this.chart.width)),e++):(r===this.x&&(0==t?i.y=a.y:1==t&&(i.y=this.chart.y)),t++)},this),i},this.addEventHandler=function(t,e){this._eventHandlers.push({event:t,handler:e})}},dimple.storyboard=function(t,e){null!=e&&void 0!=e&&(e=[].concat(e)),this.chart=t,this.categoryFields=e,this.autoplay=!0,this.frameDuration=3e3,this.storyLabel=null,this.onTick=null,this._frame=0,this._animationTimer=null,this._categories=[],this._cachedCategoryFields=[],this._drawText=function(t){if(null==this.storyLabel||void 0==this.storyLabel){var e=this;this.storyLabel=this.chart.svg.append("text").attr("x",this.chart.x+.01*this.chart.width).attr("y",this.chart.y+1.25*(this.chart.height/35>10?this.chart.height/35:10)).call(function(){e.noFormats||this.style("font-family","sans-serif").style("font-size",(e.height/35>10?e.height/35:10)+"px")})}this.storyLabel.transition().duration(.2*t).attr("opacity",0),this.storyLabel.transition().delay(.2*t).text(this.categoryFields.join("\\")+": "+this.getFrameValue()).transition().duration(.8*t).attr("opacity",1)},this._getCategories=function(){return this._categoryFields!=this._cachedCategoryFields&&(this._categories=[],this.chart.data.forEach(function(t){var e=-1;if(null!=this.categoryFields){var i="";this.categoryFields.forEach(function(e,a){a>0&&(i+="/"),i+=t[e]},this),e=this._categories.indexOf(i),-1==e&&(this._categories.push(i),e=this._categories.length-1)}},this),this._cachedCategoryFields=this._categoryFields),this._categories},this._goToFrameIndex=function(t){this._frame=t%this._getCategories().length,this.chart.draw(this.frameDuration/2)},this.getFrameValue=function(){return this._frame>=0&&this._getCategories().length>this._frame?this._getCategories()[this._frame]:null},this.goToFrame=function(t){if(this._getCategories().length>0){var e=this._getCategories().indexOf(t);this._goToFrameIndex(e)}},this.pauseAnimation=function(){null!=this._animationTimer&&(clearInterval(this._animationTimer),this._animationTimer=null)},this.startAnimation=function(){null==this._animationTimer&&(null!=this.onTick&&this.onTick(this.getFrameValue()),this._animationTimer=setInterval(function(t){return function(){t._goToFrameIndex(t._frame+1),null!=t.onTick&&t.onTick(t.getFrameValue()),t._drawText(t.frameDuration/2)}}(this),this.frameDuration))},this.stopAnimation=function(){null!=this._animationTimer&&(clearInterval(this._animationTimer),this._animationTimer=null,this._frame=0)}},dimple.aggregateMethod.avg=function(t,e,i,a){return t=null==t||void 0==t?0:t,i=null==i||void 0==i?0:i,(parseFloat(t)*parseFloat(e)+parseFloat(i)*parseFloat(a))/(parseFloat(e)+parseFloat(a))},dimple.aggregateMethod.count=function(t,e,i,a){return parseFloat(e)+parseFloat(a)},dimple.aggregateMethod.max=function(t,e,i){return parseFloat(t)>parseFloat(i)?parseFloat(t):parseFloat(i)},dimple.aggregateMethod.min=function(t,e,i){return null==t?parseFloat(i):parseFloat(t)=0;l--){var o=r[l],u={cx:0,cy:0,height:0,width:0,xOffset:0,yOffset:0};if(a.x._hasCategories()){if(u.cx=o.cx,u.width=o.width,u.xOffset=o.xOffset,void 0==c[o.xField])c[o.xField]=[];else{var d=0;c[o.xField].forEach(function(t){(o.cy>=0&&t>=0||0>=o.cy&&0>=t)&&Math.abs(t)<=Math.abs(o.cy)&&Math.abs(t)>Math.abs(d)&&(d=t)},this),u.cy=d}s.push(u),c[o.xField].push(o.cy)}else if(a.y._hasCategories()){if(u.cy=o.cy,u.height=o.height,u.yOffset=o.yOffset,void 0==c[o.yField])c[o.yField]=[];else{var d=0;c[o.yField].forEach(function(t){(o.cx>=0&&t>=0||0>=o.cx&&0>=t)&&Math.abs(t)<=Math.abs(o.cx)&&Math.abs(t)>Math.abs(d)&&(d=t)},this),u.cx=d}s.push(u),c[o.yField].push(o.cx)}}return h(r.concat(s).concat(r[0]))}).call(function(){i.noFormats||this.attr("fill",function(t){return o?"url(#fill-area-gradient-"+t.replace(" ","")+")":i.getColor(t).fill}).attr("stroke",function(t){return o?"url(#stroke-area-gradient-"+t.replace(" ","")+")":i.getColor(t).stroke}).attr("stroke-width",a.lineWeight)});var u=i.svg.selectAll(".markers").data(n).enter();a.lineMarkers&&u.append("circle").transition().duration(r).attr("cx",function(t){return e.cx(t,i,a)}).attr("cy",function(t){return e.cy(t,i,a)}).attr("r",2+a.lineWeight).attr("fill","white").attr("stroke","none"),u.append("circle").on("mouseover",function(t){s.enterEventHandler(t,this,i,a,r)}).on("mouseleave",function(t){s.leaveEventHandler(t,this,i,a,r)}).transition().duration(r).attr("cx",function(t){return e.cx(t,i,a)}).attr("cy",function(t){return e.cy(t,i,a)}).attr("r",2+a.lineWeight).attr("opacity",function(t){return a.lineMarkers?i.getColor(t).opacity:0}).call(function(){i.noFormats||this.attr("fill","white").style("stroke-width",a.lineWeight).attr("stroke",function(t){return e.stroke(t,i,a)})})},enterEventHandler:function(t,i,a,r){var s=5,n=10,l=750,o=a.svg,h=d3.select(i),c=parseFloat(h.attr("cx")),u=parseFloat(h.attr("cy")),d=parseFloat(h.attr("r")),g=e.opacity(t,a,r),y=e.fill(t,a,r),f=r._dropLineOrigin();h.style("opacity",1);var p=d3.rgb(d3.rgb(y).r+.6*(255-d3.rgb(y).r),d3.rgb(y).g+.6*(255-d3.rgb(y).g),d3.rgb(y).b+.6*(255-d3.rgb(y).b)),x=d3.rgb(d3.rgb(y).r+.8*(255-d3.rgb(y).r),d3.rgb(y).g+.8*(255-d3.rgb(y).g),d3.rgb(y).b+.8*(255-d3.rgb(y).b)),m=o.append("g").attr("class","hoverShapes");m.append("circle").attr("cx",c).attr("cy",u).attr("r",d).attr("opacity",0).style("fill","none").style("stroke",y).style("stroke-width",1).transition().duration(l/2).ease("linear").attr("opacity",1).attr("r",d+4).style("stroke-width",2),null!==f.x&&m.append("line").attr("x1",c).attr("y1",r.y._origin>u?u+d+4:u-d-4).attr("x2",c).attr("y2",r.y._origin>u?u+d+4:u-d-4).style("fill","none").style("stroke",y).style("stroke-width",2).style("stroke-dasharray","3, 3").style("opacity",g).transition().delay(l/2).duration(l/2).ease("linear").attr("y2",r.y._origin),m.append("line").attr("x1",r.x._origin>c?c+d+4:c-d-4).attr("y1",u).attr("x2",r.x._origin>c?c+d+4:c-d-4).attr("y2",u).style("fill","none").style("stroke",y).style("stroke-width",2).style("stroke-dasharray","3, 3").style("opacity",g).transition().delay(l/2).duration(l/2).ease("linear").attr("x2",r.x._origin);var v=m.append("g"),_=v.append("rect"),F=[];null!=r.categoryFields&&void 0!=r.categoryFields&&r.categoryFields.length>0&&r.categoryFields.forEach(function(e,i){F.push(e+(t.aggField!=e?": "+t.aggField[i]:""))},this),r.x._hasCategories()?r.x.categoryFields.forEach(function(e,i){F.push(e+(t.xField!=e?": "+t.xField[i]:""))},this):F.push(r.x.measure+": "+r.x._getFormat()(t.cx)),r.y._hasCategories()?r.y.categoryFields.forEach(function(e,i){F.push(e+(t.yField!=e?": "+t.yField[i]:""))},this):F.push(r.y.measure+":"+r.y._getFormat()(t.cy)),null!=r.z&&void 0!=r.z&&F.push(r.z.measure+": "+r.z._getFormat()(t.zValue)),null!=r.c&&void 0!=r.c&&F.push(r.c.measure+": "+r.c._getFormat()(t.cValue)),F=F.filter(function(t,e){return F.indexOf(t)==e}),v.selectAll(".textHoverShapes").data(F).enter().append("text").text(function(t){return t}).style("font-family","sans-serif").style("font-size","10px");var w=0,b=0,k=0;v.each(function(){b=this.getBBox().width>b?this.getBBox().width:b,k=this.getBBox().width>k?this.getBBox().height:k}),v.selectAll("text").attr("x",0).attr("y",function(){return w+=this.getBBox().height,w-this.getBBox().height/2}),_.attr("x",-s).attr("y",-s).attr("height",Math.floor(w+s)-.5).attr("width",b+2*s).attr("rx",5).attr("ry",5).style("fill",x).style("stroke",p).style("stroke-width",2).style("opacity",.95);var C=c+d+s+n+b>parseFloat(o.attr("width"));v.attr("transform","translate("+(C?c-(d+s+n+b):c+d+s+n)+" , "+(u-(w-(k-s))/2)+")")},leaveEventHandler:function(t,i,a,r){d3.select(i).style("opacity",r.lineMarkers?e.opacity(t,a,r):0),a.svg.selectAll(".hoverShapes").remove()}},dimple.plot.bar={stacked:!0,supportedAxes:["x","y","c"],draw:function(t,i,a){var r=this;t.svg.selectAll(".hoverShapes").transition().duration(a/4).style("opacity",0).remove();var s=i._positionData,n=null,l="series"+t.series.indexOf(i);n=null==i.shapes||void 0==i.shapes?t.svg.selectAll("."+l).data(s):i.shapes.data(s,function(t){return t.key}),n.enter().append("rect").attr("id",function(t){return t.key}).attr("class",function(t){return l+" bar "+t.aggField.join(" ")+" "+t.xField.join(" ")+" "+t.yField.join(" ")}).attr("x",function(a){return e.x(a,t,i)}).attr("y",function(a){return e.y(a,t,i)}).attr("width",function(a){return null!=a.xField&&a.xField.length>0?e.width(a,t,i):0}).attr("height",function(a){return null!=a.yField&&a.yField.length>0?e.height(a,t,i):0}).attr("opacity",function(a){return e.opacity(a,t,i)}).on("mouseover",function(e){r.enterEventHandler(e,this,t,i,a)}).on("mouseleave",function(e){r.leaveEventHandler(e,this,t,i,a)}).call(function(){t.noFormats||this.attr("fill",function(a){return e.fill(a,t,i)}).attr("stroke",function(a){return e.stroke(a,t,i)})}),n.transition().duration(a).attr("x",function(a){return e.x(a,t,i)}).attr("y",function(a){return e.y(a,t,i)}).attr("width",function(a){return e.width(a,t,i)}).attr("height",function(a){return e.height(a,t,i)}).call(function(){t.noFormats||this.attr("fill",function(a){return e.fill(a,t,i)}).attr("stroke",function(a){return e.stroke(a,t,i)})}),n.exit().transition().duration(a).attr("x",function(a){return e.x(a,t,i)}).attr("y",function(a){return e.y(a,t,i)}).attr("width",function(a){return e.width(a,t,i)}).attr("height",function(a){return e.height(a,t,i)}).each("end",function(){this.remove()}),i.shapes=n},enterEventHandler:function(t,e,i,a){var r=5,s=10,n=750,l=i.svg,o=d3.select(e),h=parseFloat(o.attr("x")),c=parseFloat(o.attr("y")),u=parseFloat(o.attr("width")),d=parseFloat(o.attr("height")),g=o.attr("opacity"),y=o.attr("fill"),f=d3.rgb(d3.rgb(y).r+.6*(255-d3.rgb(y).r),d3.rgb(y).g+.6*(255-d3.rgb(y).g),d3.rgb(y).b+.6*(255-d3.rgb(y).b)),p=d3.rgb(d3.rgb(y).r+.8*(255-d3.rgb(y).r),d3.rgb(y).g+.8*(255-d3.rgb(y).g),d3.rgb(y).b+.8*(255-d3.rgb(y).b)),x=l.append("g").attr("class","hoverShapes");a.x._hasCategories()||x.append("line").attr("x1",(a.x._origin>h?h:h+u)-1).attr("y1",a.y._origin>c?c+d:c).attr("x2",(a.x._origin>h?h:h+u)-1).attr("y2",a.y._origin>c?c+d:c).style("fill","none").style("stroke",y).style("stroke-width",2).style("stroke-dasharray","3, 3").style("opacity",g).transition().delay(n/2).duration(n/2).ease("linear").attr("y2",a.y._origin),a.y._hasCategories()||x.append("line").attr("x1",a.x._origin>h?h+u:h).attr("y1",(a.y._origin>c?c:c+d)+1).attr("x2",a.x._origin>h?h+u:h).attr("y2",(a.y._origin>c?c:c+d)+1).style("fill","none").style("stroke",y).style("stroke-width",2).style("stroke-dasharray","3, 3").style("opacity",g).transition().delay(n/2).duration(n/2).ease("linear").attr("x2",a.x._origin); -var m=x.append("g"),v=m.append("rect"),_=[];null!=a.categoryFields&&void 0!=a.categoryFields&&a.categoryFields.length>0&&a.categoryFields.forEach(function(e,i){_.push(e+(t.aggField!=e?": "+t.aggField[i]:""))},this),a.x._hasCategories()?a.x.categoryFields.forEach(function(e,i){_.push(e+(t.xField!=e?": "+t.xField[i]:""))},this):_.push(a.x.measure+": "+a.x._getFormat()(t.width)),a.y._hasCategories()?a.y.categoryFields.forEach(function(e,i){_.push(e+(t.yField!=e?": "+t.yField[i]:""))},this):_.push(a.y.measure+":"+a.y._getFormat()(t.height)),null!=a.c&&void 0!=a.c&&_.push(a.c.measure+": "+a.c._getFormat()(a.c.showPercent?t.cPct:t.cValue)),_=_.filter(function(t,e){return _.indexOf(t)==e}),m.selectAll(".textHoverShapes").data(_).enter().append("text").text(function(t){return t}).style("font-family","sans-serif").style("font-size","10px");var F=0,w=0,b=0;m.each(function(){w=this.getBBox().width>w?this.getBBox().width:w,b=this.getBBox().width>b?this.getBBox().height:b}),m.selectAll("text").attr("x",0).attr("y",function(){return F+=this.getBBox().height,F-this.getBBox().height/2}),v.attr("x",-r).attr("y",-r).attr("height",Math.floor(F+r)-.5).attr("width",w+2*r).attr("rx",5).attr("ry",5).style("fill",p).style("stroke",f).style("stroke-width",2).style("opacity",.95),parseFloat(l.attr("width"))>h+u+r+s+w?m.attr("transform","translate("+(h+u+r+s)+" , "+(c+d/2-(F-(b-r))/2)+")"):h-(r+s+w)>0?m.attr("transform","translate("+(h-(r+s+w))+" , "+(c+d/2-(F-(b-r))/2)+")"):parseFloat(l.attr("height"))>c+d+F+s+r?m.attr("transform","translate("+(h+u/2-(2*r+w)/2)+" , "+(c+d+2*r)+")"):m.attr("transform","translate("+(h+u/2-(2*r+w)/2)+" , "+(c-F-(b-r))+")")},leaveEventHandler:function(t,e,i){i.svg.selectAll(".hoverShapes").remove()}},dimple.plot.bubble={stacked:!1,supportedAxes:["x","y","z","c"],draw:function(t,i,a){var r=this;t.svg.selectAll(".hoverShapes").transition().duration(a/4).style("opacity",0).remove();var s=i._positionData,n=null,l="series"+t.series.indexOf(i);n=null==i.shapes||void 0==i.shapes?t.svg.selectAll("."+l).data(s):i.shapes.data(s,function(t){return t.key}),n.enter().append("circle").attr("id",function(t){return t.key}).attr("class",function(t){return l+" bubble "+t.aggField.join(" ")+" "+t.xField.join(" ")+" "+t.yField.join(" ")+" "+t.zField.join(" ")}).attr("cx",function(){return i.x._previousOrigin}).attr("cy",function(){return i.y._previousOrigin}).attr("r",0).attr("opacity",function(a){return e.opacity(a,t,i)}).on("mouseover",function(e){r.enterEventHandler(e,this,t,i,a)}).on("mouseleave",function(e){r.leaveEventHandler(e,this,t,i,a)}).call(function(){t.noFormats||this.attr("fill",function(a){return e.fill(a,t,i)}).attr("stroke",function(a){return e.stroke(a,t,i)})}),n.transition().duration(a).attr("cx",function(a){return e.cx(a,t,i)}).attr("cy",function(a){return e.cy(a,t,i)}).attr("r",function(a){return e.r(a,t,i)}).call(function(){t.noFormats||this.attr("fill",function(a){return e.fill(a,t,i)}).attr("stroke",function(a){return e.stroke(a,t,i)})}),n.exit().transition().duration(a).attr("r",0).attr("cx",function(){return i.x._origin}).attr("cy",function(){return i.y._origin}).each("end",function(){this.remove()}),i.shapes=n},enterEventHandler:function(t,e,i,a){var r=5,s=10,n=750,l=i.svg,o=d3.select(e),h=parseFloat(o.attr("cx")),c=parseFloat(o.attr("cy")),u=parseFloat(o.attr("r")),d=o.attr("opacity"),g=o.attr("fill"),y=d3.rgb(d3.rgb(g).r+.6*(255-d3.rgb(g).r),d3.rgb(g).g+.6*(255-d3.rgb(g).g),d3.rgb(g).b+.6*(255-d3.rgb(g).b)),f=d3.rgb(d3.rgb(g).r+.8*(255-d3.rgb(g).r),d3.rgb(g).g+.8*(255-d3.rgb(g).g),d3.rgb(g).b+.8*(255-d3.rgb(g).b)),p=l.append("g").attr("class","hoverShapes");p.append("circle").attr("cx",h).attr("cy",c).attr("r",u).attr("opacity",0).style("fill","none").style("stroke",g).style("stroke-width",1).transition().duration(n/2).ease("linear").attr("opacity",1).attr("r",u+4).style("stroke-width",2),p.append("line").attr("x1",h).attr("y1",a.y._origin>c?c+u+4:c-u-4).attr("x2",h).attr("y2",a.y._origin>c?c+u+4:c-u-4).style("fill","none").style("stroke",g).style("stroke-width",2).style("stroke-dasharray","3, 3").style("opacity",d).transition().delay(n/2).duration(n/2).ease("linear").attr("y2",a.y._origin),p.append("line").attr("x1",a.x._origin>h?h+u+4:h-u-4).attr("y1",c).attr("x2",a.x._origin>h?h+u+4:h-u-4).attr("y2",c).style("fill","none").style("stroke",g).style("stroke-width",2).style("stroke-dasharray","3, 3").style("opacity",d).transition().delay(n/2).duration(n/2).ease("linear").attr("x2",a.x._origin);var x=p.append("g"),m=x.append("rect"),v=[];null!=a.categoryFields&&void 0!=a.categoryFields&&a.categoryFields.length>0&&a.categoryFields.forEach(function(e,i){v.push(e+(t.aggField!=e?": "+t.aggField[i]:""))},this),a.x._hasCategories()?a.x.categoryFields.forEach(function(e,i){v.push(e+(t.xField!=e?": "+t.xField[i]:""))},this):v.push(a.x.measure+": "+a.x._getFormat()(t.cx)),a.y._hasCategories()?a.y.categoryFields.forEach(function(e,i){v.push(e+(t.yField!=e?": "+t.yField[i]:""))},this):v.push(a.y.measure+":"+a.y._getFormat()(t.cy)),null!=a.z&&void 0!=a.z&&v.push(a.z.measure+": "+a.z._getFormat()(t.zValue)),null!=a.c&&void 0!=a.c&&v.push(a.c.measure+": "+a.c._getFormat()(t.cValue)),v=v.filter(function(t,e){return v.indexOf(t)==e}),x.selectAll(".textHoverShapes").data(v).enter().append("text").text(function(t){return t}).style("font-family","sans-serif").style("font-size","10px");var _=0,F=0,w=0;x.each(function(){F=this.getBBox().width>F?this.getBBox().width:F,w=this.getBBox().width>w?this.getBBox().height:w}),x.selectAll("text").attr("x",0).attr("y",function(){return _+=this.getBBox().height,_-this.getBBox().height/2}),m.attr("x",-r).attr("y",-r).attr("height",Math.floor(_+r)-.5).attr("width",F+2*r).attr("rx",5).attr("ry",5).style("fill",f).style("stroke",y).style("stroke-width",2).style("opacity",.95);var b=h+u+r+s+F>parseFloat(l.attr("width"));x.attr("transform","translate("+(b?h-(u+r+s+F):h+u+r+s)+" , "+(c-(_-(w-r))/2)+")")},leaveEventHandler:function(t,e,i){i.svg.selectAll(".hoverShapes").remove()}},dimple.plot.line={stacked:!1,supportedAxes:["x","y","c"],draw:function(i,a,r){var s=this,n=a._positionData,l=[],o=[],h=1;(a.x._hasCategories()||a.y._hasCategories())&&(h=0),n.forEach(function(t){for(var e=[],i=!1,a=h;t.aggField.length>a;a++)e.push(t.aggField[a]);o.forEach(function(t){i=i||t.join("/")==e.join("/")},this),i||o.push(e)},this);var c=!1;null!=a.c&&void 0!=a.c&&(a.x._hasCategories()&&a.y._hasMeasure()||a.y._hasCategories()&&a.x._hasMeasure())&&(c=!0,o.forEach(function(e){t(e,"fill-line-gradient-"+e.replace(" ",""),a.x._hasCategories()?a.x:a.y,n,i,r,"fill")},this));var u=d3.svg.line().x(function(t){return e.cx(t,i,a)}).y(function(t){return e.cy(t,i,a)});(null==a.shapes||void 0==a.shapes)&&(a.shapes=i.svg.selectAll(".line").data(o).enter().append("svg:path").attr("opacity",function(t){return i.getColor(t).opacity})),a.shapes.data(o).transition().duration(r).attr("class",function(t){return"series line "+t.join("/").replace(" ","")}).attr("d",function(t){var r=[];return n.forEach(function(e){for(var i=!0,a=h;e.aggField.length>a;a++)i=i&&t[a-h]==e.aggField[a];i&&r.push(e)},this),r.sort(function(t,r){return a.x._hasCategories()?e.cx(t,i,a)u?u+d+4:u-d-4).attr("x2",c).attr("y2",f.y>u?u+d+4:u-d-4).style("fill","none").style("stroke",y).style("stroke-width",2).style("stroke-dasharray","3, 3").style("opacity",g).transition().delay(l/2).duration(l/2).ease("linear").attr("y2",f.y),null!==f.x&&m.append("line").attr("x1",f.x>c?c+d+4:c-d-4).attr("y1",u).attr("x2",f.x>c?c+d+4:c-d-4).attr("y2",u).style("fill","none").style("stroke",y).style("stroke-width",2).style("stroke-dasharray","3, 3").style("opacity",g).transition().delay(l/2).duration(l/2).ease("linear").attr("x2",f.x);var v=m.append("g"),_=v.append("rect"),F=[];null!=r.categoryFields&&void 0!=r.categoryFields&&r.categoryFields.length>0&&r.categoryFields.forEach(function(e,i){F.push(e+(t.aggField!=e?": "+t.aggField[i]:""))},this),r.x._hasCategories()?r.x.categoryFields.forEach(function(e,i){F.push(e+(t.xField!=e?": "+t.xField[i]:""))},this):F.push(r.x.measure+": "+r.x._getFormat()(t.cx)),r.y._hasCategories()?r.y.categoryFields.forEach(function(e,i){F.push(e+(t.yField!=e?": "+t.yField[i]:""))},this):F.push(r.y.measure+": "+r.y._getFormat()(t.cy)),null!=r.z&&void 0!=r.z&&F.push(r.z.measure+": "+r.z._getFormat()(t.zValue)),null!=r.c&&void 0!=r.c&&F.push(r.c.measure+": "+r.c._getFormat()(t.cValue)),F=F.filter(function(t,e){return F.indexOf(t)==e}),v.selectAll(".textHoverShapes").data(F).enter().append("text").text(function(t){return t}).style("font-family","sans-serif").style("font-size","10px");var w=0,b=0,k=0;v.each(function(){b=this.getBBox().width>b?this.getBBox().width:b,k=this.getBBox().width>k?this.getBBox().height:k}),v.selectAll("text").attr("x",0).attr("y",function(){return w+=this.getBBox().height,w-this.getBBox().height/2}),_.attr("x",-s).attr("y",-s).attr("height",Math.floor(w+s)-.5).attr("width",b+2*s).attr("rx",5).attr("ry",5).style("fill",x).style("stroke",p).style("stroke-width",2).style("opacity",.95);var C=c+d+s+n+b>parseFloat(o.attr("width"));v.attr("transform","translate("+(C?c-(d+s+n+b):c+d+s+n)+" , "+(u-(w-(k-s))/2)+")")},leaveEventHandler:function(t,i,a,r){d3.select(i).style("opacity",r.lineMarkers?e.opacity(t,a,r):0),a.svg.selectAll(".hoverShapes").remove()}};var t=function(t,e,i,a,r,s,n){var l=r.svg.select("#"+e),o=[];a.forEach(function(t){-1==o.indexOf(t[i.categoryFields[0]])&&o.push(t[i.categoryFields[0]])},this);var h=i.position+"Field",c=!0;null==l.node()&&(c=!1,l=r.svg.append("linearGradient").attr("id",e).attr("gradientUnits","userSpaceOnUse").attr("x1","x"==i.position?i._scale(o[0])+r.width/o.length/2:0).attr("y1","y"==i.position?i._scale(o[0])-r.height/o.length/2:0).attr("x2","x"==i.position?i._scale(o[o.length-1])+r.width/o.length/2:0).attr("y2","y"==i.position?i._scale(o[o.length-1])-r.height/o.length/2:0));var u=[];o.forEach(function(e,i){for(var r={},s=0;a.length>s;s++)if(a[s].aggField==t&&a[s][h]==e){r=a[s];break}u.push({offset:Math.round(100*(i/(o.length-1)))+"%",color:r[n]})},this),c?l.selectAll("stop").data(u).transition().duration(s).attr("offset",function(t){return t.offset}).attr("stop-color",function(t){return t.color}):l.selectAll("stop").data(u).enter().append("stop").attr("offset",function(t){return t.offset}).attr("stop-color",function(t){return t.color})},e={cx:function(t,i,a){return null!=a.x.measure&&void 0!=a.x.measure?a.x._scale(t.cx):null!=a.x.categoryFields&&void 0!=a.x.categoryFields&&a.x.categoryFields.length>=2?a.x._scale(t.cx)+e.xGap(t,i,a)+(t.xOffset+.5)*(i.width/a.x._max-2*e.xGap(t,i,a))*t.width:a.x._scale(t.cx)+i.width/a.x._max/2},cy:function(t,i,a){return null!=a.y.measure&&void 0!=a.y.measure?a.y._scale(t.cy):null!=a.y.categoryFields&&void 0!=a.y.categoryFields&&a.y.categoryFields.length>=2?a.y._scale(t.cy)-i.height/a.y._max+e.yGap(t,i,a)+(t.yOffset+.5)*(i.height/a.y._max-2*e.yGap(t,i,a))*t.height:a.y._scale(t.cy)-i.height/a.y._max/2},r:function(t,e,i){return null==i.z||void 0==i.z?5:i.z._hasMeasure()?i.z._scale(t.r):i.z._scale(e.height/100)},xGap:function(t,e,i){return(null==i.x.measure||void 0==i.x.measure)&&i.barGap>0?e.width/i.x._max*(i.barGap>.99?.99:i.barGap)/2:0},xClusterGap:function(t,i,a){return null!=a.x.categoryFields&&void 0!=a.x.categoryFields&&a.x.categoryFields.length>=2&&a.clusterBarGap>0?t.width*(i.width/a.x._max-2*e.xGap(t,i,a))*(a.clusterBarGap>.99?.99:a.clusterBarGap)/2:0},yGap:function(t,e,i){return(null==i.y.measure||void 0==i.y.measure)&&i.barGap>0?e.height/i.y._max*(i.barGap>.99?.99:i.barGap)/2:0},yClusterGap:function(t,i,a){return null!=a.y.categoryFields&&void 0!=a.y.categoryFields&&a.y.categoryFields.length>=2&&a.clusterBarGap>0?t.height*(i.height/a.y._max-2*e.yGap(t,i,a))*(a.clusterBarGap>.99?.99:a.clusterBarGap)/2:0},x:function(t,i,a){return a.x._scale(t.x)+e.xGap(t,i,a)+t.xOffset*(e.width(t,i,a)+2*e.xClusterGap(t,i,a))+e.xClusterGap(t,i,a)},y:function(t,i,a){return null!=a.y.measure&&void 0!=a.y.measure?a.y._scale(t.y):a.y._scale(t.y)-i.height/a.y._max+e.yGap(t,i,a)+t.yOffset*(e.height(t,i,a)+2*e.yClusterGap(t,i,a))+e.yClusterGap(t,i,a)},width:function(t,i,a){return null!=a.x.measure&&void 0!=a.x.measure?Math.abs(a.x._scale(t.width)-a.x._scale(0)):t.width*(i.width/a.x._max-2*e.xGap(t,i,a))-2*e.xClusterGap(t,i,a)},height:function(t,i,a){return null!=a.y.measure&&void 0!=a.y.measure?Math.abs(a.y._scale(0)-a.y._scale(t.height)):t.height*(i.height/a.y._max-2*e.yGap(t,i,a))-2*e.yClusterGap(t,i,a)},opacity:function(t,e,i){return null!=i.c&&void 0!=i.c?t.opacity:e.getColor(t.aggField.slice(-1)[0]).opacity},fill:function(t,e,i){return null!=i.c&&void 0!=i.c?t.fill:e.getColor(t.aggField.slice(-1)[0]).fill},stroke:function(t,e,i){return null!=i.c&&void 0!=i.c?t.stroke:e.getColor(t.aggField.slice(-1)[0]).stroke}};dimple.filterData=function(t,e,i){if(null!=e&&null!=i){null!=i&&void 0!=i&&(i=[].concat(i));var a=[];return t.forEach(function(t){null==t[e]?a.push(t):i.indexOf([].concat(t[e]).join("/"))>-1&&a.push(t)},this),a}return t},dimple.getUniqueValues=function(t,e){var i=[];return null!=e&&void 0!=e&&(e=[].concat(e),t.forEach(function(t){var a="";e.forEach(function(e,i){i>0&&(a+="/"),a+=t[e]},this),-1==i.indexOf(a)&&i.push(a)},this)),i},dimple.newSvg=function(t,e,i){return null==parent&&(parent="body"),d3.select(t).append("svg").attr("width",e).attr("height",i)}})(); \ No newline at end of file +var dimple={version:"1.0.0",plot:{},aggregateMethod:{}};(function(){"use strict";dimple.axis=function(t,e,i,a){this.chart=t,this.position=e,this.categoryFields=i,this.measure=a,this.hidden=!1,this.showPercent=!1,this.colors=null,this.overrideMin=null,this.overrideMax=null,this.shapes=null,this.showGridlines=null,this.gridlineShapes=null,this.titleShape=null,this._scale=null,this._min=0,this._max=0,this._previousOrigin=null,this._origin=null,this._draw=null,this._getFormat=function(){var t,e,i,a,r,s,n;return this.showPercent?t=d3.format("%"):null!==this.measure?(e=""+Math.floor(Math.abs(this._max),0),i=""+Math.floor(Math.abs(this._min),0),a=Math.max(i.length,e.length),a>3?(r=Math.min(Math.floor((a-1)/3),4),s="kmBT".substring(r-1,r),n=2>=a-3*r?1:0,t=function(t){return 0===t?0:d3.format(",."+n+"f")(t/Math.pow(1e3,r))+s}):(n=2>=a?1:0,t=d3.format(",."+n+"f"))):t=function(t){return t},t},this._hasCategories=function(){return null!=this.categoryFields&&void 0!=this.categoryFields&&this.categoryFields.length>0},this._hasMeasure=function(){return null!=this.measure&&void 0!=this.measure},this._update=function(e){if(this._min=this.showPercent&&-1>this._min?this._min=-1:this._min,this._max=this.showPercent&&this._max>1?this._max=1:this._max,this._min=null!=this.overrideMin?this.overrideMin:this._min,this._max=null!=this.overrideMax?this.overrideMax:this._max,this.position.length>0&&"x"==this.position[0]){if(null==this.measure||void 0==this.measure){var i=[];this.chart.data.forEach(function(t){-1==i.indexOf(t[this.categoryFields[0]])&&i.push(t[this.categoryFields[0]])},this),this._scale=d3.scale.ordinal().rangePoints([this.chart.x,this.chart.x+this.chart.width]).domain(i.concat([""]))}else this._scale=d3.scale.linear().range([this.chart.x,this.chart.x+this.chart.width]).domain([this._min,this._max]).nice();if(!this.hidden)switch(t._axisIndex(this,"x")){case 0:this._draw=d3.svg.axis().orient("bottom").scale(this._scale);break;case 1:this._draw=d3.svg.axis().orient("top").scale(this._scale);break;default:}}else if(this.position.length>0&&"y"==this.position[0]){if(null==this.measure||void 0==this.measure){var i=[];this.chart.data.forEach(function(t){-1==i.indexOf(t[this.categoryFields[0]])&&i.push(t[this.categoryFields[0]])},this),this._scale=d3.scale.ordinal().rangePoints([this.chart.y+this.chart.height,this.chart.y]).domain(i.concat([""]))}else this._scale=d3.scale.linear().range([this.chart.y+this.chart.height,this.chart.y]).domain([this._min,this._max]).nice();if(!this.hidden)switch(t._axisIndex(this,"y")){case 0:this._draw=d3.svg.axis().orient("left").scale(this._scale);break;case 1:this._draw=d3.svg.axis().orient("right").scale(this._scale);break;default:}}else this.position.length>0&&"z"==this.position[0]?this._scale=d3.scale.linear().range([this.chart.height/300,this.chart.height/10]).domain([this._min,this._max]):this.position.length>0&&"c"==this.position[0]&&(this._scale=d3.scale.linear().range([0,null==this.colors||1==this.colors.length?1:this.colors.length-1]).domain([this._min,this._max]));if((null==e||void 0==e||0==e)&&null!=this._scale&&null!=this._scale.ticks&&this._scale.ticks(10).length>0){var a=this._scale.ticks(10),r=a[1]-a[0],s=((this._max-this._min)%r).toFixed(0);0!=s&&(this._max=Math.ceil(this._max/r)*r,this._min=Math.floor(this._min/r)*r,this._update(!0))}var n=this._scale.copy()(0);return this._origin!=n&&(this._previousOrigin=null==this._origin?n:this._origin,this._origin=n),this}},dimple.chart=function(t,e){this.svg=t,this.x=.1*t[0][0].width.baseVal.value,this.y=.1*t[0][0].height.baseVal.value,this.width=.8*t[0][0].width.baseVal.value,this.height=.8*t[0][0].height.baseVal.value,this.data=e,this.noFormats=!1,this.axes=[],this.series=[],this.legends=[],this.storyboard=null,this.titleShape=null,this.shapes=null,this._assignedColors={},this._nextColor=0,this._axisIndex=function(t,e){var i=0,a=0;for(i=0;this.axes.length>i;i++){if(this.axes[i]==t)return a;(null==e||void 0==e||e[0]==this.axes[i].position[0])&&a++}return-1},this._getSeriesData=function(){null!==this.series&&void 0!==this.series&&this.series.forEach(function(t){var e=[],i=function(t,e){var i=[];return null!=t&&t._hasCategories()&&t.categoryFields.forEach(function(t){i.push(e[t])},this),i},a={x:!1,y:!1,z:!1,c:!1},r={x:[],y:[]};this.data.forEach(function(s){var n=-1,l=i(t.x,s),o=i(t.y,s),h=i(t.z,s),c=[];null==t.categoryFields||void 0==t.categoryFields||0==t.categoryFields.length?c=["All"]:1==t.categoryFields.length&&void 0==s[t.categoryFields[0]]?c=[t.categoryFields[0]]:t.categoryFields.forEach(function(t){c.push(s[t])},this);for(var u=c.join("/")+"_"+l.join("/")+"_"+o.join("/")+"_"+h.join("/"),d=0;e.length>d;d++)if(e[d].key==u){n=d;break}if(-1==n){var g={key:u,aggField:c,xField:l,xValue:null,xCount:0,yField:o,yValue:null,yCount:0,zField:h,zValue:null,zCount:0,cValue:0,cCount:0,x:0,y:0,xOffset:0,yOffset:0,width:0,height:0,cx:0,cy:0,xBound:0,yBound:0,xValueList:[],yValueList:[],zValueList:[],cValueList:[],fill:{},stroke:{}};e.push(g),n=e.length-1}var y=function(i,l,o){var h=!0;if(null!=o){var c=o.getFrameValue(),u="";o.categoryFields.forEach(function(t,e){e>0&&(u+="/"),u+=s[t],h=u==c},this)}if(null!=i&&void 0!=i&&null!=i.measure&&void 0!=i.measure&&h){var d=e[n];-1==d[i.position+"ValueList"].indexOf(s[i.measure])&&d[i.position+"ValueList"].push(s[i.measure]),isNaN(parseFloat(s[i.measure]))&&(a[i.position]=!0),d[i.position+"Value"]=t.aggregate(d[i.position+"Value"],d[i.position+"Count"],s[i.measure],1),d[i.position+"Count"]++}null!=i&&void 0!=i&&i._hasCategories()&&i.categoryFields.length>1&&void 0!=r[i.position]&&-1==r[i.position].indexOf(s[i.categoryFields[1]])&&r[i.position].push(s[i.categoryFields[1]])};y(t.x,this.data,this.storyboard),y(t.y,this.data,this.storyboard),y(t.z,this.data,this.storyboard),y(t.c,this.data,this.storyboard)},this);var s={x:[],y:[],z:[]},n={min:null,max:null};e.forEach(function(e){if(null!=t.x){1==a.x&&(e.xValue=e.xValueList.length);var i=(null==s.x[e.xField.join("/")]?0:s.x[e.xField.join("/")])+(t.y._hasMeasure()?Math.abs(e.yValue):0);s.x[e.xField.join("/")]=i}if(null!=t.y){1==a.y&&(e.yValue=e.yValueList.length);var i=(null==s.y[e.yField.join("/")]?0:s.y[e.yField.join("/")])+(t.x._hasMeasure()?Math.abs(e.xValue):0);s.y[e.yField.join("/")]=i}if(null!=t.z){1==a.z&&(e.zValue=e.zValueList.length);var i=(null==s.z[e.zField.join("/")]?0:s.z[e.zField.join("/")])+(t.z._hasMeasure()?Math.abs(e.zValue):0);s.z[e.zField.join("/")]=i}null!=t.c&&((null==n.min||e.cValuen.max)&&(n.max=e.cValue))},this),e.sort(function(t,e){return t.aggField!=e.aggField?t.aggField.join("/")0?h[o[o.length-1]]:0),o.push(d));var y=e[u+"Bound"]=e["c"+u]="x"!=u&&"y"!=u||!t.stacked?g:h[d];e[n]=g,e[u]=y-("x"==u&&g>=0||"y"==u&&0>=g?g:0)}else e[u]=e["c"+u]=e[u+"Field"][0],e[n]=1,void 0!=r[u]&&null!=r[u]&&r[u].length>=2&&(e[u+"Offset"]=r[u].indexOf(e[u+"Field"][1]),e[n]=1/r[u].length);else{var g=i.showPercent?e[u+"Value"]/s[a][e[a+"Field"].join("/")]:e[u+"Value"],d=e[a+"Field"].join("/")+(e[u+"Value"]>=0),f=l[u][d]=(null==l[u][d]||"z"==u?0:l[u][d])+g,y=e[u+"Bound"]=e["c"+u]="x"!=u&&"y"!=u||!t.stacked?g:f;e[n]=g,e[u]=y-("x"==u&&g>=0||"y"==u&&0>=g?g:0)}}};if(i(t.x,"y","width"),i(t.y,"x","height"),i(t.z,"z","r"),null!=t.c&&n.min!=n.max){var a,u;e.cValue=e.cValue>n.max?n.max:e.cValue1?(a=d3.rgb(t.c.colors[Math.floor(g)]),u=d3.rgb(t.c.colors[Math.ceil(g)])):(a=d3.rgb("white"),u=d3.rgb(this.getColor(e.aggField.slice(-1)[0]).fill)),a.r=Math.floor(a.r+(u.r-a.r)*y),a.g=Math.floor(a.g+(u.g-a.g)*y),a.b=Math.floor(a.b+(u.b-a.b)*y),e.fill=""+a,e.stroke=""+a.darker(.5)}},this),t._positionData=e},this)},this._registerEventHandlers=function(t){null!=t._eventHandlers&&t._eventHandlers.length>0&&t._eventHandlers.forEach(function(e){null!=e.handler&&"function"==typeof e.handler&&t.shapes.on(e.event,function(i){var a=new dimple.eventArgs;null!=t.chart.storyboard&&(a.frameValue=t.chart.storyboard.getFrameValue()),a.seriesValue=i.aggField,a.xValue=i.x,a.yValue=i.y,a.zValue=i.z,a.colorValue=i.cValue,a.seriesShapes=t.shapes,a.selectedShape=d3.select(this),e.handler(a)})},this)},this.addAxis=function(t,e,i){null!=e&&void 0!=e&&(e=[].concat(e));var a=new dimple.axis(this,t,e,i);return this.axes.push(a),a},this.addCategoryAxis=function(t,e){return this.addAxis(t,e,null)},this.addColorAxis=function(t,e){var i=this.addAxis("c",null,t);return i.colors=null==e||void 0==e?null:[].concat(e),i},this.addLegend=function(t,e,i,a,r,s){s=null==s||void 0==s?this.series:[].concat(s),r=null==r||void 0==r?"left":r;var n=new dimple.legend(this,t,e,i,a,r,s);return this.legends.push(n),n},this.addMeasureAxis=function(t,e){return this.addAxis(t,null,e)},this.addPctAxis=function(t,e){var i=this.addMeasureAxis(t,e);return i.showPercent=!0,i},this.addSeries=function(t,e,i){null==i&&(i=this.axes),null==e&&(e=dimple.plot.bubble);var a=null,r=null,s=null,n=null;i.forEach(function(t){null!=t&&e.supportedAxes.indexOf(t.position)>-1&&(null==a&&"x"==t.position[0]?a=t:null==r&&"y"==t.position[0]?r=t:null==s&&"z"==t.position[0]?s=t:null==n&&"c"==t.position[0]&&(n=t))},this),null!=t&&void 0!=t&&(t=[].concat(t));var l=new dimple.series(this,t,a,r,s,n,e,dimple.aggregateMethod.sum,e.stacked);return this.series.push(l),l},this.assignColor=function(t,e,i,a){return this._assignedColors[t]=new dimple.color(e,i,a),this._assignedColors[t]},this.defaultColors=[new dimple.color("#80B1D3"),new dimple.color("#FB8072"),new dimple.color("#FDB462"),new dimple.color("#B3DE69"),new dimple.color("#FFED6F"),new dimple.color("#BC80BD"),new dimple.color("#8DD3C7"),new dimple.color("#CCEBC5"),new dimple.color("#FFFFB3"),new dimple.color("#BEBADA"),new dimple.color("#FCCDE5"),new dimple.color("#D9D9D9")],this.draw=function(t){t=null==t||void 0==t?0:t;var e=null,i=null;this._getSeriesData(),this.axes.forEach(function(t){if(t._min=0,t._max=0,null!=t.measure&&void 0!=t.measure){var a=!1;this.series.forEach(function(e){if(e[t.position]==t){var i=e._axisBounds(t.position);t._min>i.min&&(t._min=i.min),t._maxe[t.measure]&&(t._min=e[t.measure]),t._max0&&(s!=e||null!=i.categoryFields&&0!=i.categoryFields.length||c(s.shapes.selectAll(".axis text")).attr("y",this.y+this.height-i._scale(0)+9),s!=i||null!=e.categoryFields&&0!=e.categoryFields.length||c(s.shapes.selectAll(".axis text")).attr("x",-1*(e._scale(0)-this.x)-9))),this.noFormats||(c(s.shapes.selectAll(".axis text")).style("font-family","sans-serif").style("font-size",(this.height/35>10?this.height/35:10)+"px"),c(s.shapes.selectAll(".axis path, .axis line")).style("fill","none").style("stroke","black").style("shape-rendering","crispEdges"),null!=s.gridlineShapes&&c(s.gridlineShapes.selectAll(".gridlines line")).style("fill","none").style("stroke","lightgray").style("opacity",.8));var u=!1;if(null==s.measure||void 0==s.measure)if(s==e){var d=0;s.shapes.selectAll(".axis text").each(function(){var t=this.getComputedTextLength();d=t>d?t:d}),d>this.width/s._max&&(u=!0,this.width/s._max/2,s.shapes.selectAll(".axis text").style("text-anchor","start").each(function(){var t=this.getBBox();d3.select(this).attr("transform","rotate(90,"+t.x+","+(t.y+t.height/2)+") translate(-5, 0)")}))}else if("x"==s.position){var d=0;s.shapes.selectAll(".axis text").each(function(){var t=this.getComputedTextLength();d=t>d?t:d}),d>this.width/s._max&&(this.width/s._max/2,s.shapes.selectAll(".axis text").style("text-anchor","end").each(function(){var t=this.getBBox();d3.select(this).attr("transform","rotate(90,"+(t.x+t.width)+","+(t.y+t.height/2)+") translate(5, 0)")}))}if(null==s.titleShape&&null!=s.shapes&&null!=s.shapes.node().firstChild){var g={l:null,t:null,r:null,b:null};s.shapes.selectAll(".axis text").each(function(){var t=this.getBBox();g.l=null==g.l||t.xg.r?t.x+t.width:g.r,g.b=u?null==g.b||t.y+t.width>g.b?t.y+t.width:g.b:null==g.b||t.y+t.height>g.b?t.y+t.height:g.b});var y=0,f=0,p="";"x"==s.position?(f=s==e?this.y+this.height+g.b+10:this.y+g.l+g.t-5,y=this.x+this.width/2):"y"==s.position&&(y=s==i?this.x+g.l-10:this.x+this.width+g.r+10,f=this.y+this.height/2,p="rotate(270, "+y+", "+f+")"),s.titleShape=this.svg.append("text").attr("class","axis title");var x=this;s.titleShape.attr("x",y).attr("y",f).attr("text-anchor","middle").attr("transform",p).text(null==s.categoryFields||void 0==s.categoryFields||0==s.categoryFields.length?s.measure:s.categoryFields.join("/")).each(function(){x.noFormats||d3.select(this).style("font-family","sans-serif").style("font-size",(x.height/35>10?x.height/35:10)+"px")}),s==e?s.titleShape.each(function(){d3.select(this).attr("y",f+this.getBBox().height/1.65)}):s==i&&s.titleShape.each(function(){d3.select(this).attr("x",y+this.getBBox().height/1.65)})}},this),this.series.forEach(function(e){e.plot.draw(this,e,t),this._registerEventHandlers(e)},this),this.legends.forEach(function(e){e._draw(t)},this),null!=this.storyboard&&void 0!=this.storyboard&&(this.storyboard._drawText(),this.storyboard.autoplay&&this.storyboard.startAnimation()),this},this.getColor=function(t){return(null==this._assignedColors[t]||void 0==this._assignedColors[t])&&(this._assignedColors[t]=this.defaultColors[this._nextColor],this._nextColor=(this._nextColor+1)%this.defaultColors.length),this._assignedColors[t]},this.setBounds=function(t,e,i,a){return this.x=t,this.y=e,this.width=i,this.height=a,this.axes.forEach(function(t){t._update()},this),this},this.setStoryboard=function(t,e){return this.storyboard=new dimple.storyboard(this,t),null!=e&&void 0!=e&&(this.storyboard.onTick=e),this.storyboard}},dimple.color=function(t,e,i){this.fill=t,this.stroke=null==e||void 0==e?""+d3.rgb(t).darker(.5):e,this.opacity=null==i||void 0==i?.8:i},dimple.eventArgs=function(){this.seriesValue=null,this.xValue=null,this.yValue=null,this.zValue=null,this.colorValue=null,this.frameValue=null,this.seriesShapes=null,this.selectedShape=null},dimple.legend=function(t,i,a,r,s,n,l){this.chart=t,this.series=l,this.x=i,this.y=a,this.width=r,this.height=s,this.horizontalAlign=n,this.shapes=null,this._draw=function(i){var a=this._getEntries();(null!=this.shapes||void 0!=this.shapes)&&this.shapes.transition().duration(.2*i).attr("opacity",0).remove();var r=0,s=0,n=0,l=0,o=15,h=9,c=this,u=t.svg.selectAll(".dontSelectAny").data(a).enter().append("g").attr("class","legend").attr("opacity",0);u.append("text").attr("id",function(t){return"legend_"+t.key}).attr("class","legendText").text(function(t){return t.key}).call(function(){t.noFormats||this.style("font-family","sans-serif").style("font-size",(t.height/35>10?t.height/35:10)+"px").style("shape-rendering","crispEdges")}).each(function(){var t=this.getBBox();t.width>r&&(r=t.width),t.height>s&&(s=t.height)}),u.append("rect").attr("class","legendKey").attr("height",h).attr("width",o),s=(h>s?h:s)+2,r+=o+20,u.each(function(t){n+r>c.width&&(n=0,l+=s),l>c.height?d3.select(this).remove():(d3.select(this).select("text").attr("x","left"==c.horizontalAlign?c.x+o+5+n:c.x+(c.width-n-r)+o+5).attr("y",function(){return c.y+l+this.getBBox().height/1.65}).attr("width",c.width).attr("height",c.height),d3.select(this).select("rect").attr("class","legend legendKey").attr("x","left"==c.horizontalAlign?c.x+n:c.x+(c.width-n-r)).attr("y",c.y+l).attr("height",h).attr("width",o).style("fill",function(){return e.fill(t,c.chart,t.series)}).style("stroke",function(){return e.stroke(t,c.chart,t.series)}).style("opacity",function(){return e.opacity(t,c.chart,t.series)}).style("shape-rendering","crispEdges"),n+=r)}),u.transition().delay(.2*i).duration(.8*i).attr("opacity",1),this.shapes=u},this._getEntries=function(){var t=[];return null!=this.series&&void 0!=this.series&&this.series.forEach(function(e){var i=e._positionData;i.forEach(function(i){for(var a=-1,r=0;t.length>r;r++)if(t[r].key==i.aggField.slice(-1)[0]){a=r;break}-1==a&&(t.push({key:i.aggField.slice(-1)[0],fill:i.fill,stroke:i.stroke,series:e,aggField:i.aggField}),a=t.length-1)})},this),t}},dimple.series=function(t,e,i,a,r,s,n,l,o){this.chart=t,this.x=i,this.y=a,this.z=r,this.c=s,this.plot=n,this.categoryFields=e,this.aggregate=l,this.stacked=o,this.barGap=.2,this.clusterBarGap=.1,this.lineWeight=2,this.lineMarkers=!1,this._eventHandlers=[],this._positionData=[],this._axisBounds=function(t){var e={min:0,max:0},n=null,l=null,o=[],h=0;"x"==t[0]?(n=i,l=a):"y"==t[0]?(n=a,l=i):"z"==t[0]?n=r:"c"==t[0]&&(n=s);var c=this._positionData;if(n.showPercent)c.forEach(function(t){t[n.position+"Bound"]e.max&&(e.max=t[n.position+"Bound"])},this);else if(null==l||null==l.categoryFields||0==l.categoryFields.length)c.forEach(function(t){!this.stacked||"x"!=n.position&&"y"!=n.position?(t[n.position+"Value"]e.max&&(e.max=t[n.position+"Value"])):0>t[n.position+"Value"]?e.min=e.min+t[n.position+"Value"]:e.max=e.max+t[n.position+"Value"]},this);else{var u=n.position+"Value",d=l.position+"Field",g=[];c.forEach(function(t){var e=t[d].join("/"),i=g.indexOf(e);-1==i&&(g.push(e),i=g.length-1),void 0==o[i]&&(o[i]={min:0,max:0},i>=h&&(h=i+1)),this.stacked?0>t[u]?o[i].min=o[i].min+t[u]:o[i].max=o[i].max+t[u]:(t[u]o[i].max&&(o[i].max=t[u]))},this),o.forEach(function(t){void 0!=t&&(t.mine.max&&(e.max=t.max))},this)}return e},this._dropLineOrigin=function(){var t=0,e=0,i={x:null,y:null},a={x:null,y:null};return this.chart.axes.forEach(function(t){"x"==t.position&&null===a.x?a.x=t._origin:"y"==t.position&&null===a.y&&(a.y=t._origin)},this),this.chart.axes.forEach(function(r){"x"!=r.position||this.x.hidden?"y"!=r.position||this.y.hidden||(r===this.y&&(0==e?i.x=a.x:1==e&&(i.x=this.chart.x+this.chart.width)),e++):(r===this.x&&(0==t?i.y=a.y:1==t&&(i.y=this.chart.y)),t++)},this),i},this.addEventHandler=function(t,e){this._eventHandlers.push({event:t,handler:e})}},dimple.storyboard=function(t,e){null!=e&&void 0!=e&&(e=[].concat(e)),this.chart=t,this.categoryFields=e,this.autoplay=!0,this.frameDuration=3e3,this.storyLabel=null,this.onTick=null,this._frame=0,this._animationTimer=null,this._categories=[],this._cachedCategoryFields=[],this._drawText=function(t){if(null==this.storyLabel||void 0==this.storyLabel){var e=this;this.storyLabel=this.chart.svg.append("text").attr("x",this.chart.x+.01*this.chart.width).attr("y",this.chart.y+1.25*(this.chart.height/35>10?this.chart.height/35:10)).call(function(){e.noFormats||this.style("font-family","sans-serif").style("font-size",(e.height/35>10?e.height/35:10)+"px")})}this.storyLabel.transition().duration(.2*t).attr("opacity",0),this.storyLabel.transition().delay(.2*t).text(this.categoryFields.join("\\")+": "+this.getFrameValue()).transition().duration(.8*t).attr("opacity",1)},this._getCategories=function(){return this._categoryFields!=this._cachedCategoryFields&&(this._categories=[],this.chart.data.forEach(function(t){var e=-1;if(null!=this.categoryFields){var i="";this.categoryFields.forEach(function(e,a){a>0&&(i+="/"),i+=t[e]},this),e=this._categories.indexOf(i),-1==e&&(this._categories.push(i),e=this._categories.length-1)}},this),this._cachedCategoryFields=this._categoryFields),this._categories},this._goToFrameIndex=function(t){this._frame=t%this._getCategories().length,this.chart.draw(this.frameDuration/2)},this.getFrameValue=function(){return this._frame>=0&&this._getCategories().length>this._frame?this._getCategories()[this._frame]:null},this.goToFrame=function(t){if(this._getCategories().length>0){var e=this._getCategories().indexOf(t);this._goToFrameIndex(e)}},this.pauseAnimation=function(){null!=this._animationTimer&&(clearInterval(this._animationTimer),this._animationTimer=null)},this.startAnimation=function(){null==this._animationTimer&&(null!=this.onTick&&this.onTick(this.getFrameValue()),this._animationTimer=setInterval(function(t){return function(){t._goToFrameIndex(t._frame+1),null!=t.onTick&&t.onTick(t.getFrameValue()),t._drawText(t.frameDuration/2)}}(this),this.frameDuration))},this.stopAnimation=function(){null!=this._animationTimer&&(clearInterval(this._animationTimer),this._animationTimer=null,this._frame=0)}},dimple.aggregateMethod.avg=function(t,e,i,a){return t=null==t||void 0==t?0:t,i=null==i||void 0==i?0:i,(parseFloat(t)*parseFloat(e)+parseFloat(i)*parseFloat(a))/(parseFloat(e)+parseFloat(a))},dimple.aggregateMethod.count=function(t,e,i,a){return parseFloat(e)+parseFloat(a)},dimple.aggregateMethod.max=function(t,e,i){return parseFloat(t)>parseFloat(i)?parseFloat(t):parseFloat(i)},dimple.aggregateMethod.min=function(t,e,i){return null==t?parseFloat(i):parseFloat(t)=0;l--){var o=r[l],u={cx:0,cy:0,height:0,width:0,xOffset:0,yOffset:0};if(a.x._hasCategories()){if(u.cx=o.cx,u.width=o.width,u.xOffset=o.xOffset,void 0==c[o.xField])c[o.xField]=[];else{var d=0;c[o.xField].forEach(function(t){(o.cy>=0&&t>=0||0>=o.cy&&0>=t)&&Math.abs(t)<=Math.abs(o.cy)&&Math.abs(t)>Math.abs(d)&&(d=t)},this),u.cy=d}s.push(u),c[o.xField].push(o.cy)}else if(a.y._hasCategories()){if(u.cy=o.cy,u.height=o.height,u.yOffset=o.yOffset,void 0==c[o.yField])c[o.yField]=[];else{var d=0;c[o.yField].forEach(function(t){(o.cx>=0&&t>=0||0>=o.cx&&0>=t)&&Math.abs(t)<=Math.abs(o.cx)&&Math.abs(t)>Math.abs(d)&&(d=t)},this),u.cx=d}s.push(u),c[o.yField].push(o.cx)}}return h(r.concat(s).concat(r[0]))}).call(function(){i.noFormats||this.attr("fill",function(t){return o?"url(#fill-area-gradient-"+t.replace(" ","")+")":i.getColor(t).fill}).attr("stroke",function(t){return o?"url(#stroke-area-gradient-"+t.replace(" ","")+")":i.getColor(t).stroke}).attr("stroke-width",a.lineWeight)});var u=i.svg.selectAll(".markers").data(n).enter();a.lineMarkers&&u.append("circle").transition().duration(r).attr("cx",function(t){return e.cx(t,i,a)}).attr("cy",function(t){return e.cy(t,i,a)}).attr("r",2+a.lineWeight).attr("fill","white").attr("stroke","none"),u.append("circle").on("mouseover",function(t){s.enterEventHandler(t,this,i,a,r)}).on("mouseleave",function(t){s.leaveEventHandler(t,this,i,a,r)}).transition().duration(r).attr("cx",function(t){return e.cx(t,i,a)}).attr("cy",function(t){return e.cy(t,i,a)}).attr("r",2+a.lineWeight).attr("opacity",function(t){return a.lineMarkers?i.getColor(t).opacity:0}).call(function(){i.noFormats||this.attr("fill","white").style("stroke-width",a.lineWeight).attr("stroke",function(t){return e.stroke(t,i,a)})})},enterEventHandler:function(t,i,a,r){var s=5,n=10,l=750,o=a.svg,h=d3.select(i),c=parseFloat(h.attr("cx")),u=parseFloat(h.attr("cy")),d=parseFloat(h.attr("r")),g=e.opacity(t,a,r),y=e.fill(t,a,r),f=r._dropLineOrigin();h.style("opacity",1);var p=d3.rgb(d3.rgb(y).r+.6*(255-d3.rgb(y).r),d3.rgb(y).g+.6*(255-d3.rgb(y).g),d3.rgb(y).b+.6*(255-d3.rgb(y).b)),x=d3.rgb(d3.rgb(y).r+.8*(255-d3.rgb(y).r),d3.rgb(y).g+.8*(255-d3.rgb(y).g),d3.rgb(y).b+.8*(255-d3.rgb(y).b)),m=o.append("g").attr("class","hoverShapes");m.append("circle").attr("cx",c).attr("cy",u).attr("r",d).attr("opacity",0).style("fill","none").style("stroke",y).style("stroke-width",1).transition().duration(l/2).ease("linear").attr("opacity",1).attr("r",d+4).style("stroke-width",2),null!==f.x&&m.append("line").attr("x1",c).attr("y1",r.y._origin>u?u+d+4:u-d-4).attr("x2",c).attr("y2",r.y._origin>u?u+d+4:u-d-4).style("fill","none").style("stroke",y).style("stroke-width",2).style("stroke-dasharray","3, 3").style("opacity",g).transition().delay(l/2).duration(l/2).ease("linear").attr("y2",r.y._origin),m.append("line").attr("x1",r.x._origin>c?c+d+4:c-d-4).attr("y1",u).attr("x2",r.x._origin>c?c+d+4:c-d-4).attr("y2",u).style("fill","none").style("stroke",y).style("stroke-width",2).style("stroke-dasharray","3, 3").style("opacity",g).transition().delay(l/2).duration(l/2).ease("linear").attr("x2",r.x._origin);var v=m.append("g"),F=v.append("rect"),_=[];null!=r.categoryFields&&void 0!=r.categoryFields&&r.categoryFields.length>0&&r.categoryFields.forEach(function(e,i){_.push(e+(t.aggField!=e?": "+t.aggField[i]:""))},this),r.x._hasCategories()?r.x.categoryFields.forEach(function(e,i){_.push(e+(t.xField!=e?": "+t.xField[i]:""))},this):_.push(r.x.measure+": "+r.x._getFormat()(t.cx)),r.y._hasCategories()?r.y.categoryFields.forEach(function(e,i){_.push(e+(t.yField!=e?": "+t.yField[i]:""))},this):_.push(r.y.measure+":"+r.y._getFormat()(t.cy)),null!=r.z&&void 0!=r.z&&_.push(r.z.measure+": "+r.z._getFormat()(t.zValue)),null!=r.c&&void 0!=r.c&&_.push(r.c.measure+": "+r.c._getFormat()(t.cValue)),_=_.filter(function(t,e){return _.indexOf(t)==e}),v.selectAll(".textHoverShapes").data(_).enter().append("text").text(function(t){return t}).style("font-family","sans-serif").style("font-size","10px");var w=0,b=0,k=0;v.each(function(){b=this.getBBox().width>b?this.getBBox().width:b,k=this.getBBox().width>k?this.getBBox().height:k}),v.selectAll("text").attr("x",0).attr("y",function(){return w+=this.getBBox().height,w-this.getBBox().height/2}),F.attr("x",-s).attr("y",-s).attr("height",Math.floor(w+s)-.5).attr("width",b+2*s).attr("rx",5).attr("ry",5).style("fill",x).style("stroke",p).style("stroke-width",2).style("opacity",.95);var C=c+d+s+n+b>parseFloat(o.attr("width"));v.attr("transform","translate("+(C?c-(d+s+n+b):c+d+s+n)+" , "+(u-(w-(k-s))/2)+")")},leaveEventHandler:function(t,i,a,r){d3.select(i).style("opacity",r.lineMarkers?e.opacity(t,a,r):0),a.svg.selectAll(".hoverShapes").remove()}},dimple.plot.bar={stacked:!0,supportedAxes:["x","y","c"],draw:function(t,i,a){var r=this;t.svg.selectAll(".hoverShapes").transition().duration(a/4).style("opacity",0).remove();var s=i._positionData,n=null,l="series"+t.series.indexOf(i);n=null==i.shapes||void 0==i.shapes?t.svg.selectAll("."+l).data(s):i.shapes.data(s,function(t){return t.key}),n.enter().append("rect").attr("id",function(t){return t.key}).attr("class",function(t){return l+" bar "+t.aggField.join(" ")+" "+t.xField.join(" ")+" "+t.yField.join(" ")}).attr("x",function(a){return e.x(a,t,i)}).attr("y",function(a){return e.y(a,t,i)}).attr("width",function(a){return null!=a.xField&&a.xField.length>0?e.width(a,t,i):0}).attr("height",function(a){return null!=a.yField&&a.yField.length>0?e.height(a,t,i):0}).attr("opacity",function(a){return e.opacity(a,t,i)}).on("mouseover",function(e){r.enterEventHandler(e,this,t,i,a)}).on("mouseleave",function(e){r.leaveEventHandler(e,this,t,i,a)}).call(function(){t.noFormats||this.attr("fill",function(a){return e.fill(a,t,i)}).attr("stroke",function(a){return e.stroke(a,t,i)})}),n.transition().duration(a).attr("x",function(a){return e.x(a,t,i)}).attr("y",function(a){return e.y(a,t,i)}).attr("width",function(a){return e.width(a,t,i)}).attr("height",function(a){return e.height(a,t,i)}).call(function(){t.noFormats||this.attr("fill",function(a){return e.fill(a,t,i)}).attr("stroke",function(a){return e.stroke(a,t,i)})}),n.exit().transition().duration(a).attr("x",function(a){return e.x(a,t,i)}).attr("y",function(a){return e.y(a,t,i)}).attr("width",function(a){return e.width(a,t,i)}).attr("height",function(a){return e.height(a,t,i)}).each("end",function(){this.remove()}),i.shapes=n},enterEventHandler:function(t,e,i,a){var r=5,s=10,n=750,l=i.svg,o=d3.select(e),h=parseFloat(o.attr("x")),c=parseFloat(o.attr("y")),u=parseFloat(o.attr("width")),d=parseFloat(o.attr("height")),g=o.attr("opacity"),y=o.attr("fill"),f=a._dropLineOrigin(),p=d3.rgb(d3.rgb(y).r+.6*(255-d3.rgb(y).r),d3.rgb(y).g+.6*(255-d3.rgb(y).g),d3.rgb(y).b+.6*(255-d3.rgb(y).b)),x=d3.rgb(d3.rgb(y).r+.8*(255-d3.rgb(y).r),d3.rgb(y).g+.8*(255-d3.rgb(y).g),d3.rgb(y).b+.8*(255-d3.rgb(y).b)),m=l.append("g").attr("class","hoverShapes");a.x._hasCategories()||null===f.y||m.append("line").attr("x1",a.x._origin>h?h+1:h+u-1).attr("y1",f.y>c?c+d:c).attr("x2",a.x._origin>h?h+1:h+u-1).attr("y2",f.y>c?c+d:c).style("fill","none").style("stroke",y).style("stroke-width",2).style("stroke-dasharray","3, 3").style("opacity",g).transition().delay(n/2).duration(n/2).ease("linear").attr("y2",f.y),a.y._hasCategories()||null===f.x||m.append("line").attr("x1",f.x>h?h+u:h).attr("y1",a.y._origin>c?c+1:c+d-1).attr("x2",f.x>h?h+u:h).attr("y2",a.y._origin>c?c+1:c+d-1).style("fill","none").style("stroke",y).style("stroke-width",2).style("stroke-dasharray","3, 3").style("opacity",g).transition().delay(n/2).duration(n/2).ease("linear").attr("x2",f.x); +var v=m.append("g"),F=v.append("rect"),_=[];null!=a.categoryFields&&void 0!=a.categoryFields&&a.categoryFields.length>0&&a.categoryFields.forEach(function(e,i){_.push(e+(t.aggField!=e?": "+t.aggField[i]:""))},this),a.x._hasCategories()?a.x.categoryFields.forEach(function(e,i){_.push(e+(t.xField!=e?": "+t.xField[i]:""))},this):_.push(a.x.measure+": "+a.x._getFormat()(t.width)),a.y._hasCategories()?a.y.categoryFields.forEach(function(e,i){_.push(e+(t.yField!=e?": "+t.yField[i]:""))},this):_.push(a.y.measure+":"+a.y._getFormat()(t.height)),null!=a.c&&void 0!=a.c&&_.push(a.c.measure+": "+a.c._getFormat()(a.c.showPercent?t.cPct:t.cValue)),_=_.filter(function(t,e){return _.indexOf(t)==e}),v.selectAll(".textHoverShapes").data(_).enter().append("text").text(function(t){return t}).style("font-family","sans-serif").style("font-size","10px");var w=0,b=0,k=0;v.each(function(){b=this.getBBox().width>b?this.getBBox().width:b,k=this.getBBox().width>k?this.getBBox().height:k}),v.selectAll("text").attr("x",0).attr("y",function(){return w+=this.getBBox().height,w-this.getBBox().height/2}),F.attr("x",-r).attr("y",-r).attr("height",Math.floor(w+r)-.5).attr("width",b+2*r).attr("rx",5).attr("ry",5).style("fill",x).style("stroke",p).style("stroke-width",2).style("opacity",.95),parseFloat(l.attr("width"))>h+u+r+s+b?v.attr("transform","translate("+(h+u+r+s)+" , "+(c+d/2-(w-(k-r))/2)+")"):h-(r+s+b)>0?v.attr("transform","translate("+(h-(r+s+b))+" , "+(c+d/2-(w-(k-r))/2)+")"):parseFloat(l.attr("height"))>c+d+w+s+r?v.attr("transform","translate("+(h+u/2-(2*r+b)/2)+" , "+(c+d+2*r)+")"):v.attr("transform","translate("+(h+u/2-(2*r+b)/2)+" , "+(c-w-(k-r))+")")},leaveEventHandler:function(t,e,i){i.svg.selectAll(".hoverShapes").remove()}},dimple.plot.bubble={stacked:!1,supportedAxes:["x","y","z","c"],draw:function(t,i,a){var r=this;t.svg.selectAll(".hoverShapes").transition().duration(a/4).style("opacity",0).remove();var s=i._positionData,n=null,l="series"+t.series.indexOf(i);n=null==i.shapes||void 0==i.shapes?t.svg.selectAll("."+l).data(s):i.shapes.data(s,function(t){return t.key}),n.enter().append("circle").attr("id",function(t){return t.key}).attr("class",function(t){return l+" bubble "+t.aggField.join(" ")+" "+t.xField.join(" ")+" "+t.yField.join(" ")+" "+t.zField.join(" ")}).attr("cx",function(){return i.x._previousOrigin}).attr("cy",function(){return i.y._previousOrigin}).attr("r",0).attr("opacity",function(a){return e.opacity(a,t,i)}).on("mouseover",function(e){r.enterEventHandler(e,this,t,i,a)}).on("mouseleave",function(e){r.leaveEventHandler(e,this,t,i,a)}).call(function(){t.noFormats||this.attr("fill",function(a){return e.fill(a,t,i)}).attr("stroke",function(a){return e.stroke(a,t,i)})}),n.transition().duration(a).attr("cx",function(a){return e.cx(a,t,i)}).attr("cy",function(a){return e.cy(a,t,i)}).attr("r",function(a){return e.r(a,t,i)}).call(function(){t.noFormats||this.attr("fill",function(a){return e.fill(a,t,i)}).attr("stroke",function(a){return e.stroke(a,t,i)})}),n.exit().transition().duration(a).attr("r",0).attr("cx",function(){return i.x._origin}).attr("cy",function(){return i.y._origin}).each("end",function(){this.remove()}),i.shapes=n},enterEventHandler:function(t,e,i,a){var r=5,s=10,n=750,l=i.svg,o=d3.select(e),h=parseFloat(o.attr("cx")),c=parseFloat(o.attr("cy")),u=parseFloat(o.attr("r")),d=o.attr("opacity"),g=o.attr("fill"),y=a._dropLineOrigin(),f=d3.rgb(d3.rgb(g).r+.6*(255-d3.rgb(g).r),d3.rgb(g).g+.6*(255-d3.rgb(g).g),d3.rgb(g).b+.6*(255-d3.rgb(g).b)),p=d3.rgb(d3.rgb(g).r+.8*(255-d3.rgb(g).r),d3.rgb(g).g+.8*(255-d3.rgb(g).g),d3.rgb(g).b+.8*(255-d3.rgb(g).b)),x=l.append("g").attr("class","hoverShapes");x.append("circle").attr("cx",h).attr("cy",c).attr("r",u).attr("opacity",0).style("fill","none").style("stroke",g).style("stroke-width",1).transition().duration(n/2).ease("linear").attr("opacity",1).attr("r",u+4).style("stroke-width",2),null!==y.y&&x.append("line").attr("x1",h).attr("y1",y.y>c?c+u+4:c-u-4).attr("x2",h).attr("y2",y.y>c?c+u+4:c-u-4).style("fill","none").style("stroke",g).style("stroke-width",2).style("stroke-dasharray","3, 3").style("opacity",d).transition().delay(n/2).duration(n/2).ease("linear").attr("y2",y.y),null!==y.x&&x.append("line").attr("x1",y.x>h?h+u+4:h-u-4).attr("y1",c).attr("x2",y.x>h?h+u+4:h-u-4).attr("y2",c).style("fill","none").style("stroke",g).style("stroke-width",2).style("stroke-dasharray","3, 3").style("opacity",d).transition().delay(n/2).duration(n/2).ease("linear").attr("x2",y.x);var m=x.append("g"),v=m.append("rect"),F=[];null!=a.categoryFields&&void 0!=a.categoryFields&&a.categoryFields.length>0&&a.categoryFields.forEach(function(e,i){F.push(e+(t.aggField!=e?": "+t.aggField[i]:""))},this),a.x._hasCategories()?a.x.categoryFields.forEach(function(e,i){F.push(e+(t.xField!=e?": "+t.xField[i]:""))},this):F.push(a.x.measure+": "+a.x._getFormat()(t.cx)),a.y._hasCategories()?a.y.categoryFields.forEach(function(e,i){F.push(e+(t.yField!=e?": "+t.yField[i]:""))},this):F.push(a.y.measure+":"+a.y._getFormat()(t.cy)),null!=a.z&&void 0!=a.z&&F.push(a.z.measure+": "+a.z._getFormat()(t.zValue)),null!=a.c&&void 0!=a.c&&F.push(a.c.measure+": "+a.c._getFormat()(t.cValue)),F=F.filter(function(t,e){return F.indexOf(t)==e}),m.selectAll(".textHoverShapes").data(F).enter().append("text").text(function(t){return t}).style("font-family","sans-serif").style("font-size","10px");var _=0,w=0,b=0;m.each(function(){w=this.getBBox().width>w?this.getBBox().width:w,b=this.getBBox().width>b?this.getBBox().height:b}),m.selectAll("text").attr("x",0).attr("y",function(){return _+=this.getBBox().height,_-this.getBBox().height/2}),v.attr("x",-r).attr("y",-r).attr("height",Math.floor(_+r)-.5).attr("width",w+2*r).attr("rx",5).attr("ry",5).style("fill",p).style("stroke",f).style("stroke-width",2).style("opacity",.95);var k=h+u+r+s+w>parseFloat(l.attr("width"));m.attr("transform","translate("+(k?h-(u+r+s+w):h+u+r+s)+" , "+(c-(_-(b-r))/2)+")")},leaveEventHandler:function(t,e,i){i.svg.selectAll(".hoverShapes").remove()}},dimple.plot.line={stacked:!1,supportedAxes:["x","y","c"],draw:function(i,a,r){var s=this,n=a._positionData,l=[],o=[],h=1;(a.x._hasCategories()||a.y._hasCategories())&&(h=0),n.forEach(function(t){for(var e=[],i=!1,a=h;t.aggField.length>a;a++)e.push(t.aggField[a]);o.forEach(function(t){i=i||t.join("/")==e.join("/")},this),i||o.push(e)},this);var c=!1;null!=a.c&&void 0!=a.c&&(a.x._hasCategories()&&a.y._hasMeasure()||a.y._hasCategories()&&a.x._hasMeasure())&&(c=!0,o.forEach(function(e){t(e,"fill-line-gradient-"+e.replace(" ",""),a.x._hasCategories()?a.x:a.y,n,i,r,"fill")},this));var u=d3.svg.line().x(function(t){return e.cx(t,i,a)}).y(function(t){return e.cy(t,i,a)});(null==a.shapes||void 0==a.shapes)&&(a.shapes=i.svg.selectAll(".line").data(o).enter().append("svg:path").attr("opacity",function(t){return i.getColor(t).opacity})),a.shapes.data(o).transition().duration(r).attr("class",function(t){return"series line "+t.join("/").replace(" ","")}).attr("d",function(t){var r=[];return n.forEach(function(e){for(var i=!0,a=h;e.aggField.length>a;a++)i=i&&t[a-h]==e.aggField[a];i&&r.push(e)},this),r.sort(function(t,r){return a.x._hasCategories()?e.cx(t,i,a)u?u+d+4:u-d-4).attr("x2",c).attr("y2",f.y>u?u+d+4:u-d-4).style("fill","none").style("stroke",y).style("stroke-width",2).style("stroke-dasharray","3, 3").style("opacity",g).transition().delay(l/2).duration(l/2).ease("linear").attr("y2",f.y),null!==f.x&&m.append("line").attr("x1",f.x>c?c+d+4:c-d-4).attr("y1",u).attr("x2",f.x>c?c+d+4:c-d-4).attr("y2",u).style("fill","none").style("stroke",y).style("stroke-width",2).style("stroke-dasharray","3, 3").style("opacity",g).transition().delay(l/2).duration(l/2).ease("linear").attr("x2",f.x);var v=m.append("g"),F=v.append("rect"),_=[];null!=r.categoryFields&&void 0!=r.categoryFields&&r.categoryFields.length>0&&r.categoryFields.forEach(function(e,i){_.push(e+(t.aggField!=e?": "+t.aggField[i]:""))},this),r.x._hasCategories()?r.x.categoryFields.forEach(function(e,i){_.push(e+(t.xField!=e?": "+t.xField[i]:""))},this):_.push(r.x.measure+": "+r.x._getFormat()(t.cx)),r.y._hasCategories()?r.y.categoryFields.forEach(function(e,i){_.push(e+(t.yField!=e?": "+t.yField[i]:""))},this):_.push(r.y.measure+": "+r.y._getFormat()(t.cy)),null!=r.z&&void 0!=r.z&&_.push(r.z.measure+": "+r.z._getFormat()(t.zValue)),null!=r.c&&void 0!=r.c&&_.push(r.c.measure+": "+r.c._getFormat()(t.cValue)),_=_.filter(function(t,e){return _.indexOf(t)==e}),v.selectAll(".textHoverShapes").data(_).enter().append("text").text(function(t){return t}).style("font-family","sans-serif").style("font-size","10px");var w=0,b=0,k=0;v.each(function(){b=this.getBBox().width>b?this.getBBox().width:b,k=this.getBBox().width>k?this.getBBox().height:k}),v.selectAll("text").attr("x",0).attr("y",function(){return w+=this.getBBox().height,w-this.getBBox().height/2}),F.attr("x",-s).attr("y",-s).attr("height",Math.floor(w+s)-.5).attr("width",b+2*s).attr("rx",5).attr("ry",5).style("fill",x).style("stroke",p).style("stroke-width",2).style("opacity",.95);var C=c+d+s+n+b>parseFloat(o.attr("width"));v.attr("transform","translate("+(C?c-(d+s+n+b):c+d+s+n)+" , "+(u-(w-(k-s))/2)+")")},leaveEventHandler:function(t,i,a,r){d3.select(i).style("opacity",r.lineMarkers?e.opacity(t,a,r):0),a.svg.selectAll(".hoverShapes").remove()}};var t=function(t,e,i,a,r,s,n){var l=r.svg.select("#"+e),o=[];a.forEach(function(t){-1==o.indexOf(t[i.categoryFields[0]])&&o.push(t[i.categoryFields[0]])},this);var h=i.position+"Field",c=!0;null==l.node()&&(c=!1,l=r.svg.append("linearGradient").attr("id",e).attr("gradientUnits","userSpaceOnUse").attr("x1","x"==i.position?i._scale(o[0])+r.width/o.length/2:0).attr("y1","y"==i.position?i._scale(o[0])-r.height/o.length/2:0).attr("x2","x"==i.position?i._scale(o[o.length-1])+r.width/o.length/2:0).attr("y2","y"==i.position?i._scale(o[o.length-1])-r.height/o.length/2:0));var u=[];o.forEach(function(e,i){for(var r={},s=0;a.length>s;s++)if(a[s].aggField==t&&a[s][h]==e){r=a[s];break}u.push({offset:Math.round(100*(i/(o.length-1)))+"%",color:r[n]})},this),c?l.selectAll("stop").data(u).transition().duration(s).attr("offset",function(t){return t.offset}).attr("stop-color",function(t){return t.color}):l.selectAll("stop").data(u).enter().append("stop").attr("offset",function(t){return t.offset}).attr("stop-color",function(t){return t.color})},e={cx:function(t,i,a){return null!=a.x.measure&&void 0!=a.x.measure?a.x._scale(t.cx):null!=a.x.categoryFields&&void 0!=a.x.categoryFields&&a.x.categoryFields.length>=2?a.x._scale(t.cx)+e.xGap(t,i,a)+(t.xOffset+.5)*(i.width/a.x._max-2*e.xGap(t,i,a))*t.width:a.x._scale(t.cx)+i.width/a.x._max/2},cy:function(t,i,a){return null!=a.y.measure&&void 0!=a.y.measure?a.y._scale(t.cy):null!=a.y.categoryFields&&void 0!=a.y.categoryFields&&a.y.categoryFields.length>=2?a.y._scale(t.cy)-i.height/a.y._max+e.yGap(t,i,a)+(t.yOffset+.5)*(i.height/a.y._max-2*e.yGap(t,i,a))*t.height:a.y._scale(t.cy)-i.height/a.y._max/2},r:function(t,e,i){return null==i.z||void 0==i.z?5:i.z._hasMeasure()?i.z._scale(t.r):i.z._scale(e.height/100)},xGap:function(t,e,i){return(null==i.x.measure||void 0==i.x.measure)&&i.barGap>0?e.width/i.x._max*(i.barGap>.99?.99:i.barGap)/2:0},xClusterGap:function(t,i,a){return null!=a.x.categoryFields&&void 0!=a.x.categoryFields&&a.x.categoryFields.length>=2&&a.clusterBarGap>0?t.width*(i.width/a.x._max-2*e.xGap(t,i,a))*(a.clusterBarGap>.99?.99:a.clusterBarGap)/2:0},yGap:function(t,e,i){return(null==i.y.measure||void 0==i.y.measure)&&i.barGap>0?e.height/i.y._max*(i.barGap>.99?.99:i.barGap)/2:0},yClusterGap:function(t,i,a){return null!=a.y.categoryFields&&void 0!=a.y.categoryFields&&a.y.categoryFields.length>=2&&a.clusterBarGap>0?t.height*(i.height/a.y._max-2*e.yGap(t,i,a))*(a.clusterBarGap>.99?.99:a.clusterBarGap)/2:0},x:function(t,i,a){return a.x._scale(t.x)+e.xGap(t,i,a)+t.xOffset*(e.width(t,i,a)+2*e.xClusterGap(t,i,a))+e.xClusterGap(t,i,a)},y:function(t,i,a){return null!=a.y.measure&&void 0!=a.y.measure?a.y._scale(t.y):a.y._scale(t.y)-i.height/a.y._max+e.yGap(t,i,a)+t.yOffset*(e.height(t,i,a)+2*e.yClusterGap(t,i,a))+e.yClusterGap(t,i,a)},width:function(t,i,a){return null!=a.x.measure&&void 0!=a.x.measure?Math.abs(a.x._scale(t.width)-a.x._scale(0)):t.width*(i.width/a.x._max-2*e.xGap(t,i,a))-2*e.xClusterGap(t,i,a)},height:function(t,i,a){return null!=a.y.measure&&void 0!=a.y.measure?Math.abs(a.y._scale(0)-a.y._scale(t.height)):t.height*(i.height/a.y._max-2*e.yGap(t,i,a))-2*e.yClusterGap(t,i,a)},opacity:function(t,e,i){return null!=i.c&&void 0!=i.c?t.opacity:e.getColor(t.aggField.slice(-1)[0]).opacity},fill:function(t,e,i){return null!=i.c&&void 0!=i.c?t.fill:e.getColor(t.aggField.slice(-1)[0]).fill},stroke:function(t,e,i){return null!=i.c&&void 0!=i.c?t.stroke:e.getColor(t.aggField.slice(-1)[0]).stroke}};dimple.filterData=function(t,e,i){if(null!=e&&null!=i){null!=i&&void 0!=i&&(i=[].concat(i));var a=[];return t.forEach(function(t){null==t[e]?a.push(t):i.indexOf([].concat(t[e]).join("/"))>-1&&a.push(t)},this),a}return t},dimple.getUniqueValues=function(t,e){var i=[];return null!=e&&void 0!=e&&(e=[].concat(e),t.forEach(function(t){var a="";e.forEach(function(e,i){i>0&&(a+="/"),a+=t[e]},this),-1==i.indexOf(a)&&i.push(a)},this)),i},dimple.newSvg=function(t,e,i){return null==parent&&(parent="body"),d3.select(t).append("svg").attr("width",e).attr("height",i)}})(); \ No newline at end of file diff --git a/src/objects/plot/bar.js b/src/objects/plot/bar.js index a0cec42..7908b37 100644 --- a/src/objects/plot/bar.js +++ b/src/objects/plot/bar.js @@ -107,6 +107,7 @@ dimple.plot.bar = { var height = parseFloat(selectedShape.attr("height")); var opacity = selectedShape.attr("opacity"); var fill = selectedShape.attr("fill"); + var dropDest = series._dropLineOrigin(); // Fade the popup stroke mixing the shape fill with 60% white var popupStrokeColor = d3.rgb( @@ -127,12 +128,12 @@ dimple.plot.bar = { .attr("class", "hoverShapes"); // Add a drop line to the x axis - if (!series.x._hasCategories()) { + if (!series.x._hasCategories() && dropDest.y !== null) { g.append("line") - .attr("x1", (x < series.x._origin ? x : x + width ) - 1) - .attr("y1", (y < series.y._origin ? y + height : y )) - .attr("x2", (x < series.x._origin ? x : x + width ) - 1) - .attr("y2", (y < series.y._origin ? y + height : y )) + .attr("x1", (x < series.x._origin ? x + 1 : x + width - 1)) + .attr("y1", (y < dropDest.y ? y + height : y )) + .attr("x2", (x < series.x._origin ? x + 1 : x + width - 1)) + .attr("y2", (y < dropDest.y ? y + height : y )) .style("fill", "none") .style("stroke", fill) .style("stroke-width", 2) @@ -142,16 +143,16 @@ dimple.plot.bar = { .delay(animDuration / 2) .duration(animDuration / 2) .ease("linear") - .attr("y2", series.y._origin); + .attr("y2", dropDest.y); } // Add a drop line to the y axis - if (!series.y._hasCategories()) { + if (!series.y._hasCategories() && dropDest.x !== null) { g.append("line") - .attr("x1", (x < series.x._origin ? x + width : x )) - .attr("y1", (y < series.y._origin ? y : y + height ) + 1) - .attr("x2", (x < series.x._origin ? x + width : x )) - .attr("y2", (y < series.y._origin ? y : y + height ) + 1) + .attr("x1", (x < dropDest.x ? x + width : x )) + .attr("y1", (y < series.y._origin ? y + 1 : y + height - 1 )) + .attr("x2", (x < dropDest.x ? x + width : x )) + .attr("y2", (y < series.y._origin ? y + 1 : y + height - 1 )) .style("fill", "none") .style("stroke", fill) .style("stroke-width", 2) @@ -161,7 +162,7 @@ dimple.plot.bar = { .delay(animDuration / 2) .duration(animDuration / 2) .ease("linear") - .attr("x2", series.x._origin); + .attr("x2", dropDest.x); } // Add a group for text diff --git a/src/objects/plot/bubble.js b/src/objects/plot/bubble.js index 1c0cd0f..397b56a 100644 --- a/src/objects/plot/bubble.js +++ b/src/objects/plot/bubble.js @@ -103,6 +103,7 @@ dimple.plot.bubble = { var r = parseFloat(selectedShape.attr("r")); var opacity = selectedShape.attr("opacity"); var fill = selectedShape.attr("fill"); + var dropDest = series._dropLineOrigin(); // Fade the popup stroke mixing the shape fill with 60% white var popupStrokeColor = d3.rgb( @@ -139,38 +140,42 @@ dimple.plot.bubble = { .style("stroke-width", 2); // Add a drop line to the x axis - g.append("line") - .attr("x1", cx) - .attr("y1", (cy < series.y._origin ? cy + r + 4 : cy - r - 4 )) - .attr("x2", cx) - .attr("y2", (cy < series.y._origin ? cy + r + 4 : cy - r - 4 )) - .style("fill", "none") - .style("stroke", fill) - .style("stroke-width", 2) - .style("stroke-dasharray", ("3, 3")) - .style("opacity", opacity) - .transition() - .delay(animDuration / 2) - .duration(animDuration / 2) - .ease("linear") - .attr("y2", series.y._origin); + if (dropDest.y !== null) { + g.append("line") + .attr("x1", cx) + .attr("y1", (cy < dropDest.y ? cy + r + 4 : cy - r - 4 )) + .attr("x2", cx) + .attr("y2", (cy < dropDest.y ? cy + r + 4 : cy - r - 4 )) + .style("fill", "none") + .style("stroke", fill) + .style("stroke-width", 2) + .style("stroke-dasharray", ("3, 3")) + .style("opacity", opacity) + .transition() + .delay(animDuration / 2) + .duration(animDuration / 2) + .ease("linear") + .attr("y2", dropDest.y); + } // Add a drop line to the y axis - g.append("line") - .attr("x1", (cx < series.x._origin ? cx + r + 4 : cx - r - 4 )) - .attr("y1", cy) - .attr("x2", (cx < series.x._origin ? cx + r + 4 : cx - r - 4 )) - .attr("y2", cy) - .style("fill", "none") - .style("stroke", fill) - .style("stroke-width", 2) - .style("stroke-dasharray", ("3, 3")) - .style("opacity", opacity) - .transition() - .delay(animDuration / 2) - .duration(animDuration / 2) - .ease("linear") - .attr("x2", series.x._origin); + if (dropDest.x !== null) { + g.append("line") + .attr("x1", (cx < dropDest.x ? cx + r + 4 : cx - r - 4 )) + .attr("y1", cy) + .attr("x2", (cx < dropDest.x ? cx + r + 4 : cx - r - 4 )) + .attr("y2", cy) + .style("fill", "none") + .style("stroke", fill) + .style("stroke-width", 2) + .style("stroke-dasharray", ("3, 3")) + .style("opacity", opacity) + .transition() + .delay(animDuration / 2) + .duration(animDuration / 2) + .ease("linear") + .attr("x2", dropDest.x); + } // Add a group for text var t = g.append("g");