diff --git a/data/example_data.tsv b/data/example_data.tsv index a253f61..02a4f38 100644 --- a/data/example_data.tsv +++ b/data/example_data.tsv @@ -1726,4 +1726,4 @@ Date Month Channel Owner Brand Pack Size Pack Type SKU Price Tier Unit Sales Sal 01/12/2012 Dec-12 Supermarkets Tyrell Corp Kappa 8 Standard Kappa 8 Pack Standard Regular 11263 703847 36.56 1788.2 62.49 702058.8 655473.24 46585.56 -10565 -625137 1.02 -1588.22 1.61 -623548.78 -582171.91 -41376.87 01/12/2012 Dec-12 Supermarkets Tyrell Corp Kappa 12 Standard Kappa 12 Pack Standard Regular 4999 377208 39 958.34 75.46 376249.66 351283.18 24966.48 1864 128842 4.93 327.34 -3.76 128514.66 119986.56 8528.1 01/12/2012 Dec-12 Supermarkets Tyrell Corp Kappa 18 Standard Kappa 18 Pack Standard Regular 5330 339454 31.78 862.42 63.69 338591.58 316124.13 22467.45 -1763 -103005 -0.35 -261.69 1.31 -102743.31 -95925.65 -6817.66 -01/12/2012 Dec-12 Supermarkets Wayne Ent Pi 12 Giftset Pi 12 Pack Giftset Regular 176 14269 5.97 36.25 81.07 14232.75 13288.51 944.24 4 -3 0.12 -0.01 -1.91 -2.99 -2.79 -0.2 +01/12/2012 Dec-12 Supermarkets Wayne Ent Pi 12 Giftset Pi 12 Pack Giftset Regular 176 14269 5.97 36.25 81.07 14232.75 13288.51 944.24 4 -3 0.12 -0.01 -1.91 -2.99 -2.79 -0.2 \ No newline at end of file diff --git a/dist/dimple.v1.js b/dist/dimple.v1.js index 2b024fb..c7bf10f 100644 --- a/dist/dimple.v1.js +++ b/dist/dimple.v1.js @@ -317,6 +317,10 @@ var dimple = { // The group within which to put all of this chart's objects this._group = svg.append("g"); + // The group within which to put tooltips. This is not initialised here because + // the group would end up behind other chart contents in a multi chart output. It will + // therefore be added and removed by the mouse enter/leave events + this._tooltipGroup = null; // Colors assigned to chart contents. E.g. a series value. this._assignedColors = {}; // The next colour index to use, this value is cycled around for all default colours @@ -1932,10 +1936,10 @@ var dimple = { filter.push(d.aggField[k]); } uniqueValues.forEach(function (e) { - match = match || (e.join("/") === filter.join("/")); + match = match || (e === filter.join("/")); }, this); if (!match) { - uniqueValues.push(filter); + uniqueValues.push(filter.join("/")); } }, this); @@ -1963,7 +1967,7 @@ var dimple = { .data(uniqueValues) .transition() .duration(duration) - .attr("class", function (d) { return "series area " + d.join("_").replace(" ", ""); }) + .attr("class", function (d) { return "series area " + d.replace(" ", ""); }) .attr("d", function (d) { var seriesData, baseline = [], @@ -2119,15 +2123,17 @@ var dimple = { h = 0, box, overlap, - rows = [], - // Create a group for the hover objects - g = chart._group.append("g") - .attr("class", "hoverShapes"); + rows = []; + + if (chart._tooltipGroup !== null && chart._tooltipGroup !== undefined) { + chart._tooltipGroup.remove(); + } + chart._tooltipGroup = chart.svg.append("g"); // On hover make the line marker visible immediately selectedShape.style("opacity", 1); // Add a ring around the data point - g.append("circle") + chart._tooltipGroup.append("circle") .attr("cx", cx) .attr("cy", cy) .attr("r", r) @@ -2144,7 +2150,7 @@ var dimple = { // Add a drop line to the x axis if (dropDest.y !== null) { - g.append("line") + chart._tooltipGroup.append("line") .attr("x1", cx) .attr("y1", (cy < dropDest.y ? cy + r + 4 : cy - r - 4)) .attr("x2", cx) @@ -2163,7 +2169,7 @@ var dimple = { // Add a drop line to the y axis if (dropDest.x !== null) { - g.append("line") + chart._tooltipGroup.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)) @@ -2181,7 +2187,7 @@ var dimple = { } // Add a group for text - t = g.append("g"); + t = chart._tooltipGroup.append("g"); // Create a box for the popup in the text group box = t.append("rect"); @@ -2279,10 +2285,9 @@ var dimple = { leaveEventHandler: function (e, shape, chart, series) { // Return the opacity of the marker d3.select(shape).style("opacity", (series.lineMarkers ? dimple._helpers.opacity(e, chart, series) : 0)); - // Clear all hover shapes - chart._group - .selectAll(".hoverShapes") - .remove(); + if (chart._tooltipGroup !== null && chart._tooltipGroup !== undefined) { + chart._tooltipGroup.remove(); + } } }; @@ -2413,14 +2418,16 @@ var dimple = { yRunning = 0, // The maximum bounds of the text elements w = 0, - h = 0, - // Create a group for the hover objects - g = chart._group.append("g") - .attr("class", "hoverShapes"); + h = 0; + + if (chart._tooltipGroup !== null && chart._tooltipGroup !== undefined) { + chart._tooltipGroup.remove(); + } + chart._tooltipGroup = chart.svg.append("g"); // Add a drop line to the x axis if (!series.x._hasCategories() && dropDest.y !== null) { - g.append("line") + chart._tooltipGroup.append("line") .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)) @@ -2439,7 +2446,7 @@ var dimple = { // Add a drop line to the y axis if (!series.y._hasCategories() && dropDest.x !== null) { - g.append("line") + chart._tooltipGroup.append("line") .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)) @@ -2457,7 +2464,7 @@ var dimple = { } // Add a group for text - t = g.append("g"); + t = chart._tooltipGroup.append("g"); // Create a box for the popup in the text group box = t.append("rect"); @@ -2566,10 +2573,9 @@ var dimple = { // Handle the mouse leave event leaveEventHandler: function (chart) { - // Clear all hover shapes - chart._group - .selectAll(".hoverShapes") - .remove(); + if (chart._tooltipGroup !== null && chart._tooltipGroup !== undefined) { + chart._tooltipGroup.remove(); + } } }; @@ -2697,13 +2703,15 @@ var dimple = { // The maximum bounds of the text elements w = 0, h = 0, - overlap, - // Create a group for the hover objects - g = chart._group.append("g") - .attr("class", "hoverShapes"); + overlap; + + if (chart._tooltipGroup !== null && chart._tooltipGroup !== undefined) { + chart._tooltipGroup.remove(); + } + chart._tooltipGroup = chart.svg.append("g"); // Add a ring around the data point - g.append("circle") + chart._tooltipGroup.append("circle") .attr("cx", cx) .attr("cy", cy) .attr("r", r) @@ -2720,7 +2728,7 @@ var dimple = { // Add a drop line to the x axis if (dropDest.y !== null) { - g.append("line") + chart._tooltipGroup.append("line") .attr("x1", cx) .attr("y1", (cy < dropDest.y ? cy + r + 4 : cy - r - 4)) .attr("x2", cx) @@ -2739,7 +2747,7 @@ var dimple = { // Add a drop line to the y axis if (dropDest.x !== null) { - g.append("line") + chart._tooltipGroup.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)) @@ -2757,7 +2765,7 @@ var dimple = { } // Add a group for text - t = g.append("g"); + t = chart._tooltipGroup.append("g"); // Create a box for the popup in the text group box = t.append("rect"); @@ -2853,10 +2861,9 @@ var dimple = { // Handle the mouse leave event leaveEventHandler: function (chart) { - // Clear all hover shapes - chart._group - .selectAll(".hoverShapes") - .remove(); + if (chart._tooltipGroup !== null && chart._tooltipGroup !== undefined) { + chart._tooltipGroup.remove(); + } } }; @@ -3062,16 +3069,18 @@ var dimple = { t, box, rows = [], - overlap, - // Create a group for the hover objects - g = chart._group.append("g") - .attr("class", "hoverShapes"); + overlap; + + if (chart._tooltipGroup !== null && chart._tooltipGroup !== undefined) { + chart._tooltipGroup.remove(); + } + chart._tooltipGroup = chart.svg.append("g"); // On hover make the line marker visible immediately selectedShape.style("opacity", 1); // Add a ring around the data point - g.append("circle") + chart._tooltipGroup.append("circle") .attr("cx", cx) .attr("cy", cy) .attr("r", r) @@ -3088,7 +3097,7 @@ var dimple = { // Add a drop line to the x axis if (dropDest.y !== null) { - g.append("line") + chart._tooltipGroup.append("line") .attr("x1", cx) .attr("y1", (cy < dropDest.y ? cy + r + series.lineWeight + 2 : cy - r - series.lineWeight - 2)) .attr("x2", cx) @@ -3107,7 +3116,7 @@ var dimple = { // Add a drop line to the y axis if (dropDest.x !== null) { - g.append("line") + chart._tooltipGroup.append("line") .attr("x1", (cx < dropDest.x ? cx + r + series.lineWeight + 2 : cx - r - series.lineWeight - 2)) .attr("y1", cy) .attr("x2", (cx < dropDest.x ? cx + r + series.lineWeight + 2 : cx - r - series.lineWeight - 2)) @@ -3125,7 +3134,7 @@ var dimple = { } // Add a group for text - t = g.append("g"); + t = chart._tooltipGroup.append("g"); // Create a box for the popup in the text group box = t.append("rect"); @@ -3223,10 +3232,9 @@ var dimple = { leaveEventHandler: function (e, shape, chart, series) { // Return the opacity of the marker d3.select(shape).style("opacity", (series.lineMarkers ? dimple._helpers.opacity(e, chart, series) : 0)); - // Clear all hover shapes - chart._group - .selectAll(".hoverShapes") - .remove(); + if (chart._tooltipGroup !== null && chart._tooltipGroup !== undefined) { + chart._tooltipGroup.remove(); + } } }; diff --git a/dist/dimple.v1.min.js b/dist/dimple.v1.min.js index 4ac5c78..0c6e045 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(a,b,c,d){this.chart=a,this.position=b,this.categoryFields=c,this.measure=d,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._orderRules=[],this._groupOrderRules=[],this._draw=null,this._getFormat=function(){var a,b,c,d,e,f,g;return this.showPercent?a=d3.format("%"):null!==this.measure?(b=Math.floor(Math.abs(this._max),0).toString(),c=Math.floor(Math.abs(this._min),0).toString(),d=Math.max(c.length,b.length),d>3?(e=Math.min(Math.floor((d-1)/3),4),f="kmBT".substring(e-1,e),g=1>=d-3*e?1:0,a=function(a){return 0===a?0:d3.format(",."+g+"f")(a/Math.pow(1e3,e))+f}):(g=1>=d?1:0,a=d3.format(",."+g+"f"))):a=function(a){return a},a},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(a){var b,c,d,e,f=[],g=function(a,b,c){var d,e=a.categoryFields[0],f=e,g=!1,h=!0,i=[];for(d=0;d1?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?(f=g(this,"x","y"),this._scale=d3.scale.ordinal().rangePoints([this.chart.x,this.chart.x+this.chart.width]).domain(f.concat([""]))):this._scale=d3.scale.linear().range([this.chart.x,this.chart.x+this.chart.width]).domain([this._min,this._max]).nice(),!this.hidden)switch(this.chart._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)}}else if(this.position.length>0&&"y"===this.position[0]){if(null===this.measure||void 0===this.measure?(f=g(this,"y","x"),this._scale=d3.scale.ordinal().rangePoints([this.chart.y+this.chart.height,this.chart.y]).domain(f.concat([""]))):this._scale=d3.scale.linear().range([this.chart.y+this.chart.height,this.chart.y]).domain([this._min,this._max]).nice(),!this.hidden)switch(this.chart._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)}}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]));return(null===a||void 0===a||a===!1)&&null!==this._scale&&null!==this._scale.ticks&&void 0!==this._scale.ticks&&this._scale.ticks(10).length>0&&(b=this._scale.ticks(10),c=b[1]-b[0],d=((this._max-this._min)%c).toFixed(0),0!==d&&(this._max=Math.ceil(this._max/c)*c,this._min=Math.floor(this._min/c)*c,this._update(!0))),e=this._scale.copy()(0),this._origin!==e&&(this._previousOrigin=null===this._origin?e:this._origin,this._origin=e),this},this.addGroupOrderRule=function(a,b){this._groupOrderRules.push({ordering:a,desc:b})},this.addOrderRule=function(a,b){this._orderRules.push({ordering:a,desc:b})}},dimple.chart=function(a,b){this.svg=a,this.x=.1*a[0][0].width.baseVal.value,this.y=.1*a[0][0].height.baseVal.value,this.width=.8*a[0][0].width.baseVal.value,this.height=.8*a[0][0].height.baseVal.value,this.data=b,this.noFormats=!1,this.axes=[],this.series=[],this.legends=[],this.storyboard=null,this.titleShape=null,this.shapes=null,this._group=a.append("g"),this._assignedColors={},this._nextColor=0,this._axisIndex=function(a,b){var c=0,d=0,e=-1;for(c=0;c0&&(n=this.storyboard.categoryFields[0],o=dimple._getOrderedList(this.data,n,this.storyboard._orderRules)),a.x._hasCategories()&&a.x._hasMeasure()&&(r=a.x.categoryFields[0],s=dimple._getOrderedList(this.data,r,a.x._orderRules.concat([{ordering:a.x.measure,desc:!0}]))),a.y._hasCategories()&&a.y._hasMeasure()&&(t=a.y.categoryFields[0],u=dimple._getOrderedList(this.data,t,a.y._orderRules.concat([{ordering:a.y.measure,desc:!0}]))),null!==a.categoryFields&&void 0!==a.categoryFields&&a.categoryFields.length>0&&(v=a._orderRules,p=a.categoryFields[0],null!==a.c&&void 0!==a.c&&a.c._hasMeasure()?v.push({ordering:a.c.measure,desc:!0}):null!==a.z&&void 0!==a.z&&a.z._hasMeasure()?v.push({ordering:a.z.measure,desc:!0}):a.x._hasMeasure()?v.push({ordering:a.x.measure,desc:!0}):a.y._hasMeasure()&&v.push({ordering:a.y.measure,desc:!0}),q=dimple._getOrderedList(this.data,p,v)),w.sort(function(a,b){var c=0;return""!==n&&(c=o.indexOf(a[n])-o.indexOf(b[n])),""!==r&&0===c&&(c=s.indexOf(a[r])-s.indexOf(b[r])),""!==t&&0===c&&(c=u.indexOf(a[t])-u.indexOf(b[t])),""!==p&&0===c&&(c=q.indexOf(a[p])-q.indexOf(b[p])),c}),w.forEach(function(b){var c,g,h,i,j=-1,k=e(a.x,b),l=e(a.y,b),m=e(a.z,b),n=[];for(null===a.categoryFields||void 0===a.categoryFields||0===a.categoryFields.length?n=["All"]:1===a.categoryFields.length&&void 0===b[a.categoryFields[0]]?n=[a.categoryFields[0]]:a.categoryFields.forEach(function(a){n.push(b[a])},this),c=n.join("/")+"_"+k.join("/")+"_"+l.join("/")+"_"+m.join("/"),g=0;g0&&(m+="/"),m+=b[a],i=m===g},this)),null!==c&&void 0!==c&&null!==c.measure&&void 0!==c.measure&&i&&(h=d[j],-1===h[c.position+"ValueList"].indexOf(b[c.measure])&&h[c.position+"ValueList"].push(b[c.measure]),isNaN(parseFloat(b[c.measure]))&&(f[c.position]=!0),k.value=h[c.position+"Value"],k.count=h[c.position+"Count"],l.value=b[c.measure],h[c.position+"Value"]=a.aggregate(k,l),h[c.position+"Count"]+=1)},i(a.x,this.storyboard),i(a.y,this.storyboard),i(a.z,this.storyboard),i(a.c,this.storyboard)},this),null!==a.x&&void 0!==a.x&&a.x._hasCategories()&&a.x.categoryFields.length>1&&void 0!==g.x&&(x=[],a.y._hasMeasure()&&x.push({ordering:a.y.measure,desc:!0}),g.x=dimple._getOrderedList(this.data,a.x.categoryFields[1],a.x._groupOrderRules.concat(x))),null!==a.y&&void 0!==a.y&&a.y._hasCategories()&&a.y.categoryFields.length>1&&void 0!==g.y&&(x=[],a.x._hasMeasure()&&x.push({ordering:a.x.measure,desc:!0}),g.y=dimple._getOrderedList(this.data,a.y.categoryFields[1],a.y._groupOrderRules.concat(x)),g.y.reverse()),d.forEach(function(c){null!==a.x&&(f.x===!0&&(c.xValue=c.xValueList.length),b=(null===h.x[c.xField.join("/")]||void 0===h.x[c.xField.join("/")]?0:h.x[c.xField.join("/")])+(a.y._hasMeasure()?Math.abs(c.yValue):0),h.x[c.xField.join("/")]=b),null!==a.y&&(f.y===!0&&(c.yValue=c.yValueList.length),b=(null===h.y[c.yField.join("/")]||void 0===h.y[c.yField.join("/")]?0:h.y[c.yField.join("/")])+(a.x._hasMeasure()?Math.abs(c.xValue):0),h.y[c.yField.join("/")]=b),null!==a.z&&(f.z===!0&&(c.zValue=c.zValueList.length),b=(null===h.z[c.zField.join("/")]||void 0===h.z[c.zField.join("/")]?0:h.z[c.zField.join("/")])+(a.z._hasMeasure()?Math.abs(c.zValue):0),h.z[c.zField.join("/")]=b),null!==a.c&&((null===i.min||c.cValuei.max)&&(i.max=c.cValue))},this);for(c in h.x)h.x.hasOwnProperty(c)&&(m.x+=h.x[c]);for(c in h.y)h.y.hasOwnProperty(c)&&(m.y+=h.y[c]);for(c in h.z)h.z.hasOwnProperty(c)&&(m.z+=h.z[c]);d.forEach(function(b){var c,d,e,f,n,o=function(c,d,e){var f,i,n,o,p;null!==c&&void 0!==c&&(o=c.position,c._hasCategories()?c._hasMeasure()?(f=b[c.position+"Field"].join("/"),i=c.showPercent?h[c.position][f]/m[c.position]:h[c.position][f],-1===k.indexOf(f)&&(l[f]=i+(k.length>0?l[k[k.length-1]]:0),k.push(f)),n=b[o+"Bound"]=b["c"+o]="x"!==o&&"y"!==o||!a.stacked?i:l[f],b[e]=i,b[o]=n-("x"===o&&i>=0||"y"===o&&0>=i?i:0)):(b[o]=b["c"+o]=b[o+"Field"][0],b[e]=1,void 0!==g[o]&&null!==g[o]&&g[o].length>=2&&(b[o+"Offset"]=g[o].indexOf(b[o+"Field"][1]),b[e]=1/g[o].length)):(i=c.showPercent?b[o+"Value"]/h[d][b[d+"Field"].join("/")]:b[o+"Value"],f=b[d+"Field"].join("/")+(b[o+"Value"]>=0),p=j[o][f]=(null===j[o][f]||void 0===j[o][f]||"z"===o?0:j[o][f])+i,n=b[o+"Bound"]=b["c"+o]="x"!==o&&"y"!==o||!a.stacked?i:p,b[e]=i,b[o]=n-("x"===o&&i>=0||"y"===o&&0>=i?i:0)))};o(a.x,"y","width"),o(a.y,"x","height"),o(a.z,"z","r"),null!==a.c&&i.min!==i.max&&(i.min=null!==a.c.overrideMin&&void 0!==a.c.overrideMin?a.c.overrideMin:i.min,i.max=null!==a.c.overrideMax&&void 0!==a.c.overrideMax?a.c.overrideMax:i.max,b.cValue=b.cValue>i.max?i.max:b.cValue1?(c=d3.rgb(a.c.colors[Math.floor(f)]),d=d3.rgb(a.c.colors[Math.ceil(f)])):(c=d3.rgb("white"),d=d3.rgb(this.getColor(b.aggField.slice(-1)[0]).fill)),c.r=Math.floor(c.r+(d.r-c.r)*n),c.g=Math.floor(c.g+(d.g-c.g)*n),c.b=Math.floor(c.b+(d.b-c.b)*n),b.fill=c.toString(),b.stroke=c.darker(.5).toString())},this),a._positionData=d},this)},this._registerEventHandlers=function(a){null!==a._eventHandlers&&a._eventHandlers.length>0&&a._eventHandlers.forEach(function(b){null!==b.handler&&"function"==typeof b.handler&&a.shapes.on(b.event,function(c){var d=new dimple.eventArgs;null!==a.chart.storyboard&&(d.frameValue=a.chart.storyboard.getFrameValue()),d.seriesValue=c.aggField,d.xValue=c.x,d.yValue=c.y,d.zValue=c.z,d.colorValue=c.cValue,d.seriesShapes=a.shapes,d.selectedShape=d3.select(this),b.handler(d)})},this)},this.addAxis=function(a,b,c){null!==b&&void 0!==b&&(b=[].concat(b));var d=new dimple.axis(this,a,b,c);return this.axes.push(d),d},this.addCategoryAxis=function(a,b){return this.addAxis(a,b,null)},this.addColorAxis=function(a,b){var c=this.addAxis("c",null,a);return c.colors=null===b||void 0===b?null:[].concat(b),c},this.addLegend=function(a,b,c,d,e,f){f=null===f||void 0===f?this.series:[].concat(f),e=null===e||void 0===e?"left":e;var g=new dimple.legend(this,a,b,c,d,e,f);return this.legends.push(g),g},this.addMeasureAxis=function(a,b){return this.addAxis(a,null,b)},this.addPctAxis=function(a,b){var c=this.addMeasureAxis(a,b);return c.showPercent=!0,c},this.addSeries=function(a,b,c){(null===c||void 0===c)&&(c=this.axes),(null===b||void 0===b)&&(b=dimple.plot.bubble);var d,e=null,f=null,g=null,h=null;return c.forEach(function(a){null!==a&&b.supportedAxes.indexOf(a.position)>-1&&(null===e&&"x"===a.position[0]?e=a:null===f&&"y"===a.position[0]?f=a:null===g&&"z"===a.position[0]?g=a:null===h&&"c"===a.position[0]&&(h=a))},this),null!==a&&void 0!==a&&(a=[].concat(a)),d=new dimple.series(this,a,e,f,g,h,b,dimple.aggregateMethod.sum,b.stacked),this.series.push(d),d},this.assignColor=function(a,b,c,d){return this._assignedColors[a]=new dimple.color(b,c,d),this._assignedColors[a]},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(a){a=null===a||void 0===a?0:a;var b,c=null,d=null,e=!1,f=!1;return this._getSeriesData(),this.axes.forEach(function(a){if(a._min=0,a._max=0,null!==a.measure&&void 0!==a.measure){var e=!1;this.series.forEach(function(b){if(b[a.position]===a){var c=b._axisBounds(a.position);a._min>c.min&&(a._min=c.min),a._maxb[a.measure]&&(a._min=b[a.measure]),a._max0&&(b!==c||null!==d.categoryFields&&0!==d.categoryFields.length||g(b.shapes.selectAll(".axis text")).attr("y",this.y+this.height-d._scale(0)+9),b!==d||null!==c.categoryFields&&0!==c.categoryFields.length||g(b.shapes.selectAll(".axis text")).attr("x",-1*(c._scale(0)-this.x)-9))),this.noFormats||(g(b.shapes.selectAll(".axis text")).style("font-family","sans-serif").style("font-size",(this.height/35>10?this.height/35:10)+"px"),g(b.shapes.selectAll(".axis path, .axis line")).style("fill","none").style("stroke","black").style("shape-rendering","crispEdges"),null!==b.gridlineShapes&&g(b.gridlineShapes.selectAll(".gridlines line")).style("fill","none").style("stroke","lightgray").style("opacity",.8)),(null===b.measure||void 0===b.measure)&&(b===c?(m=0,b.shapes.selectAll(".axis text").each(function(){var a=this.getComputedTextLength();m=a>m?a:m}),m>this.width/b._max&&(l=!0,b.shapes.selectAll(".axis text").style("text-anchor","start").each(function(){var a=this.getBBox();d3.select(this).attr("transform","rotate(90,"+a.x+","+(a.y+a.height/2)+") translate(-5, 0)")}))):"x"===b.position&&(m=0,b.shapes.selectAll(".axis text").each(function(){var a=this.getComputedTextLength();m=a>m?a:m}),m>this.width/b._max&&b.shapes.selectAll(".axis text").style("text-anchor","end").each(function(){var a=this.getBBox();d3.select(this).attr("transform","rotate(90,"+(a.x+a.width)+","+(a.y+a.height/2)+") translate(5, 0)")}))),null===b.titleShape&&null!==b.shapes&&null!==b.shapes.node().firstChild&&(b.shapes.selectAll(".axis text").each(function(){var a=this.getBBox();n.l=null===n.l||a.xn.r?a.x+a.width:n.r,n.b=l?null===n.b||a.y+a.width>n.b?a.y+a.width:n.b:null===n.b||a.y+a.height>n.b?a.y+a.height:n.b}),"x"===b.position?(p=b===c?this.y+this.height+n.b+10:this.y+n.l+n.t-5,o=this.x+this.width/2):"y"===b.position&&(o=b===d?this.x+n.l-10:this.x+this.width+n.r+10,p=this.y+this.height/2,q="rotate(270, "+o+", "+p+")"),b.titleShape=this._group.append("text").attr("class","axis title"),b.titleShape.attr("x",o).attr("y",p).attr("text-anchor","middle").attr("transform",q).text(null===b.categoryFields||void 0===b.categoryFields||0===b.categoryFields.length?b.measure:b.categoryFields.join("/")).each(function(){r.noFormats||d3.select(this).style("font-family","sans-serif").style("font-size",(r.height/35>10?r.height/35:10)+"px")}),b===c?b.titleShape.each(function(){d3.select(this).attr("y",p+this.getBBox().height/1.65)}):b===d&&b.titleShape.each(function(){d3.select(this).attr("x",o+this.getBBox().height/1.65)}))},this),this.series.forEach(function(b){b.plot.draw(this,b,a),this._registerEventHandlers(b)},this),this.legends.forEach(function(b){b._draw(a)},this),null!==this.storyboard&&void 0!==this.storyboard&&(this.storyboard._drawText(),this.storyboard.autoplay&&this.storyboard.startAnimation()),this},this.getColor=function(a){return(null===this._assignedColors[a]||void 0===this._assignedColors[a])&&(this._assignedColors[a]=this.defaultColors[this._nextColor],this._nextColor=(this._nextColor+1)%this.defaultColors.length),this._assignedColors[a]},this.setBounds=function(a,b,c,d){return this.x=a,this.y=b,this.width=c,this.height=d,this.axes.forEach(function(a){a._update()},this),this},this.setStoryboard=function(a,b){return this.storyboard=new dimple.storyboard(this,a),null!==b&&void 0!==b&&(this.storyboard.onTick=b),this.storyboard}},dimple.color=function(a,b,c){this.fill=a,this.stroke=null===b||void 0===b?d3.rgb(a).darker(.5).toString():b,this.opacity=null===c||void 0===c?.8:c},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(a,b,c,d,e,f,g){this.chart=a,this.series=g,this.x=b,this.y=c,this.width=d,this.height=e,this.horizontalAlign=f,this.shapes=null,this._draw=function(a){var b,c=this._getEntries(),d=0,e=0,f=0,g=0,h=15,i=9,j=this;null!==this.shapes&&void 0!==this.shapes&&this.shapes.transition().duration(.2*a).attr("opacity",0).remove(),b=this.chart._group.selectAll(".dontSelectAny").data(c).enter().append("g").attr("class","legend").attr("opacity",0),b.append("text").attr("id",function(a){return"legend_"+a.key}).attr("class","legendText").text(function(a){return a.key}).call(function(){j.chart.noFormats||this.style("font-family","sans-serif").style("font-size",(j.chart.height/35>10?j.chart.height/35:10)+"px").style("shape-rendering","crispEdges")}).each(function(){var a=this.getBBox();a.width>d&&(d=a.width),a.height>e&&(e=a.height)}),b.append("rect").attr("class","legendKey").attr("height",i).attr("width",h),e=(i>e?i:e)+2,d+=h+20,b.each(function(a){f+d>j.width&&(f=0,g+=e),g>j.height?d3.select(this).remove():(d3.select(this).select("text").attr("x","left"===j.horizontalAlign?j.x+h+5+f:j.x+(j.width-f-d)+h+5).attr("y",function(){return j.y+g+this.getBBox().height/1.65}).attr("width",j.width).attr("height",j.height),d3.select(this).select("rect").attr("class","legend legendKey").attr("x","left"===j.horizontalAlign?j.x+f:j.x+(j.width-f-d)).attr("y",j.y+g).attr("height",i).attr("width",h).style("fill",function(){return dimple._helpers.fill(a,j.chart,a.series)}).style("stroke",function(){return dimple._helpers.stroke(a,j.chart,a.series)}).style("opacity",function(){return dimple._helpers.opacity(a,j.chart,a.series)}).style("shape-rendering","crispEdges"),f+=d)}),b.transition().delay(.2*a).duration(.8*a).attr("opacity",1),this.shapes=b},this._getEntries=function(){var a=[];return null!==this.series&&void 0!==this.series&&this.series.forEach(function(b){var c=b._positionData;c.forEach(function(c){var d,e=-1;for(d=0;de.max&&(e.max=a[f.position+"Bound"])},this):null===g||null===g.categoryFields||0===g.categoryFields.length?j.forEach(function(a){!this.stacked||"x"!==f.position&&"y"!==f.position?(a[f.position+"Value"]e.max&&(e.max=a[f.position+"Value"])):a[f.position+"Value"]<0?e.min=e.min+a[f.position+"Value"]:e.max=e.max+a[f.position+"Value"]},this):(b=f.position+"Value",c=g.position+"Field",d=[],j.forEach(function(a){var e=a[c].join("/"),f=d.indexOf(e);-1===f&&(d.push(e),f=d.length-1),void 0===h[f]&&(h[f]={min:0,max:0},f>=i&&(i=f+1)),this.stacked?a[b]<0?h[f].min=h[f].min+a[b]:h[f].max=h[f].max+a[b]:(a[b]h[f].max&&(h[f].max=a[b]))},this),h.forEach(function(a){void 0!==a&&(a.mine.max&&(e.max=a.max))},this)),e},this._dropLineOrigin=function(){var a=0,b=0,c={x:null,y:null},d={x:null,y:null};return this.chart.axes.forEach(function(a){"x"===a.position&&null===d.x?d.x=a._origin:"y"===a.position&&null===d.y&&(d.y=a._origin)},this),this.chart.axes.forEach(function(e){"x"!==e.position||this.x.hidden?"y"!==e.position||this.y.hidden||(e===this.y&&(0===b?c.x=d.x:1===b&&(c.x=this.chart.x+this.chart.width)),b+=1):(e===this.x&&(0===a?c.y=d.y:1===a&&(c.y=this.chart.y)),a+=1)},this),c},this.addEventHandler=function(a,b){this._eventHandlers.push({event:a,handler:b})},this.addOrderRule=function(a,b){this._orderRules.push({ordering:a,desc:b})}},dimple.storyboard=function(a,b){null!==b&&void 0!==b&&(b=[].concat(b)),this.chart=a,this.categoryFields=b,this.autoplay=!0,this.frameDuration=3e3,this.storyLabel=null,this.onTick=null,this._frame=0,this._animationTimer=null,this._categories=[],this._cachedCategoryFields=[],this._orderRules=[],this._drawText=function(a){if(null===this.storyLabel||void 0===this.storyLabel){var b=this,c=0;this.chart.axes.forEach(function(a){"x"===a.position&&(c+=1)},this),this.storyLabel=this.chart._group.append("text").attr("x",this.chart.x+.01*this.chart.width).attr("y",this.chart.y+(this.chart.height/35>10?this.chart.height/35:10)*(c>1?1.25:-1)).call(function(){b.noFormats||this.style("font-family","sans-serif").style("font-size",(b.height/35>10?b.height/35:10)+"px")})}this.storyLabel.transition().duration(.2*a).attr("opacity",0),this.storyLabel.transition().delay(.2*a).text(this.categoryFields.join("\\")+": "+this.getFrameValue()).transition().duration(.8*a).attr("opacity",1)},this._getCategories=function(){return this._categoryFields!==this._cachedCategoryFields&&(this._categories=[],this.chart.data.forEach(function(a){var b=-1,c="";null!==this.categoryFields&&(this.categoryFields.forEach(function(b,d){d>0&&(c+="/"),c+=a[b]},this),b=this._categories.indexOf(c),-1===b&&(this._categories.push(c),b=this._categories.length-1))},this),this._cachedCategoryFields=this._categoryFields),this._categories},this._goToFrameIndex=function(a){this._frame=a%this._getCategories().length,this.chart.draw(this.frameDuration/2)},this.addOrderRule=function(a,b){this._orderRules.push({ordering:a,desc:b})},this.getFrameValue=function(){var a=null;return this._frame>=0&&this._getCategories().length>this._frame&&(a=this._getCategories()[this._frame]),a},this.goToFrame=function(a){if(this._getCategories().length>0){var b=this._getCategories().indexOf(a);this._goToFrameIndex(b)}},this.pauseAnimation=function(){null!==this._animationTimer&&(window.clearInterval(this._animationTimer),this._animationTimer=null)},this.startAnimation=function(){null===this._animationTimer&&(null!==this.onTick&&this.onTick(this.getFrameValue()),this._animationTimer=window.setInterval(function(a){return function(){a._goToFrameIndex(a._frame+1),null!==a.onTick&&a.onTick(a.getFrameValue()),a._drawText(a.frameDuration/2)}}(this),this.frameDuration))},this.stopAnimation=function(){null!==this._animationTimer&&(window.clearInterval(this._animationTimer),this._animationTimer=null,this._frame=0)}},dimple.aggregateMethod.avg=function(a,b){return a.value=null===a.value||void 0===a.value?0:parseFloat(a.value),a.count=null===a.count||void 0===a.count?1:parseFloat(a.count),b.value=null===b.value||void 0===b.value?0:parseFloat(b.value),b.count=null===b.count||void 0===b.count?1:parseFloat(b.count),(a.value*a.count+b.value*b.count)/(a.count+b.count)},dimple.aggregateMethod.count=function(a,b){return a.count=null===a.count||void 0===a.count?0:parseFloat(a.count),b.count=null===b.count||void 0===b.count?0:parseFloat(b.count),a.count+b.count},dimple.aggregateMethod.max=function(a,b){return a.value=null===a.value||void 0===a.value?0:parseFloat(a.value),b.value=null===b.value||void 0===b.value?0:parseFloat(b.value),a.value>b.value?a.value:b.value},dimple.aggregateMethod.min=function(a,b){return null===a.value?parseFloat(b.value):parseFloat(a.value)=0;i-=1)if(f=e[i],h={cx:0,cy:0,height:0,width:0,xOffset:0,yOffset:0},b.x._hasCategories()){if(h.cx=f.cx,h.width=f.width,h.xOffset=f.xOffset,void 0===k[f.xField])k[f.xField]=[];else{for(p=0,j=0;j<=k[f.xField].length;j+=1)m=k[f.xField][j],(f.cy>=0&&m>=0||f.cy<=0&&0>=m)&&Math.abs(m)<=Math.abs(f.cy)&&Math.abs(m)>Math.abs(p)&&(p=m);h.cy=p}o.push(h),k[f.xField].push(f.cy)}else if(b.y._hasCategories()){if(h.cy=f.cy,h.height=f.height,h.yOffset=f.yOffset,void 0===k[f.yField])k[f.yField]=[];else{for(p=0,l=0;l<=k[f.yField].length;l+=1)n=k[f.yField][l],(f.cx>=0&&n>=0||f.cx<=0&&0>=n)&&Math.abs(n)<=Math.abs(f.cx)&&Math.abs(n)>Math.abs(p)&&(p=n);h.cx=p}o.push(h),k[f.yField].push(f.cx)}return d(e.concat(o).concat(e[0]))}).call(function(){a.noFormats||this.attr("fill",function(b){return j?"url(#fill-area-gradient-"+b.join("_").replace(" ","")+")":a.getColor(b).fill}).attr("stroke",function(b){return j?"url(#stroke-area-gradient-"+b.join("_").replace(" ","")+")":a.getColor(b).stroke}).attr("stroke-width",b.lineWeight)}),e=a._group.selectAll(".markers").data(g).enter(),b.lineMarkers&&e.append("circle").transition().duration(c).attr("cx",function(c){return dimple._helpers.cx(c,a,b)}).attr("cy",function(c){return dimple._helpers.cy(c,a,b)}).attr("r",2+b.lineWeight).attr("fill","white").attr("stroke","none"),e.append("circle").on("mouseover",function(c){f.enterEventHandler(c,this,a,b)}).on("mouseleave",function(c){f.leaveEventHandler(c,this,a,b)}).transition().duration(c).attr("cx",function(c){return dimple._helpers.cx(c,a,b)}).attr("cy",function(c){return dimple._helpers.cy(c,a,b)}).attr("r",2+b.lineWeight).attr("opacity",function(c){return b.lineMarkers?a.getColor(c).opacity:0}).call(function(){a.noFormats||this.attr("fill","white").style("stroke-width",b.lineWeight).attr("stroke",function(c){return dimple._helpers.stroke(c,a,b)})})},enterEventHandler:function(a,b,c,d){var e,f,g,h=5,i=10,j=750,k=d3.select(b),l=parseFloat(k.attr("cx")),m=parseFloat(k.attr("cy")),n=parseFloat(k.attr("r")),o=dimple._helpers.opacity(a,c,d),p=dimple._helpers.fill(a,c,d),q=d._dropLineOrigin(),r=d3.rgb(d3.rgb(p).r+.6*(255-d3.rgb(p).r),d3.rgb(p).g+.6*(255-d3.rgb(p).g),d3.rgb(p).b+.6*(255-d3.rgb(p).b)),s=d3.rgb(d3.rgb(p).r+.8*(255-d3.rgb(p).r),d3.rgb(p).g+.8*(255-d3.rgb(p).g),d3.rgb(p).b+.8*(255-d3.rgb(p).b)),t=0,u=0,v=0,w=[],x=c._group.append("g").attr("class","hoverShapes");k.style("opacity",1),x.append("circle").attr("cx",l).attr("cy",m).attr("r",n).attr("opacity",0).style("fill","none").style("stroke",p).style("stroke-width",1).transition().duration(j/2).ease("linear").attr("opacity",1).attr("r",n+4).style("stroke-width",2),null!==q.y&&x.append("line").attr("x1",l).attr("y1",m0&&d.categoryFields.forEach(function(b,c){w.push(b+(a.aggField!==b?": "+a.aggField[c]:""))},this),d.x._hasCategories()?d.x.categoryFields.forEach(function(b,c){w.push(b+(a.xField!==b?": "+a.xField[c]:""))},this):w.push(d.x.measure+": "+d.x._getFormat()(a.cx)),d.y._hasCategories()?d.y.categoryFields.forEach(function(b,c){w.push(b+(a.yField!==b?": "+a.yField[c]:""))},this):w.push(d.y.measure+":"+d.y._getFormat()(a.cy)),null!==d.z&&void 0!==d.z&&w.push(d.z.measure+": "+d.z._getFormat()(a.zValue)),null!==d.c&&void 0!==d.c&&w.push(d.c.measure+": "+d.c._getFormat()(a.cValue)),w=w.filter(function(a,b){return w.indexOf(a)===b -}),e.selectAll(".textHoverShapes").data(w).enter().append("text").text(function(a){return a}).style("font-family","sans-serif").style("font-size","10px"),e.each(function(){u=this.getBBox().width>u?this.getBBox().width:u,v=this.getBBox().width>v?this.getBBox().height:v}),e.selectAll("text").attr("x",0).attr("y",function(){return t+=this.getBBox().height,t-this.getBBox().height/2}),f.attr("x",-h).attr("y",-h).attr("height",Math.floor(t+h)-.5).attr("width",u+2*h).attr("rx",5).attr("ry",5).style("fill",s).style("stroke",r).style("stroke-width",2).style("opacity",.95),g=l+n+h+i+u>parseFloat(c.svg.attr("width")),e.attr("transform","translate("+(g?l-(n+h+i+u):l+n+h+i)+" , "+(m-(t-(v-h))/2)+")")},leaveEventHandler:function(a,b,c,d){d3.select(b).style("opacity",d.lineMarkers?dimple._helpers.opacity(a,c,d):0),c._group.selectAll(".hoverShapes").remove()}},dimple.plot.bar={stacked:!0,supportedAxes:["x","y","c"],draw:function(a,b,c){var d=this,e=b._positionData,f=null,g="series"+a.series.indexOf(b);a._group.selectAll(".hoverShapes").transition().duration(c/4).style("opacity",0).remove(),f=null===b.shapes||void 0===b.shapes?a._group.selectAll("."+g).data(e):b.shapes.data(e,function(a){return a.key}),f.enter().append("rect").attr("id",function(a){return a.key}).attr("class",function(a){return g+" bar "+a.aggField.join(" ")+" "+a.xField.join(" ")+" "+a.yField.join(" ")}).attr("x",function(c){return dimple._helpers.x(c,a,b)}).attr("y",function(c){return dimple._helpers.y(c,a,b)+dimple._helpers.height(c,a,b)}).attr("width",function(c){return null!==c.xField&&c.xField.length>0?dimple._helpers.width(c,a,b):0}).attr("height",function(c){return null!==c.yField&&c.yField.length>0?dimple._helpers.height(c,a,b):0}).attr("opacity",function(c){return dimple._helpers.opacity(c,a,b)}).on("mouseover",function(c){d.enterEventHandler(c,this,a,b)}).on("mouseleave",function(){d.leaveEventHandler(a)}).call(function(){a.noFormats||this.attr("fill",function(c){return dimple._helpers.fill(c,a,b)}).attr("stroke",function(c){return dimple._helpers.stroke(c,a,b)})}),f.transition().duration(c).attr("x",function(c){return dimple._helpers.x(c,a,b)}).attr("y",function(c){return dimple._helpers.y(c,a,b)}).attr("width",function(c){return dimple._helpers.width(c,a,b)}).attr("height",function(c){return dimple._helpers.height(c,a,b)}).call(function(){a.noFormats||this.attr("fill",function(c){return dimple._helpers.fill(c,a,b)}).attr("stroke",function(c){return dimple._helpers.stroke(c,a,b)})}),f.exit().transition().duration(c).attr("x",function(c){return dimple._helpers.x(c,a,b)}).attr("y",function(c){return dimple._helpers.y(c,a,b)}).attr("width",function(c){return dimple._helpers.width(c,a,b)}).attr("height",function(c){return dimple._helpers.height(c,a,b)}).each("end",function(){d3.select(this).remove()}),b.shapes=f},enterEventHandler:function(a,b,c,d){var e,f,g=5,h=10,i=750,j=d3.select(b),k=parseFloat(j.attr("x")),l=parseFloat(j.attr("y")),m=parseFloat(j.attr("width")),n=parseFloat(j.attr("height")),o=j.attr("opacity"),p=j.attr("fill"),q=d._dropLineOrigin(),r=d3.rgb(d3.rgb(p).r+.6*(255-d3.rgb(p).r),d3.rgb(p).g+.6*(255-d3.rgb(p).g),d3.rgb(p).b+.6*(255-d3.rgb(p).b)),s=d3.rgb(d3.rgb(p).r+.8*(255-d3.rgb(p).r),d3.rgb(p).g+.8*(255-d3.rgb(p).g),d3.rgb(p).b+.8*(255-d3.rgb(p).b)),t=[],u=0,v=0,w=0,x=c._group.append("g").attr("class","hoverShapes");d.x._hasCategories()||null===q.y||x.append("line").attr("x1",k0&&d.categoryFields.forEach(function(b,c){t.push(b+(a.aggField!==b?": "+a.aggField[c]:""))},this),d.x._hasCategories()?d.x.categoryFields.forEach(function(b,c){t.push(b+(a.xField!==b?": "+a.xField[c]:""))},this):t.push(d.x.measure+": "+d.x._getFormat()(a.width)),d.y._hasCategories()?d.y.categoryFields.forEach(function(b,c){t.push(b+(a.yField!==b?": "+a.yField[c]:""))},this):t.push(d.y.measure+":"+d.y._getFormat()(a.height)),null!==d.c&&void 0!==d.c&&t.push(d.c.measure+": "+d.c._getFormat()(d.c.showPercent?a.cPct:a.cValue)),t=t.filter(function(a,b){return t.indexOf(a)===b}),e.selectAll(".textHoverShapes").data(t).enter().append("text").text(function(a){return a}).style("font-family","sans-serif").style("font-size","10px"),e.each(function(){v=this.getBBox().width>v?this.getBBox().width:v,w=this.getBBox().width>w?this.getBBox().height:w}),e.selectAll("text").attr("x",0).attr("y",function(){return u+=this.getBBox().height,u-this.getBBox().height/2}),f.attr("x",-g).attr("y",-g).attr("height",Math.floor(u+g)-.5).attr("width",v+2*g).attr("rx",5).attr("ry",5).style("fill",s).style("stroke",r).style("stroke-width",2).style("opacity",.95),k+m+g+h+v0?e.attr("transform","translate("+(k-(g+h+v))+" , "+(l+n/2-(u-(w-g))/2)+")"):l+n+u+h+g0&&d.categoryFields.forEach(function(b,c){t.push(b+(a.aggField!==b?": "+a.aggField[c]:""))},this),d.x._hasCategories()?d.x.categoryFields.forEach(function(b,c){t.push(b+(a.xField!==b?": "+a.xField[c]:""))},this):t.push(d.x.measure+": "+d.x._getFormat()(a.cx)),d.y._hasCategories()?d.y.categoryFields.forEach(function(b,c){t.push(b+(a.yField!==b?": "+a.yField[c]:""))},this):t.push(d.y.measure+":"+d.y._getFormat()(a.cy)),null!==d.z&&void 0!==d.z&&t.push(d.z.measure+": "+d.z._getFormat()(a.zValue)),null!==d.c&&void 0!==d.c&&t.push(d.c.measure+": "+d.c._getFormat()(a.cValue)),t=t.filter(function(a,b){return t.indexOf(a)===b}),e.selectAll(".textHoverShapes").data(t).enter().append("text").text(function(a){return a}).style("font-family","sans-serif").style("font-size","10px"),e.each(function(){v=this.getBBox().width>v?this.getBBox().width:v,w=this.getBBox().width>w?this.getBBox().height:w}),e.selectAll("text").attr("x",0).attr("y",function(){return u+=this.getBBox().height,u-this.getBBox().height/2}),f.attr("x",-h).attr("y",-h).attr("height",Math.floor(u+h)-.5).attr("width",v+2*h).attr("rx",5).attr("ry",5).style("fill",s).style("stroke",r).style("stroke-width",2).style("opacity",.95),g=l+n+h+i+v>parseFloat(c.svg.attr("width")),e.attr("transform","translate("+(g?l-(n+h+i+v):l+n+h+i)+" , "+(m-(u-(w-h))/2)+")")},leaveEventHandler:function(a){a._group.selectAll(".hoverShapes").remove()}},dimple.plot.line={stacked:!1,supportedAxes:["x","y","c"],draw:function(a,b,c){var d,e,f=this,g=b._positionData,h=[],i=[],j=1,k=!1;(b.x._hasCategories()||b.y._hasCategories())&&(j=0),g.forEach(function(a){var b,c=[],d=!1;for(b=j;b0&&d.categoryFields.forEach(function(b,c){w.push(b+(a.aggField!==b?": "+a.aggField[c]:""))},this),d.x._hasCategories()?d.x.categoryFields.forEach(function(b,c){w.push(b+(a.xField!==b?": "+a.xField[c]:""))},this):w.push(d.x.measure+": "+d.x._getFormat()(a.cx)),d.y._hasCategories()?d.y.categoryFields.forEach(function(b,c){w.push(b+(a.yField!==b?": "+a.yField[c]:""))},this):w.push(d.y.measure+": "+d.y._getFormat()(a.cy)),null!==d.z&&void 0!==d.z&&w.push(d.z.measure+": "+d.z._getFormat()(a.zValue)),null!==d.c&&void 0!==d.c&&w.push(d.c.measure+": "+d.c._getFormat()(a.cValue)),w=w.filter(function(a,b){return w.indexOf(a)===b}),e.selectAll(".textHoverShapes").data(w).enter().append("text").text(function(a){return a}).style("font-family","sans-serif").style("font-size","10px"),e.each(function(){u=this.getBBox().width>u?this.getBBox().width:u,v=this.getBBox().width>v?this.getBBox().height:v}),e.selectAll("text").attr("x",0).attr("y",function(){return t+=this.getBBox().height,t-this.getBBox().height/2}),f.attr("x",-h).attr("y",-h).attr("height",Math.floor(t+h)-.5).attr("width",u+2*h).attr("rx",5).attr("ry",5).style("fill",s).style("stroke",r).style("stroke-width",2).style("opacity",.95),g=l+n+h+i+u>parseFloat(c.svg.attr("width")),e.attr("transform","translate("+(g?l-(n+h+i+u):l+n+h+i)+" , "+(m-(t-(v-h))/2)+")")},leaveEventHandler:function(a,b,c,d){d3.select(b).style("opacity",d.lineMarkers?dimple._helpers.opacity(a,c,d):0),c._group.selectAll(".hoverShapes").remove()}},dimple._addGradient=function(a,b,c,d,e,f,g){var h=e._group.select("#"+b),i=[],j=c.position+"Field",k=!0,l=[];d.forEach(function(a){-1===i.indexOf(a[j])&&i.push(a[j])},this),i=i.sort(function(a,b){return c._scale(a)-c._scale(b)}),null===h.node()&&(k=!1,h=e._group.append("linearGradient").attr("id",b).attr("gradientUnits","userSpaceOnUse").attr("x1","x"===c.position?c._scale(i[0])+e.width/i.length/2:0).attr("y1","y"===c.position?c._scale(i[0])-e.height/i.length/2:0).attr("x2","x"===c.position?c._scale(i[i.length-1])+e.width/i.length/2:0).attr("y2","y"===c.position?c._scale(i[i.length-1])-e.height/i.length/2:0)),i.forEach(function(b,c){var e={},f=0;for(f=0;f=1&&(c.forEach(function(a){var c=null===a.desc||void 0===a.desc?!1:a.desc,d=a.ordering,f=[],g="string"==typeof d?d:null,h=function(a){var b,c=0;for(b=0;bb[0]&&(c=1):c=Date.parse(a[0])-Date.parse(b[0]):c=parseFloat(d)-parseFloat(e),c};"function"==typeof d?e.push(function(a,b){return(c?-1:1)*d(a,b)}):d instanceof Array?(d.forEach(function(a){f.push([].concat(a).join("|"))},this),e.push(function(a,d){var e,g,h="".concat(a[b]),i="".concat(d[b]);return e=f.indexOf(h),g=f.indexOf(i),e=0>e?c?-1:f.length:e,g=0>g?c?-1:f.length:g,(c?-1:1)*(e-g)})):e.push(function(a,b){var d=0;return void 0!==a[g]&&void 0!==b[g]&&(d=i([].concat(a[g]),[].concat(b[g]))),(c?-1:1)*d})}),d.sort(function(a,b){for(var c=0,d=0;c=2?c.x._scale(a.cx)+dimple._helpers.xGap(b,c)+(a.xOffset+.5)*(b.width/c.x._max-2*dimple._helpers.xGap(b,c))*a.width:c.x._scale(a.cx)+b.width/c.x._max/2},cy:function(a,b,c){var d=0;return d=null!==c.y.measure&&void 0!==c.y.measure?c.y._scale(a.cy):null!==c.y.categoryFields&&void 0!==c.y.categoryFields&&c.y.categoryFields.length>=2?c.y._scale(a.cy)-b.height/c.y._max+dimple._helpers.yGap(b,c)+(a.yOffset+.5)*(b.height/c.y._max-2*dimple._helpers.yGap(b,c))*a.height:c.y._scale(a.cy)-b.height/c.y._max/2},r:function(a,b,c){var d=0;return d=null===c.z||void 0===c.z?5:c.z._hasMeasure()?c.z._scale(a.r):c.z._scale(b.height/100)},xGap:function(a,b){var c=0;return(null===b.x.measure||void 0===b.x.measure)&&b.barGap>0&&(c=a.width/b.x._max*(b.barGap>.99?.99:b.barGap)/2),c},xClusterGap:function(a,b,c){var d=0;return null!==c.x.categoryFields&&void 0!==c.x.categoryFields&&c.x.categoryFields.length>=2&&c.clusterBarGap>0&&!c.x._hasMeasure()&&(d=a.width*(b.width/c.x._max-2*dimple._helpers.xGap(b,c))*(c.clusterBarGap>.99?.99:c.clusterBarGap)/2),d},yGap:function(a,b){var c=0;return(null===b.y.measure||void 0===b.y.measure)&&b.barGap>0&&(c=a.height/b.y._max*(b.barGap>.99?.99:b.barGap)/2),c},yClusterGap:function(a,b,c){var d=0;return null!==c.y.categoryFields&&void 0!==c.y.categoryFields&&c.y.categoryFields.length>=2&&c.clusterBarGap>0&&!c.y._hasMeasure()&&(d=a.height*(b.height/c.y._max-2*dimple._helpers.yGap(b,c))*(c.clusterBarGap>.99?.99:c.clusterBarGap)/2),d},x:function(a,b,c){return c.x._scale(a.x)+dimple._helpers.xGap(b,c)+a.xOffset*(dimple._helpers.width(a,b,c)+2*dimple._helpers.xClusterGap(a,b,c))+dimple._helpers.xClusterGap(a,b,c)},y:function(a,b,c){var d=0;return d=null!==c.y.measure&&void 0!==c.y.measure?c.y._scale(a.y):c.y._scale(a.y)-b.height/c.y._max+dimple._helpers.yGap(b,c)+a.yOffset*(dimple._helpers.height(a,b,c)+2*dimple._helpers.yClusterGap(a,b,c))+dimple._helpers.yClusterGap(a,b,c)},width:function(a,b,c){var d=0;return d=null!==c.x.measure&&void 0!==c.x.measure?Math.abs(c.x._scale(a.width)-c.x._scale(0)):a.width*(b.width/c.x._max-2*dimple._helpers.xGap(b,c))-2*dimple._helpers.xClusterGap(a,b,c)},height:function(a,b,c){var d=0;return d=null!==c.y.measure&&void 0!==c.y.measure?Math.abs(c.y._scale(0)-c.y._scale(a.height)):a.height*(b.height/c.y._max-2*dimple._helpers.yGap(b,c))-2*dimple._helpers.yClusterGap(a,b,c)},opacity:function(a,b,c){var d=0;return d=null!==c.c&&void 0!==c.c?a.opacity:b.getColor(a.aggField.slice(-1)[0]).opacity},fill:function(a,b,c){var d=0;return d=null!==c.c&&void 0!==c.c?a.fill:b.getColor(a.aggField.slice(-1)[0]).fill},stroke:function(a,b,c){var d=0;return d=null!==c.c&&void 0!==c.c?a.stroke:b.getColor(a.aggField.slice(-1)[0]).stroke}},dimple._rollUp=function(a,b,c){var d=[];return b=null!==b&&void 0!==b?[].concat(b):[],a.forEach(function(a){var e=-1,f={},g=!0;d.forEach(function(c,d){-1===e&&(g=!0,b.forEach(function(b){g=g&&a[b]===c[b]},this),g&&(e=d))},this),-1!==e?f=d[e]:(b.forEach(function(b){f[b]=a[b]},this),d.push(f),e=d.length-1),c.forEach(function(c){-1===b.indexOf(c)&&(void 0===f[c]&&(f[c]=[]),f[c]=f[c].concat(a[c]))},this),d[e]=f},this),d},dimple.filterData=function(a,b,c){var d=a;return null!==b&&null!==c&&(null!==c&&void 0!==c&&(c=[].concat(c)),d=[],a.forEach(function(a){null===a[b]?d.push(a):c.indexOf([].concat(a[b]).join("/"))>-1&&d.push(a)},this)),d},dimple.getUniqueValues=function(a,b){var c=[];return null!==b&&void 0!==b&&(b=[].concat(b),a.forEach(function(a){var d="";b.forEach(function(b,c){c>0&&(d+="/"),d+=a[b]},this),-1===c.indexOf(d)&&c.push(d)},this)),c},dimple.newSvg=function(a,b,c){var d=null;if((null===a||void 0===a)&&(a="body"),d=d3.select(a),d.empty())throw"The '"+a+"' selector did not match any elements. Please prefix with '#' to select by id or '.' to select by class";return d.append("svg").attr("width",b).attr("height",c)}}(); \ No newline at end of file +var dimple={version:"1.0.0",plot:{},aggregateMethod:{}};!function(){"use strict";dimple.axis=function(a,b,c,d){this.chart=a,this.position=b,this.categoryFields=c,this.measure=d,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._orderRules=[],this._groupOrderRules=[],this._draw=null,this._getFormat=function(){var a,b,c,d,e,f,g;return this.showPercent?a=d3.format("%"):null!==this.measure?(b=Math.floor(Math.abs(this._max),0).toString(),c=Math.floor(Math.abs(this._min),0).toString(),d=Math.max(c.length,b.length),d>3?(e=Math.min(Math.floor((d-1)/3),4),f="kmBT".substring(e-1,e),g=1>=d-3*e?1:0,a=function(a){return 0===a?0:d3.format(",."+g+"f")(a/Math.pow(1e3,e))+f}):(g=1>=d?1:0,a=d3.format(",."+g+"f"))):a=function(a){return a},a},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(a){var b,c,d,e,f=[],g=function(a,b,c){var d,e=a.categoryFields[0],f=e,g=!1,h=!0,i=[];for(d=0;d1?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?(f=g(this,"x","y"),this._scale=d3.scale.ordinal().rangePoints([this.chart.x,this.chart.x+this.chart.width]).domain(f.concat([""]))):this._scale=d3.scale.linear().range([this.chart.x,this.chart.x+this.chart.width]).domain([this._min,this._max]).nice(),!this.hidden)switch(this.chart._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)}}else if(this.position.length>0&&"y"===this.position[0]){if(null===this.measure||void 0===this.measure?(f=g(this,"y","x"),this._scale=d3.scale.ordinal().rangePoints([this.chart.y+this.chart.height,this.chart.y]).domain(f.concat([""]))):this._scale=d3.scale.linear().range([this.chart.y+this.chart.height,this.chart.y]).domain([this._min,this._max]).nice(),!this.hidden)switch(this.chart._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)}}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]));return(null===a||void 0===a||a===!1)&&null!==this._scale&&null!==this._scale.ticks&&void 0!==this._scale.ticks&&this._scale.ticks(10).length>0&&(b=this._scale.ticks(10),c=b[1]-b[0],d=((this._max-this._min)%c).toFixed(0),0!==d&&(this._max=Math.ceil(this._max/c)*c,this._min=Math.floor(this._min/c)*c,this._update(!0))),e=this._scale.copy()(0),this._origin!==e&&(this._previousOrigin=null===this._origin?e:this._origin,this._origin=e),this},this.addGroupOrderRule=function(a,b){this._groupOrderRules.push({ordering:a,desc:b})},this.addOrderRule=function(a,b){this._orderRules.push({ordering:a,desc:b})}},dimple.chart=function(a,b){this.svg=a,this.x=.1*a[0][0].width.baseVal.value,this.y=.1*a[0][0].height.baseVal.value,this.width=.8*a[0][0].width.baseVal.value,this.height=.8*a[0][0].height.baseVal.value,this.data=b,this.noFormats=!1,this.axes=[],this.series=[],this.legends=[],this.storyboard=null,this.titleShape=null,this.shapes=null,this._group=a.append("g"),this._tooltipGroup=null,this._assignedColors={},this._nextColor=0,this._axisIndex=function(a,b){var c=0,d=0,e=-1;for(c=0;c0&&(n=this.storyboard.categoryFields[0],o=dimple._getOrderedList(this.data,n,this.storyboard._orderRules)),a.x._hasCategories()&&a.x._hasMeasure()&&(r=a.x.categoryFields[0],s=dimple._getOrderedList(this.data,r,a.x._orderRules.concat([{ordering:a.x.measure,desc:!0}]))),a.y._hasCategories()&&a.y._hasMeasure()&&(t=a.y.categoryFields[0],u=dimple._getOrderedList(this.data,t,a.y._orderRules.concat([{ordering:a.y.measure,desc:!0}]))),null!==a.categoryFields&&void 0!==a.categoryFields&&a.categoryFields.length>0&&(v=a._orderRules,p=a.categoryFields[0],null!==a.c&&void 0!==a.c&&a.c._hasMeasure()?v.push({ordering:a.c.measure,desc:!0}):null!==a.z&&void 0!==a.z&&a.z._hasMeasure()?v.push({ordering:a.z.measure,desc:!0}):a.x._hasMeasure()?v.push({ordering:a.x.measure,desc:!0}):a.y._hasMeasure()&&v.push({ordering:a.y.measure,desc:!0}),q=dimple._getOrderedList(this.data,p,v)),w.sort(function(a,b){var c=0;return""!==n&&(c=o.indexOf(a[n])-o.indexOf(b[n])),""!==r&&0===c&&(c=s.indexOf(a[r])-s.indexOf(b[r])),""!==t&&0===c&&(c=u.indexOf(a[t])-u.indexOf(b[t])),""!==p&&0===c&&(c=q.indexOf(a[p])-q.indexOf(b[p])),c}),w.forEach(function(b){var c,g,h,i,j=-1,k=e(a.x,b),l=e(a.y,b),m=e(a.z,b),n=[];for(null===a.categoryFields||void 0===a.categoryFields||0===a.categoryFields.length?n=["All"]:1===a.categoryFields.length&&void 0===b[a.categoryFields[0]]?n=[a.categoryFields[0]]:a.categoryFields.forEach(function(a){n.push(b[a])},this),c=n.join("/")+"_"+k.join("/")+"_"+l.join("/")+"_"+m.join("/"),g=0;g0&&(m+="/"),m+=b[a],i=m===g},this)),null!==c&&void 0!==c&&null!==c.measure&&void 0!==c.measure&&i&&(h=d[j],-1===h[c.position+"ValueList"].indexOf(b[c.measure])&&h[c.position+"ValueList"].push(b[c.measure]),isNaN(parseFloat(b[c.measure]))&&(f[c.position]=!0),k.value=h[c.position+"Value"],k.count=h[c.position+"Count"],l.value=b[c.measure],h[c.position+"Value"]=a.aggregate(k,l),h[c.position+"Count"]+=1)},i(a.x,this.storyboard),i(a.y,this.storyboard),i(a.z,this.storyboard),i(a.c,this.storyboard)},this),null!==a.x&&void 0!==a.x&&a.x._hasCategories()&&a.x.categoryFields.length>1&&void 0!==g.x&&(x=[],a.y._hasMeasure()&&x.push({ordering:a.y.measure,desc:!0}),g.x=dimple._getOrderedList(this.data,a.x.categoryFields[1],a.x._groupOrderRules.concat(x))),null!==a.y&&void 0!==a.y&&a.y._hasCategories()&&a.y.categoryFields.length>1&&void 0!==g.y&&(x=[],a.x._hasMeasure()&&x.push({ordering:a.x.measure,desc:!0}),g.y=dimple._getOrderedList(this.data,a.y.categoryFields[1],a.y._groupOrderRules.concat(x)),g.y.reverse()),d.forEach(function(c){null!==a.x&&(f.x===!0&&(c.xValue=c.xValueList.length),b=(null===h.x[c.xField.join("/")]||void 0===h.x[c.xField.join("/")]?0:h.x[c.xField.join("/")])+(a.y._hasMeasure()?Math.abs(c.yValue):0),h.x[c.xField.join("/")]=b),null!==a.y&&(f.y===!0&&(c.yValue=c.yValueList.length),b=(null===h.y[c.yField.join("/")]||void 0===h.y[c.yField.join("/")]?0:h.y[c.yField.join("/")])+(a.x._hasMeasure()?Math.abs(c.xValue):0),h.y[c.yField.join("/")]=b),null!==a.z&&(f.z===!0&&(c.zValue=c.zValueList.length),b=(null===h.z[c.zField.join("/")]||void 0===h.z[c.zField.join("/")]?0:h.z[c.zField.join("/")])+(a.z._hasMeasure()?Math.abs(c.zValue):0),h.z[c.zField.join("/")]=b),null!==a.c&&((null===i.min||c.cValuei.max)&&(i.max=c.cValue))},this);for(c in h.x)h.x.hasOwnProperty(c)&&(m.x+=h.x[c]);for(c in h.y)h.y.hasOwnProperty(c)&&(m.y+=h.y[c]);for(c in h.z)h.z.hasOwnProperty(c)&&(m.z+=h.z[c]);d.forEach(function(b){var c,d,e,f,n,o=function(c,d,e){var f,i,n,o,p;null!==c&&void 0!==c&&(o=c.position,c._hasCategories()?c._hasMeasure()?(f=b[c.position+"Field"].join("/"),i=c.showPercent?h[c.position][f]/m[c.position]:h[c.position][f],-1===k.indexOf(f)&&(l[f]=i+(k.length>0?l[k[k.length-1]]:0),k.push(f)),n=b[o+"Bound"]=b["c"+o]="x"!==o&&"y"!==o||!a.stacked?i:l[f],b[e]=i,b[o]=n-("x"===o&&i>=0||"y"===o&&0>=i?i:0)):(b[o]=b["c"+o]=b[o+"Field"][0],b[e]=1,void 0!==g[o]&&null!==g[o]&&g[o].length>=2&&(b[o+"Offset"]=g[o].indexOf(b[o+"Field"][1]),b[e]=1/g[o].length)):(i=c.showPercent?b[o+"Value"]/h[d][b[d+"Field"].join("/")]:b[o+"Value"],f=b[d+"Field"].join("/")+(b[o+"Value"]>=0),p=j[o][f]=(null===j[o][f]||void 0===j[o][f]||"z"===o?0:j[o][f])+i,n=b[o+"Bound"]=b["c"+o]="x"!==o&&"y"!==o||!a.stacked?i:p,b[e]=i,b[o]=n-("x"===o&&i>=0||"y"===o&&0>=i?i:0)))};o(a.x,"y","width"),o(a.y,"x","height"),o(a.z,"z","r"),null!==a.c&&i.min!==i.max&&(i.min=null!==a.c.overrideMin&&void 0!==a.c.overrideMin?a.c.overrideMin:i.min,i.max=null!==a.c.overrideMax&&void 0!==a.c.overrideMax?a.c.overrideMax:i.max,b.cValue=b.cValue>i.max?i.max:b.cValue1?(c=d3.rgb(a.c.colors[Math.floor(f)]),d=d3.rgb(a.c.colors[Math.ceil(f)])):(c=d3.rgb("white"),d=d3.rgb(this.getColor(b.aggField.slice(-1)[0]).fill)),c.r=Math.floor(c.r+(d.r-c.r)*n),c.g=Math.floor(c.g+(d.g-c.g)*n),c.b=Math.floor(c.b+(d.b-c.b)*n),b.fill=c.toString(),b.stroke=c.darker(.5).toString())},this),a._positionData=d},this)},this._registerEventHandlers=function(a){null!==a._eventHandlers&&a._eventHandlers.length>0&&a._eventHandlers.forEach(function(b){null!==b.handler&&"function"==typeof b.handler&&a.shapes.on(b.event,function(c){var d=new dimple.eventArgs;null!==a.chart.storyboard&&(d.frameValue=a.chart.storyboard.getFrameValue()),d.seriesValue=c.aggField,d.xValue=c.x,d.yValue=c.y,d.zValue=c.z,d.colorValue=c.cValue,d.seriesShapes=a.shapes,d.selectedShape=d3.select(this),b.handler(d)})},this)},this.addAxis=function(a,b,c){null!==b&&void 0!==b&&(b=[].concat(b));var d=new dimple.axis(this,a,b,c);return this.axes.push(d),d},this.addCategoryAxis=function(a,b){return this.addAxis(a,b,null)},this.addColorAxis=function(a,b){var c=this.addAxis("c",null,a);return c.colors=null===b||void 0===b?null:[].concat(b),c},this.addLegend=function(a,b,c,d,e,f){f=null===f||void 0===f?this.series:[].concat(f),e=null===e||void 0===e?"left":e;var g=new dimple.legend(this,a,b,c,d,e,f);return this.legends.push(g),g},this.addMeasureAxis=function(a,b){return this.addAxis(a,null,b)},this.addPctAxis=function(a,b){var c=this.addMeasureAxis(a,b);return c.showPercent=!0,c},this.addSeries=function(a,b,c){(null===c||void 0===c)&&(c=this.axes),(null===b||void 0===b)&&(b=dimple.plot.bubble);var d,e=null,f=null,g=null,h=null;return c.forEach(function(a){null!==a&&b.supportedAxes.indexOf(a.position)>-1&&(null===e&&"x"===a.position[0]?e=a:null===f&&"y"===a.position[0]?f=a:null===g&&"z"===a.position[0]?g=a:null===h&&"c"===a.position[0]&&(h=a))},this),null!==a&&void 0!==a&&(a=[].concat(a)),d=new dimple.series(this,a,e,f,g,h,b,dimple.aggregateMethod.sum,b.stacked),this.series.push(d),d},this.assignColor=function(a,b,c,d){return this._assignedColors[a]=new dimple.color(b,c,d),this._assignedColors[a]},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(a){a=null===a||void 0===a?0:a;var b,c=null,d=null,e=!1,f=!1;return this._getSeriesData(),this.axes.forEach(function(a){if(a._min=0,a._max=0,null!==a.measure&&void 0!==a.measure){var e=!1;this.series.forEach(function(b){if(b[a.position]===a){var c=b._axisBounds(a.position);a._min>c.min&&(a._min=c.min),a._maxb[a.measure]&&(a._min=b[a.measure]),a._max0&&(b!==c||null!==d.categoryFields&&0!==d.categoryFields.length||g(b.shapes.selectAll(".axis text")).attr("y",this.y+this.height-d._scale(0)+9),b!==d||null!==c.categoryFields&&0!==c.categoryFields.length||g(b.shapes.selectAll(".axis text")).attr("x",-1*(c._scale(0)-this.x)-9))),this.noFormats||(g(b.shapes.selectAll(".axis text")).style("font-family","sans-serif").style("font-size",(this.height/35>10?this.height/35:10)+"px"),g(b.shapes.selectAll(".axis path, .axis line")).style("fill","none").style("stroke","black").style("shape-rendering","crispEdges"),null!==b.gridlineShapes&&g(b.gridlineShapes.selectAll(".gridlines line")).style("fill","none").style("stroke","lightgray").style("opacity",.8)),(null===b.measure||void 0===b.measure)&&(b===c?(m=0,b.shapes.selectAll(".axis text").each(function(){var a=this.getComputedTextLength();m=a>m?a:m}),m>this.width/b._max&&(l=!0,b.shapes.selectAll(".axis text").style("text-anchor","start").each(function(){var a=this.getBBox();d3.select(this).attr("transform","rotate(90,"+a.x+","+(a.y+a.height/2)+") translate(-5, 0)")}))):"x"===b.position&&(m=0,b.shapes.selectAll(".axis text").each(function(){var a=this.getComputedTextLength();m=a>m?a:m}),m>this.width/b._max&&b.shapes.selectAll(".axis text").style("text-anchor","end").each(function(){var a=this.getBBox();d3.select(this).attr("transform","rotate(90,"+(a.x+a.width)+","+(a.y+a.height/2)+") translate(5, 0)")}))),null===b.titleShape&&null!==b.shapes&&null!==b.shapes.node().firstChild&&(b.shapes.selectAll(".axis text").each(function(){var a=this.getBBox();n.l=null===n.l||a.xn.r?a.x+a.width:n.r,n.b=l?null===n.b||a.y+a.width>n.b?a.y+a.width:n.b:null===n.b||a.y+a.height>n.b?a.y+a.height:n.b}),"x"===b.position?(p=b===c?this.y+this.height+n.b+10:this.y+n.l+n.t-5,o=this.x+this.width/2):"y"===b.position&&(o=b===d?this.x+n.l-10:this.x+this.width+n.r+10,p=this.y+this.height/2,q="rotate(270, "+o+", "+p+")"),b.titleShape=this._group.append("text").attr("class","axis title"),b.titleShape.attr("x",o).attr("y",p).attr("text-anchor","middle").attr("transform",q).text(null===b.categoryFields||void 0===b.categoryFields||0===b.categoryFields.length?b.measure:b.categoryFields.join("/")).each(function(){r.noFormats||d3.select(this).style("font-family","sans-serif").style("font-size",(r.height/35>10?r.height/35:10)+"px")}),b===c?b.titleShape.each(function(){d3.select(this).attr("y",p+this.getBBox().height/1.65)}):b===d&&b.titleShape.each(function(){d3.select(this).attr("x",o+this.getBBox().height/1.65)}))},this),this.series.forEach(function(b){b.plot.draw(this,b,a),this._registerEventHandlers(b)},this),this.legends.forEach(function(b){b._draw(a)},this),null!==this.storyboard&&void 0!==this.storyboard&&(this.storyboard._drawText(),this.storyboard.autoplay&&this.storyboard.startAnimation()),this},this.getColor=function(a){return(null===this._assignedColors[a]||void 0===this._assignedColors[a])&&(this._assignedColors[a]=this.defaultColors[this._nextColor],this._nextColor=(this._nextColor+1)%this.defaultColors.length),this._assignedColors[a]},this.setBounds=function(a,b,c,d){return this.x=a,this.y=b,this.width=c,this.height=d,this.axes.forEach(function(a){a._update()},this),this},this.setStoryboard=function(a,b){return this.storyboard=new dimple.storyboard(this,a),null!==b&&void 0!==b&&(this.storyboard.onTick=b),this.storyboard}},dimple.color=function(a,b,c){this.fill=a,this.stroke=null===b||void 0===b?d3.rgb(a).darker(.5).toString():b,this.opacity=null===c||void 0===c?.8:c},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(a,b,c,d,e,f,g){this.chart=a,this.series=g,this.x=b,this.y=c,this.width=d,this.height=e,this.horizontalAlign=f,this.shapes=null,this._draw=function(a){var b,c=this._getEntries(),d=0,e=0,f=0,g=0,h=15,i=9,j=this;null!==this.shapes&&void 0!==this.shapes&&this.shapes.transition().duration(.2*a).attr("opacity",0).remove(),b=this.chart._group.selectAll(".dontSelectAny").data(c).enter().append("g").attr("class","legend").attr("opacity",0),b.append("text").attr("id",function(a){return"legend_"+a.key}).attr("class","legendText").text(function(a){return a.key}).call(function(){j.chart.noFormats||this.style("font-family","sans-serif").style("font-size",(j.chart.height/35>10?j.chart.height/35:10)+"px").style("shape-rendering","crispEdges")}).each(function(){var a=this.getBBox();a.width>d&&(d=a.width),a.height>e&&(e=a.height)}),b.append("rect").attr("class","legendKey").attr("height",i).attr("width",h),e=(i>e?i:e)+2,d+=h+20,b.each(function(a){f+d>j.width&&(f=0,g+=e),g>j.height?d3.select(this).remove():(d3.select(this).select("text").attr("x","left"===j.horizontalAlign?j.x+h+5+f:j.x+(j.width-f-d)+h+5).attr("y",function(){return j.y+g+this.getBBox().height/1.65}).attr("width",j.width).attr("height",j.height),d3.select(this).select("rect").attr("class","legend legendKey").attr("x","left"===j.horizontalAlign?j.x+f:j.x+(j.width-f-d)).attr("y",j.y+g).attr("height",i).attr("width",h).style("fill",function(){return dimple._helpers.fill(a,j.chart,a.series)}).style("stroke",function(){return dimple._helpers.stroke(a,j.chart,a.series)}).style("opacity",function(){return dimple._helpers.opacity(a,j.chart,a.series)}).style("shape-rendering","crispEdges"),f+=d)}),b.transition().delay(.2*a).duration(.8*a).attr("opacity",1),this.shapes=b},this._getEntries=function(){var a=[];return null!==this.series&&void 0!==this.series&&this.series.forEach(function(b){var c=b._positionData;c.forEach(function(c){var d,e=-1;for(d=0;de.max&&(e.max=a[f.position+"Bound"])},this):null===g||null===g.categoryFields||0===g.categoryFields.length?j.forEach(function(a){!this.stacked||"x"!==f.position&&"y"!==f.position?(a[f.position+"Value"]e.max&&(e.max=a[f.position+"Value"])):a[f.position+"Value"]<0?e.min=e.min+a[f.position+"Value"]:e.max=e.max+a[f.position+"Value"]},this):(b=f.position+"Value",c=g.position+"Field",d=[],j.forEach(function(a){var e=a[c].join("/"),f=d.indexOf(e);-1===f&&(d.push(e),f=d.length-1),void 0===h[f]&&(h[f]={min:0,max:0},f>=i&&(i=f+1)),this.stacked?a[b]<0?h[f].min=h[f].min+a[b]:h[f].max=h[f].max+a[b]:(a[b]h[f].max&&(h[f].max=a[b]))},this),h.forEach(function(a){void 0!==a&&(a.mine.max&&(e.max=a.max))},this)),e},this._dropLineOrigin=function(){var a=0,b=0,c={x:null,y:null},d={x:null,y:null};return this.chart.axes.forEach(function(a){"x"===a.position&&null===d.x?d.x=a._origin:"y"===a.position&&null===d.y&&(d.y=a._origin)},this),this.chart.axes.forEach(function(e){"x"!==e.position||this.x.hidden?"y"!==e.position||this.y.hidden||(e===this.y&&(0===b?c.x=d.x:1===b&&(c.x=this.chart.x+this.chart.width)),b+=1):(e===this.x&&(0===a?c.y=d.y:1===a&&(c.y=this.chart.y)),a+=1)},this),c},this.addEventHandler=function(a,b){this._eventHandlers.push({event:a,handler:b})},this.addOrderRule=function(a,b){this._orderRules.push({ordering:a,desc:b})}},dimple.storyboard=function(a,b){null!==b&&void 0!==b&&(b=[].concat(b)),this.chart=a,this.categoryFields=b,this.autoplay=!0,this.frameDuration=3e3,this.storyLabel=null,this.onTick=null,this._frame=0,this._animationTimer=null,this._categories=[],this._cachedCategoryFields=[],this._orderRules=[],this._drawText=function(a){if(null===this.storyLabel||void 0===this.storyLabel){var b=this,c=0;this.chart.axes.forEach(function(a){"x"===a.position&&(c+=1)},this),this.storyLabel=this.chart._group.append("text").attr("x",this.chart.x+.01*this.chart.width).attr("y",this.chart.y+(this.chart.height/35>10?this.chart.height/35:10)*(c>1?1.25:-1)).call(function(){b.noFormats||this.style("font-family","sans-serif").style("font-size",(b.height/35>10?b.height/35:10)+"px")})}this.storyLabel.transition().duration(.2*a).attr("opacity",0),this.storyLabel.transition().delay(.2*a).text(this.categoryFields.join("\\")+": "+this.getFrameValue()).transition().duration(.8*a).attr("opacity",1)},this._getCategories=function(){return this._categoryFields!==this._cachedCategoryFields&&(this._categories=[],this.chart.data.forEach(function(a){var b=-1,c="";null!==this.categoryFields&&(this.categoryFields.forEach(function(b,d){d>0&&(c+="/"),c+=a[b]},this),b=this._categories.indexOf(c),-1===b&&(this._categories.push(c),b=this._categories.length-1))},this),this._cachedCategoryFields=this._categoryFields),this._categories},this._goToFrameIndex=function(a){this._frame=a%this._getCategories().length,this.chart.draw(this.frameDuration/2)},this.addOrderRule=function(a,b){this._orderRules.push({ordering:a,desc:b})},this.getFrameValue=function(){var a=null;return this._frame>=0&&this._getCategories().length>this._frame&&(a=this._getCategories()[this._frame]),a},this.goToFrame=function(a){if(this._getCategories().length>0){var b=this._getCategories().indexOf(a);this._goToFrameIndex(b)}},this.pauseAnimation=function(){null!==this._animationTimer&&(window.clearInterval(this._animationTimer),this._animationTimer=null)},this.startAnimation=function(){null===this._animationTimer&&(null!==this.onTick&&this.onTick(this.getFrameValue()),this._animationTimer=window.setInterval(function(a){return function(){a._goToFrameIndex(a._frame+1),null!==a.onTick&&a.onTick(a.getFrameValue()),a._drawText(a.frameDuration/2)}}(this),this.frameDuration))},this.stopAnimation=function(){null!==this._animationTimer&&(window.clearInterval(this._animationTimer),this._animationTimer=null,this._frame=0)}},dimple.aggregateMethod.avg=function(a,b){return a.value=null===a.value||void 0===a.value?0:parseFloat(a.value),a.count=null===a.count||void 0===a.count?1:parseFloat(a.count),b.value=null===b.value||void 0===b.value?0:parseFloat(b.value),b.count=null===b.count||void 0===b.count?1:parseFloat(b.count),(a.value*a.count+b.value*b.count)/(a.count+b.count)},dimple.aggregateMethod.count=function(a,b){return a.count=null===a.count||void 0===a.count?0:parseFloat(a.count),b.count=null===b.count||void 0===b.count?0:parseFloat(b.count),a.count+b.count},dimple.aggregateMethod.max=function(a,b){return a.value=null===a.value||void 0===a.value?0:parseFloat(a.value),b.value=null===b.value||void 0===b.value?0:parseFloat(b.value),a.value>b.value?a.value:b.value},dimple.aggregateMethod.min=function(a,b){return null===a.value?parseFloat(b.value):parseFloat(a.value)=0;i-=1)if(f=e[i],h={cx:0,cy:0,height:0,width:0,xOffset:0,yOffset:0},b.x._hasCategories()){if(h.cx=f.cx,h.width=f.width,h.xOffset=f.xOffset,void 0===k[f.xField])k[f.xField]=[];else{for(p=0,j=0;j<=k[f.xField].length;j+=1)m=k[f.xField][j],(f.cy>=0&&m>=0||f.cy<=0&&0>=m)&&Math.abs(m)<=Math.abs(f.cy)&&Math.abs(m)>Math.abs(p)&&(p=m);h.cy=p}o.push(h),k[f.xField].push(f.cy)}else if(b.y._hasCategories()){if(h.cy=f.cy,h.height=f.height,h.yOffset=f.yOffset,void 0===k[f.yField])k[f.yField]=[];else{for(p=0,l=0;l<=k[f.yField].length;l+=1)n=k[f.yField][l],(f.cx>=0&&n>=0||f.cx<=0&&0>=n)&&Math.abs(n)<=Math.abs(f.cx)&&Math.abs(n)>Math.abs(p)&&(p=n);h.cx=p}o.push(h),k[f.yField].push(f.cx)}return d(e.concat(o).concat(e[0]))}).call(function(){a.noFormats||this.attr("fill",function(b){return j?"url(#fill-area-gradient-"+b.join("_").replace(" ","")+")":a.getColor(b).fill}).attr("stroke",function(b){return j?"url(#stroke-area-gradient-"+b.join("_").replace(" ","")+")":a.getColor(b).stroke}).attr("stroke-width",b.lineWeight)}),e=a._group.selectAll(".markers").data(g).enter(),b.lineMarkers&&e.append("circle").transition().duration(c).attr("cx",function(c){return dimple._helpers.cx(c,a,b)}).attr("cy",function(c){return dimple._helpers.cy(c,a,b)}).attr("r",2+b.lineWeight).attr("fill","white").attr("stroke","none"),e.append("circle").on("mouseover",function(c){f.enterEventHandler(c,this,a,b)}).on("mouseleave",function(c){f.leaveEventHandler(c,this,a,b)}).transition().duration(c).attr("cx",function(c){return dimple._helpers.cx(c,a,b)}).attr("cy",function(c){return dimple._helpers.cy(c,a,b)}).attr("r",2+b.lineWeight).attr("opacity",function(c){return b.lineMarkers?a.getColor(c).opacity:0}).call(function(){a.noFormats||this.attr("fill","white").style("stroke-width",b.lineWeight).attr("stroke",function(c){return dimple._helpers.stroke(c,a,b)})})},enterEventHandler:function(a,b,c,d){var e,f,g,h=5,i=10,j=750,k=d3.select(b),l=parseFloat(k.attr("cx")),m=parseFloat(k.attr("cy")),n=parseFloat(k.attr("r")),o=dimple._helpers.opacity(a,c,d),p=dimple._helpers.fill(a,c,d),q=d._dropLineOrigin(),r=d3.rgb(d3.rgb(p).r+.6*(255-d3.rgb(p).r),d3.rgb(p).g+.6*(255-d3.rgb(p).g),d3.rgb(p).b+.6*(255-d3.rgb(p).b)),s=d3.rgb(d3.rgb(p).r+.8*(255-d3.rgb(p).r),d3.rgb(p).g+.8*(255-d3.rgb(p).g),d3.rgb(p).b+.8*(255-d3.rgb(p).b)),t=0,u=0,v=0,w=[];null!==c._tooltipGroup&&void 0!==c._tooltipGroup&&c._tooltipGroup.remove(),c._tooltipGroup=c.svg.append("g"),k.style("opacity",1),c._tooltipGroup.append("circle").attr("cx",l).attr("cy",m).attr("r",n).attr("opacity",0).style("fill","none").style("stroke",p).style("stroke-width",1).transition().duration(j/2).ease("linear").attr("opacity",1).attr("r",n+4).style("stroke-width",2),null!==q.y&&c._tooltipGroup.append("line").attr("x1",l).attr("y1",m0&&d.categoryFields.forEach(function(b,c){w.push(b+(a.aggField!==b?": "+a.aggField[c]:""))},this),d.x._hasCategories()?d.x.categoryFields.forEach(function(b,c){w.push(b+(a.xField!==b?": "+a.xField[c]:""))},this):w.push(d.x.measure+": "+d.x._getFormat()(a.cx)),d.y._hasCategories()?d.y.categoryFields.forEach(function(b,c){w.push(b+(a.yField!==b?": "+a.yField[c]:"")) +},this):w.push(d.y.measure+":"+d.y._getFormat()(a.cy)),null!==d.z&&void 0!==d.z&&w.push(d.z.measure+": "+d.z._getFormat()(a.zValue)),null!==d.c&&void 0!==d.c&&w.push(d.c.measure+": "+d.c._getFormat()(a.cValue)),w=w.filter(function(a,b){return w.indexOf(a)===b}),e.selectAll(".textHoverShapes").data(w).enter().append("text").text(function(a){return a}).style("font-family","sans-serif").style("font-size","10px"),e.each(function(){u=this.getBBox().width>u?this.getBBox().width:u,v=this.getBBox().width>v?this.getBBox().height:v}),e.selectAll("text").attr("x",0).attr("y",function(){return t+=this.getBBox().height,t-this.getBBox().height/2}),f.attr("x",-h).attr("y",-h).attr("height",Math.floor(t+h)-.5).attr("width",u+2*h).attr("rx",5).attr("ry",5).style("fill",s).style("stroke",r).style("stroke-width",2).style("opacity",.95),g=l+n+h+i+u>parseFloat(c.svg.attr("width")),e.attr("transform","translate("+(g?l-(n+h+i+u):l+n+h+i)+" , "+(m-(t-(v-h))/2)+")")},leaveEventHandler:function(a,b,c,d){d3.select(b).style("opacity",d.lineMarkers?dimple._helpers.opacity(a,c,d):0),null!==c._tooltipGroup&&void 0!==c._tooltipGroup&&c._tooltipGroup.remove()}},dimple.plot.bar={stacked:!0,supportedAxes:["x","y","c"],draw:function(a,b,c){var d=this,e=b._positionData,f=null,g="series"+a.series.indexOf(b);a._group.selectAll(".hoverShapes").transition().duration(c/4).style("opacity",0).remove(),f=null===b.shapes||void 0===b.shapes?a._group.selectAll("."+g).data(e):b.shapes.data(e,function(a){return a.key}),f.enter().append("rect").attr("id",function(a){return a.key}).attr("class",function(a){return g+" bar "+a.aggField.join(" ")+" "+a.xField.join(" ")+" "+a.yField.join(" ")}).attr("x",function(c){return dimple._helpers.x(c,a,b)}).attr("y",function(c){return dimple._helpers.y(c,a,b)+dimple._helpers.height(c,a,b)}).attr("width",function(c){return null!==c.xField&&c.xField.length>0?dimple._helpers.width(c,a,b):0}).attr("height",function(c){return null!==c.yField&&c.yField.length>0?dimple._helpers.height(c,a,b):0}).attr("opacity",function(c){return dimple._helpers.opacity(c,a,b)}).on("mouseover",function(c){d.enterEventHandler(c,this,a,b)}).on("mouseleave",function(){d.leaveEventHandler(a)}).call(function(){a.noFormats||this.attr("fill",function(c){return dimple._helpers.fill(c,a,b)}).attr("stroke",function(c){return dimple._helpers.stroke(c,a,b)})}),f.transition().duration(c).attr("x",function(c){return dimple._helpers.x(c,a,b)}).attr("y",function(c){return dimple._helpers.y(c,a,b)}).attr("width",function(c){return dimple._helpers.width(c,a,b)}).attr("height",function(c){return dimple._helpers.height(c,a,b)}).call(function(){a.noFormats||this.attr("fill",function(c){return dimple._helpers.fill(c,a,b)}).attr("stroke",function(c){return dimple._helpers.stroke(c,a,b)})}),f.exit().transition().duration(c).attr("x",function(c){return dimple._helpers.x(c,a,b)}).attr("y",function(c){return dimple._helpers.y(c,a,b)}).attr("width",function(c){return dimple._helpers.width(c,a,b)}).attr("height",function(c){return dimple._helpers.height(c,a,b)}).each("end",function(){d3.select(this).remove()}),b.shapes=f},enterEventHandler:function(a,b,c,d){var e,f,g=5,h=10,i=750,j=d3.select(b),k=parseFloat(j.attr("x")),l=parseFloat(j.attr("y")),m=parseFloat(j.attr("width")),n=parseFloat(j.attr("height")),o=j.attr("opacity"),p=j.attr("fill"),q=d._dropLineOrigin(),r=d3.rgb(d3.rgb(p).r+.6*(255-d3.rgb(p).r),d3.rgb(p).g+.6*(255-d3.rgb(p).g),d3.rgb(p).b+.6*(255-d3.rgb(p).b)),s=d3.rgb(d3.rgb(p).r+.8*(255-d3.rgb(p).r),d3.rgb(p).g+.8*(255-d3.rgb(p).g),d3.rgb(p).b+.8*(255-d3.rgb(p).b)),t=[],u=0,v=0,w=0;null!==c._tooltipGroup&&void 0!==c._tooltipGroup&&c._tooltipGroup.remove(),c._tooltipGroup=c.svg.append("g"),d.x._hasCategories()||null===q.y||c._tooltipGroup.append("line").attr("x1",k0&&d.categoryFields.forEach(function(b,c){t.push(b+(a.aggField!==b?": "+a.aggField[c]:""))},this),d.x._hasCategories()?d.x.categoryFields.forEach(function(b,c){t.push(b+(a.xField!==b?": "+a.xField[c]:""))},this):t.push(d.x.measure+": "+d.x._getFormat()(a.width)),d.y._hasCategories()?d.y.categoryFields.forEach(function(b,c){t.push(b+(a.yField!==b?": "+a.yField[c]:""))},this):t.push(d.y.measure+":"+d.y._getFormat()(a.height)),null!==d.c&&void 0!==d.c&&t.push(d.c.measure+": "+d.c._getFormat()(d.c.showPercent?a.cPct:a.cValue)),t=t.filter(function(a,b){return t.indexOf(a)===b}),e.selectAll(".textHoverShapes").data(t).enter().append("text").text(function(a){return a}).style("font-family","sans-serif").style("font-size","10px"),e.each(function(){v=this.getBBox().width>v?this.getBBox().width:v,w=this.getBBox().width>w?this.getBBox().height:w}),e.selectAll("text").attr("x",0).attr("y",function(){return u+=this.getBBox().height,u-this.getBBox().height/2}),f.attr("x",-g).attr("y",-g).attr("height",Math.floor(u+g)-.5).attr("width",v+2*g).attr("rx",5).attr("ry",5).style("fill",s).style("stroke",r).style("stroke-width",2).style("opacity",.95),k+m+g+h+v0?e.attr("transform","translate("+(k-(g+h+v))+" , "+(l+n/2-(u-(w-g))/2)+")"):l+n+u+h+g0&&d.categoryFields.forEach(function(b,c){t.push(b+(a.aggField!==b?": "+a.aggField[c]:""))},this),d.x._hasCategories()?d.x.categoryFields.forEach(function(b,c){t.push(b+(a.xField!==b?": "+a.xField[c]:""))},this):t.push(d.x.measure+": "+d.x._getFormat()(a.cx)),d.y._hasCategories()?d.y.categoryFields.forEach(function(b,c){t.push(b+(a.yField!==b?": "+a.yField[c]:""))},this):t.push(d.y.measure+":"+d.y._getFormat()(a.cy)),null!==d.z&&void 0!==d.z&&t.push(d.z.measure+": "+d.z._getFormat()(a.zValue)),null!==d.c&&void 0!==d.c&&t.push(d.c.measure+": "+d.c._getFormat()(a.cValue)),t=t.filter(function(a,b){return t.indexOf(a)===b}),e.selectAll(".textHoverShapes").data(t).enter().append("text").text(function(a){return a}).style("font-family","sans-serif").style("font-size","10px"),e.each(function(){v=this.getBBox().width>v?this.getBBox().width:v,w=this.getBBox().width>w?this.getBBox().height:w}),e.selectAll("text").attr("x",0).attr("y",function(){return u+=this.getBBox().height,u-this.getBBox().height/2}),f.attr("x",-h).attr("y",-h).attr("height",Math.floor(u+h)-.5).attr("width",v+2*h).attr("rx",5).attr("ry",5).style("fill",s).style("stroke",r).style("stroke-width",2).style("opacity",.95),g=l+n+h+i+v>parseFloat(c.svg.attr("width")),e.attr("transform","translate("+(g?l-(n+h+i+v):l+n+h+i)+" , "+(m-(u-(w-h))/2)+")")},leaveEventHandler:function(a){null!==a._tooltipGroup&&void 0!==a._tooltipGroup&&a._tooltipGroup.remove()}},dimple.plot.line={stacked:!1,supportedAxes:["x","y","c"],draw:function(a,b,c){var d,e,f=this,g=b._positionData,h=[],i=[],j=1,k=!1;(b.x._hasCategories()||b.y._hasCategories())&&(j=0),g.forEach(function(a){var b,c=[],d=!1;for(b=j;b0&&d.categoryFields.forEach(function(b,c){w.push(b+(a.aggField!==b?": "+a.aggField[c]:""))},this),d.x._hasCategories()?d.x.categoryFields.forEach(function(b,c){w.push(b+(a.xField!==b?": "+a.xField[c]:""))},this):w.push(d.x.measure+": "+d.x._getFormat()(a.cx)),d.y._hasCategories()?d.y.categoryFields.forEach(function(b,c){w.push(b+(a.yField!==b?": "+a.yField[c]:""))},this):w.push(d.y.measure+": "+d.y._getFormat()(a.cy)),null!==d.z&&void 0!==d.z&&w.push(d.z.measure+": "+d.z._getFormat()(a.zValue)),null!==d.c&&void 0!==d.c&&w.push(d.c.measure+": "+d.c._getFormat()(a.cValue)),w=w.filter(function(a,b){return w.indexOf(a)===b}),e.selectAll(".textHoverShapes").data(w).enter().append("text").text(function(a){return a}).style("font-family","sans-serif").style("font-size","10px"),e.each(function(){u=this.getBBox().width>u?this.getBBox().width:u,v=this.getBBox().width>v?this.getBBox().height:v}),e.selectAll("text").attr("x",0).attr("y",function(){return t+=this.getBBox().height,t-this.getBBox().height/2}),f.attr("x",-h).attr("y",-h).attr("height",Math.floor(t+h)-.5).attr("width",u+2*h).attr("rx",5).attr("ry",5).style("fill",s).style("stroke",r).style("stroke-width",2).style("opacity",.95),g=l+n+h+i+u>parseFloat(c.svg.attr("width")),e.attr("transform","translate("+(g?l-(n+h+i+u):l+n+h+i)+" , "+(m-(t-(v-h))/2)+")")},leaveEventHandler:function(a,b,c,d){d3.select(b).style("opacity",d.lineMarkers?dimple._helpers.opacity(a,c,d):0),null!==c._tooltipGroup&&void 0!==c._tooltipGroup&&c._tooltipGroup.remove()}},dimple._addGradient=function(a,b,c,d,e,f,g){var h=e._group.select("#"+b),i=[],j=c.position+"Field",k=!0,l=[];d.forEach(function(a){-1===i.indexOf(a[j])&&i.push(a[j])},this),i=i.sort(function(a,b){return c._scale(a)-c._scale(b)}),null===h.node()&&(k=!1,h=e._group.append("linearGradient").attr("id",b).attr("gradientUnits","userSpaceOnUse").attr("x1","x"===c.position?c._scale(i[0])+e.width/i.length/2:0).attr("y1","y"===c.position?c._scale(i[0])-e.height/i.length/2:0).attr("x2","x"===c.position?c._scale(i[i.length-1])+e.width/i.length/2:0).attr("y2","y"===c.position?c._scale(i[i.length-1])-e.height/i.length/2:0)),i.forEach(function(b,c){var e={},f=0;for(f=0;f=1&&(c.forEach(function(a){var c=null===a.desc||void 0===a.desc?!1:a.desc,d=a.ordering,f=[],g="string"==typeof d?d:null,h=function(a){var b,c=0;for(b=0;bb[0]&&(c=1):c=Date.parse(a[0])-Date.parse(b[0]):c=parseFloat(d)-parseFloat(e),c};"function"==typeof d?e.push(function(a,b){return(c?-1:1)*d(a,b)}):d instanceof Array?(d.forEach(function(a){f.push([].concat(a).join("|"))},this),e.push(function(a,d){var e,g,h="".concat(a[b]),i="".concat(d[b]);return e=f.indexOf(h),g=f.indexOf(i),e=0>e?c?-1:f.length:e,g=0>g?c?-1:f.length:g,(c?-1:1)*(e-g)})):e.push(function(a,b){var d=0;return void 0!==a[g]&&void 0!==b[g]&&(d=i([].concat(a[g]),[].concat(b[g]))),(c?-1:1)*d})}),d.sort(function(a,b){for(var c=0,d=0;c=2?c.x._scale(a.cx)+dimple._helpers.xGap(b,c)+(a.xOffset+.5)*(b.width/c.x._max-2*dimple._helpers.xGap(b,c))*a.width:c.x._scale(a.cx)+b.width/c.x._max/2},cy:function(a,b,c){var d=0;return d=null!==c.y.measure&&void 0!==c.y.measure?c.y._scale(a.cy):null!==c.y.categoryFields&&void 0!==c.y.categoryFields&&c.y.categoryFields.length>=2?c.y._scale(a.cy)-b.height/c.y._max+dimple._helpers.yGap(b,c)+(a.yOffset+.5)*(b.height/c.y._max-2*dimple._helpers.yGap(b,c))*a.height:c.y._scale(a.cy)-b.height/c.y._max/2},r:function(a,b,c){var d=0;return d=null===c.z||void 0===c.z?5:c.z._hasMeasure()?c.z._scale(a.r):c.z._scale(b.height/100)},xGap:function(a,b){var c=0;return(null===b.x.measure||void 0===b.x.measure)&&b.barGap>0&&(c=a.width/b.x._max*(b.barGap>.99?.99:b.barGap)/2),c},xClusterGap:function(a,b,c){var d=0;return null!==c.x.categoryFields&&void 0!==c.x.categoryFields&&c.x.categoryFields.length>=2&&c.clusterBarGap>0&&!c.x._hasMeasure()&&(d=a.width*(b.width/c.x._max-2*dimple._helpers.xGap(b,c))*(c.clusterBarGap>.99?.99:c.clusterBarGap)/2),d},yGap:function(a,b){var c=0;return(null===b.y.measure||void 0===b.y.measure)&&b.barGap>0&&(c=a.height/b.y._max*(b.barGap>.99?.99:b.barGap)/2),c},yClusterGap:function(a,b,c){var d=0;return null!==c.y.categoryFields&&void 0!==c.y.categoryFields&&c.y.categoryFields.length>=2&&c.clusterBarGap>0&&!c.y._hasMeasure()&&(d=a.height*(b.height/c.y._max-2*dimple._helpers.yGap(b,c))*(c.clusterBarGap>.99?.99:c.clusterBarGap)/2),d},x:function(a,b,c){return c.x._scale(a.x)+dimple._helpers.xGap(b,c)+a.xOffset*(dimple._helpers.width(a,b,c)+2*dimple._helpers.xClusterGap(a,b,c))+dimple._helpers.xClusterGap(a,b,c)},y:function(a,b,c){var d=0;return d=null!==c.y.measure&&void 0!==c.y.measure?c.y._scale(a.y):c.y._scale(a.y)-b.height/c.y._max+dimple._helpers.yGap(b,c)+a.yOffset*(dimple._helpers.height(a,b,c)+2*dimple._helpers.yClusterGap(a,b,c))+dimple._helpers.yClusterGap(a,b,c)},width:function(a,b,c){var d=0;return d=null!==c.x.measure&&void 0!==c.x.measure?Math.abs(c.x._scale(a.width)-c.x._scale(0)):a.width*(b.width/c.x._max-2*dimple._helpers.xGap(b,c))-2*dimple._helpers.xClusterGap(a,b,c)},height:function(a,b,c){var d=0;return d=null!==c.y.measure&&void 0!==c.y.measure?Math.abs(c.y._scale(0)-c.y._scale(a.height)):a.height*(b.height/c.y._max-2*dimple._helpers.yGap(b,c))-2*dimple._helpers.yClusterGap(a,b,c)},opacity:function(a,b,c){var d=0;return d=null!==c.c&&void 0!==c.c?a.opacity:b.getColor(a.aggField.slice(-1)[0]).opacity},fill:function(a,b,c){var d=0;return d=null!==c.c&&void 0!==c.c?a.fill:b.getColor(a.aggField.slice(-1)[0]).fill},stroke:function(a,b,c){var d=0;return d=null!==c.c&&void 0!==c.c?a.stroke:b.getColor(a.aggField.slice(-1)[0]).stroke}},dimple._rollUp=function(a,b,c){var d=[];return b=null!==b&&void 0!==b?[].concat(b):[],a.forEach(function(a){var e=-1,f={},g=!0;d.forEach(function(c,d){-1===e&&(g=!0,b.forEach(function(b){g=g&&a[b]===c[b]},this),g&&(e=d))},this),-1!==e?f=d[e]:(b.forEach(function(b){f[b]=a[b]},this),d.push(f),e=d.length-1),c.forEach(function(c){-1===b.indexOf(c)&&(void 0===f[c]&&(f[c]=[]),f[c]=f[c].concat(a[c]))},this),d[e]=f},this),d},dimple.filterData=function(a,b,c){var d=a;return null!==b&&null!==c&&(null!==c&&void 0!==c&&(c=[].concat(c)),d=[],a.forEach(function(a){null===a[b]?d.push(a):c.indexOf([].concat(a[b]).join("/"))>-1&&d.push(a)},this)),d},dimple.getUniqueValues=function(a,b){var c=[];return null!==b&&void 0!==b&&(b=[].concat(b),a.forEach(function(a){var d="";b.forEach(function(b,c){c>0&&(d+="/"),d+=a[b]},this),-1===c.indexOf(d)&&c.push(d)},this)),c},dimple.newSvg=function(a,b,c){var d=null;if((null===a||void 0===a)&&(a="body"),d=d3.select(a),d.empty())throw"The '"+a+"' selector did not match any elements. Please prefix with '#' to select by id or '.' to select by class";return d.append("svg").attr("width",b).attr("height",c)}}(); \ No newline at end of file diff --git a/examples/advanced_trellis_bar.html b/examples/advanced_trellis_bar.html index d3105b2..3b45b58 100644 --- a/examples/advanced_trellis_bar.html +++ b/examples/advanced_trellis_bar.html @@ -9,29 +9,24 @@ var months = dimple.getUniqueValues(data, "Date"); // Set the bounds for the charts - var row = 2, - col = 3, + var row = 0, + col = 0, top = 25, left = 60, inMarg = 15, width = 115, height = 90; - // Sort the months in descending order so that when tooltips are drawn - // they won't be behind the chart on the right. This is because all - // chart shapes (including tooltips) are grouped. - months.sort(function (a, b) { return Date.parse(b) - Date.parse(a); }); - // Pick the latest 12 dates - months = months.slice(0, 12); + months = months.slice(months.length - 12); // Draw a chart for each of the 12 dates months.forEach(function (month) { // Wrap to the row above - if (col < 0) { - row -= 1; - col = 3; + if (left + ((col + 1) * (width + inMarg)) > parseFloat(svg.attr("width"))) { + row += 1; + col = 0; } // Filter for the month in the iteration @@ -88,7 +83,7 @@ x.titleShape.remove(); // Move to the next column - col -= 1; + col += 1; }, this); }); diff --git a/src/objects/chart/begin.js b/src/objects/chart/begin.js index 4ddde22..62e1015 100644 --- a/src/objects/chart/begin.js +++ b/src/objects/chart/begin.js @@ -33,6 +33,10 @@ // The group within which to put all of this chart's objects this._group = svg.append("g"); + // The group within which to put tooltips. This is not initialised here because + // the group would end up behind other chart contents in a multi chart output. It will + // therefore be added and removed by the mouse enter/leave events + this._tooltipGroup = null; // Colors assigned to chart contents. E.g. a series value. this._assignedColors = {}; // The next colour index to use, this value is cycled around for all default colours diff --git a/src/objects/plot/area.js b/src/objects/plot/area.js index f664b66..68ea5f0 100644 --- a/src/objects/plot/area.js +++ b/src/objects/plot/area.js @@ -30,10 +30,10 @@ filter.push(d.aggField[k]); } uniqueValues.forEach(function (e) { - match = match || (e.join("/") === filter.join("/")); + match = match || (e === filter.join("/")); }, this); if (!match) { - uniqueValues.push(filter); + uniqueValues.push(filter.join("/")); } }, this); @@ -61,7 +61,7 @@ .data(uniqueValues) .transition() .duration(duration) - .attr("class", function (d) { return "series area " + d.join("_").replace(" ", ""); }) + .attr("class", function (d) { return "series area " + d.replace(" ", ""); }) .attr("d", function (d) { var seriesData, baseline = [], @@ -217,15 +217,17 @@ h = 0, box, overlap, - rows = [], - // Create a group for the hover objects - g = chart._group.append("g") - .attr("class", "hoverShapes"); + rows = []; + + if (chart._tooltipGroup !== null && chart._tooltipGroup !== undefined) { + chart._tooltipGroup.remove(); + } + chart._tooltipGroup = chart.svg.append("g"); // On hover make the line marker visible immediately selectedShape.style("opacity", 1); // Add a ring around the data point - g.append("circle") + chart._tooltipGroup.append("circle") .attr("cx", cx) .attr("cy", cy) .attr("r", r) @@ -242,7 +244,7 @@ // Add a drop line to the x axis if (dropDest.y !== null) { - g.append("line") + chart._tooltipGroup.append("line") .attr("x1", cx) .attr("y1", (cy < dropDest.y ? cy + r + 4 : cy - r - 4)) .attr("x2", cx) @@ -261,7 +263,7 @@ // Add a drop line to the y axis if (dropDest.x !== null) { - g.append("line") + chart._tooltipGroup.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)) @@ -279,7 +281,7 @@ } // Add a group for text - t = g.append("g"); + t = chart._tooltipGroup.append("g"); // Create a box for the popup in the text group box = t.append("rect"); @@ -377,10 +379,9 @@ leaveEventHandler: function (e, shape, chart, series) { // Return the opacity of the marker d3.select(shape).style("opacity", (series.lineMarkers ? dimple._helpers.opacity(e, chart, series) : 0)); - // Clear all hover shapes - chart._group - .selectAll(".hoverShapes") - .remove(); + if (chart._tooltipGroup !== null && chart._tooltipGroup !== undefined) { + chart._tooltipGroup.remove(); + } } }; diff --git a/src/objects/plot/bar.js b/src/objects/plot/bar.js index 4345f03..101c494 100644 --- a/src/objects/plot/bar.js +++ b/src/objects/plot/bar.js @@ -124,14 +124,16 @@ yRunning = 0, // The maximum bounds of the text elements w = 0, - h = 0, - // Create a group for the hover objects - g = chart._group.append("g") - .attr("class", "hoverShapes"); + h = 0; + + if (chart._tooltipGroup !== null && chart._tooltipGroup !== undefined) { + chart._tooltipGroup.remove(); + } + chart._tooltipGroup = chart.svg.append("g"); // Add a drop line to the x axis if (!series.x._hasCategories() && dropDest.y !== null) { - g.append("line") + chart._tooltipGroup.append("line") .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)) @@ -150,7 +152,7 @@ // Add a drop line to the y axis if (!series.y._hasCategories() && dropDest.x !== null) { - g.append("line") + chart._tooltipGroup.append("line") .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)) @@ -168,7 +170,7 @@ } // Add a group for text - t = g.append("g"); + t = chart._tooltipGroup.append("g"); // Create a box for the popup in the text group box = t.append("rect"); @@ -277,10 +279,9 @@ // Handle the mouse leave event leaveEventHandler: function (chart) { - // Clear all hover shapes - chart._group - .selectAll(".hoverShapes") - .remove(); + if (chart._tooltipGroup !== null && chart._tooltipGroup !== undefined) { + chart._tooltipGroup.remove(); + } } }; diff --git a/src/objects/plot/bubble.js b/src/objects/plot/bubble.js index 6432741..43fb4f5 100644 --- a/src/objects/plot/bubble.js +++ b/src/objects/plot/bubble.js @@ -121,13 +121,15 @@ // The maximum bounds of the text elements w = 0, h = 0, - overlap, - // Create a group for the hover objects - g = chart._group.append("g") - .attr("class", "hoverShapes"); + overlap; + + if (chart._tooltipGroup !== null && chart._tooltipGroup !== undefined) { + chart._tooltipGroup.remove(); + } + chart._tooltipGroup = chart.svg.append("g"); // Add a ring around the data point - g.append("circle") + chart._tooltipGroup.append("circle") .attr("cx", cx) .attr("cy", cy) .attr("r", r) @@ -144,7 +146,7 @@ // Add a drop line to the x axis if (dropDest.y !== null) { - g.append("line") + chart._tooltipGroup.append("line") .attr("x1", cx) .attr("y1", (cy < dropDest.y ? cy + r + 4 : cy - r - 4)) .attr("x2", cx) @@ -163,7 +165,7 @@ // Add a drop line to the y axis if (dropDest.x !== null) { - g.append("line") + chart._tooltipGroup.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)) @@ -181,7 +183,7 @@ } // Add a group for text - t = g.append("g"); + t = chart._tooltipGroup.append("g"); // Create a box for the popup in the text group box = t.append("rect"); @@ -277,10 +279,9 @@ // Handle the mouse leave event leaveEventHandler: function (chart) { - // Clear all hover shapes - chart._group - .selectAll(".hoverShapes") - .remove(); + if (chart._tooltipGroup !== null && chart._tooltipGroup !== undefined) { + chart._tooltipGroup.remove(); + } } }; diff --git a/src/objects/plot/line.js b/src/objects/plot/line.js index 767a727..d0732b9 100644 --- a/src/objects/plot/line.js +++ b/src/objects/plot/line.js @@ -199,16 +199,18 @@ t, box, rows = [], - overlap, - // Create a group for the hover objects - g = chart._group.append("g") - .attr("class", "hoverShapes"); + overlap; + + if (chart._tooltipGroup !== null && chart._tooltipGroup !== undefined) { + chart._tooltipGroup.remove(); + } + chart._tooltipGroup = chart.svg.append("g"); // On hover make the line marker visible immediately selectedShape.style("opacity", 1); // Add a ring around the data point - g.append("circle") + chart._tooltipGroup.append("circle") .attr("cx", cx) .attr("cy", cy) .attr("r", r) @@ -225,7 +227,7 @@ // Add a drop line to the x axis if (dropDest.y !== null) { - g.append("line") + chart._tooltipGroup.append("line") .attr("x1", cx) .attr("y1", (cy < dropDest.y ? cy + r + series.lineWeight + 2 : cy - r - series.lineWeight - 2)) .attr("x2", cx) @@ -244,7 +246,7 @@ // Add a drop line to the y axis if (dropDest.x !== null) { - g.append("line") + chart._tooltipGroup.append("line") .attr("x1", (cx < dropDest.x ? cx + r + series.lineWeight + 2 : cx - r - series.lineWeight - 2)) .attr("y1", cy) .attr("x2", (cx < dropDest.x ? cx + r + series.lineWeight + 2 : cx - r - series.lineWeight - 2)) @@ -262,7 +264,7 @@ } // Add a group for text - t = g.append("g"); + t = chart._tooltipGroup.append("g"); // Create a box for the popup in the text group box = t.append("rect"); @@ -360,10 +362,9 @@ leaveEventHandler: function (e, shape, chart, series) { // Return the opacity of the marker d3.select(shape).style("opacity", (series.lineMarkers ? dimple._helpers.opacity(e, chart, series) : 0)); - // Clear all hover shapes - chart._group - .selectAll(".hoverShapes") - .remove(); + if (chart._tooltipGroup !== null && chart._tooltipGroup !== undefined) { + chart._tooltipGroup.remove(); + } } };