-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbChart.min.js
6 lines (5 loc) · 66.6 KB
/
bChart.min.js
1
2
3
4
5
6
/*! bChart - v0.1.0 - 2015-06-18
* Copyright (c) 2015 Jingxian Mao; Licensed MIT */
!function(a){"use strict";"function"==typeof define&&define.amd?define([],a):window.bChart=a()}(function(){"use strict";var a={},b={},c=d3.time.format.multi([[".%L",function(a){return a.getMilliseconds()}],[":%S",function(a){return a.getSeconds()}],["%I:%M",function(a){return a.getMinutes()}],["%I %p",function(a){return a.getHours()}],["%a %d",function(a){return a.getDay()&&1!=a.getDate()}],["%b %d",function(a){return 1!=a.getUTCDate()}],["%B",function(a){return a.getUTCMonth()}],["%Y",function(){return!0}]]),d={selector:"",colors:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],colorOpacity:1,duration:400,padding:{top:80,right:90,bottom:60,left:60},data:{dataValue:[],groups:[],groups2:[],x:[]},_colorMap:{},_datasetTmp:[],_uniqueGroupTmp:[],_uniqueXArray:[],_uniqueGroupArrayAll:[],_uniqueGroupArray2:[],_dataset:[],isStack:!1,minDefault:-1,maxDefault:-1,minDefault2:-1,maxDefault2:-1,width:800,height:350,background:{imageURL:"",color:"#ffffff",displayImage:!1,opacity:1},_secondAxis:!1,legend:{position:"topright",symbolSize:10,multipleLine:!1,textFirst:!0,display:!0,fontType:"helvetica",fontSize:12,fontBold:!1,fontItalic:!1,fontUnderline:!1,fontColor:"#000000",offsetAdjust:{between:15,horizontal:0,vertical:0,textToSymbol:5}},title:{display:!0,fontType:"helvetica",fontSize:18,fontBold:!1,fontItalic:!1,fontUnderline:!1,fontColor:"#000000",offsetAdjust:{horizontal:0,vertical:0}},xLabel:{display:!0,text:"x label",rotation:0,fontType:"helvetica",fontSize:14,fontBold:!1,fontItalic:!1,fontUnderline:!1,fontColor:"#000000",offsetAdjust:{horizontal:0,vertical:0}},yLabel:{display:!0,text:"y label",rotation:-90,fontType:"helvetica",fontSize:14,fontBold:!1,fontItalic:!1,fontUnderline:!1,fontColor:"#000000",offsetAdjust:{horizontal:0,vertical:0}},yLabel2:{display:!0,text:"y label second",rotation:-90,fontType:"helvetica",fontSize:14,fontBold:!1,fontItalic:!1,fontUnderline:!1,fontColor:"#000000",offsetAdjust:{horizontal:0,vertical:0}},yAxis:{display:!0,displayTicksLine:!0,tickNumber:8,tickFormat:d3.format(",.0f"),tickPadding:3,innerTickSize:0,outerTickSize:0,orientation:"left",tickValue:[],fontColor:"#000",fontType:"helvetica",fontSize:12,fontBold:!1,fontItalic:!1,fontUnderline:!1,tickLineColor:"#ccc",tickLineWidth:.2,axisColor:"#000",axisWidth:1,rotation:0,offsetAdjust:0},yAxis2:{display:!0,displayTicksLine:!1,tickNumber:8,tickFormat:d3.format(",.0f"),tickPadding:3,innerTickSize:0,outerTickSize:0,orientation:"right",tickValue:[],fontColor:"#000",fontType:"helvetica",fontSize:12,fontBold:!1,fontItalic:!1,fontUnderline:!1,tickLineColor:"#ccc",tickLineWidth:.2,axisColor:"#000",axisWidth:1,rotation:0,offsetAdjust:0},xAxis:{display:!0,isTimeSeries:!1,timeTick:"",timeFormat:"",displayTicksLine:!0,tickNumber:5,tickFormat:"",tickPadding:3,innerTickSize:"auto",outerTickSize:0,tickSize:10,orientation:"bottom",tickValue:[],fontColor:"#000",fontType:"helvetica",fontSize:12,fontBold:!1,fontItalic:!1,fontUnderline:!1,tickLineColor:"#ccc",tickLineWidth:.2,axisColor:"#000",axisWidth:1,rotation:0,offsetAdjust:0},tooltip:{type:1,background:"rgba(255,255,255, 0.6)",xLine:{stroke:"#666",strokeWidth:2},display:!0,text:"tooltip",fontType:"helvetica",fontSize:12,fontBold:!1,fontItalic:!1,fontUnderline:!1,fontColor:"#fff",width:"auto",height:"auto",xHTML:"",groupHTML:"",_xHTML:"",_groupHTML:""}},e=function(b){if(e.existy(b)&&e.typeString(b)){if(arguments.length>=2){var c="";switch(arguments[1].toLowerCase()){case"bar":c="BarChart";break;case"scatter":c="ScatterChart";break;case"bubble":c="BubbleChart";break;case"line":c="LineChart";break;case"area":c="AreaChart";break;case"pie":c="PieChart"}return 3===arguments.length?new e[c](arguments[0],arguments[2]):new e[c](arguments[0])}if(1===arguments.length&&e.isSelector(b))return a[b]}};e._init=function(a,c){var r={};switch(c){case"bar":r=h;break;case"scatter":r=p;break;case"bubble":r=j;break;case"line":r=l;break;case"area":r=f;break;case"pie":r=n}var s=e.concatObject(d,r);switch(b=e.clone(s),e.typeString(a)&&e.isSelector(a)?b.selector=a:e.typeObject(a)&&(b=e.concatObject(b,a)),c){case"bar":return new i(b.selector,b);case"scatter":return new q(b.selector,b);case"bubble":return new k(b.selector,b);case"line":return new m(b.selector,b);case"area":return new g(b.selector,b);case"pie":return new o(b.selector,b)}},e._customConstructor=function(a,c,d,f){var g={};if(e.existy(c))if(1===d.length){if(e.existy(e.getObjectBySelector(c))&&e.isSelector(c))return e.getObjectBySelector(c);b.selector===c&&e.truthy(b.selector)||(a=e._init(c,f))}else d[0]===b.selector&&e.truthy(b.selector)?(a._options=e.clone(d[1]),e.setObjectOfSelector(c,a),a.setOptions(e.clone(d[1])),a.draw()):(g=d[1],g.selector=c,a=e._init(g,f));return a},e.getObjectBySelector=function(b){return a[b]},e.setObjectOfSelector=function(b,c){a[b]=c},e.isSelector=function(a){return a.indexOf("#")>=0||a.indexOf(".")>=0},e.clone=function(a){return e.typeObject(a)?JSON.parse(JSON.stringify(a)):void 0},e.copyPropertyOfObject=function(a,b){e.typeObject(a)&&e.each(a,function(a,c){b[c]=a})},e.generateArray=function(a){for(var b=[],c=0;a>c;c+=1)b.push(c);return b},e.setChart=function(a,b){var c=this;return c[b]=a,c},e.existy=function(a){return null!=a},e.getUniqueValueArray=function(a){return function(b){if(e.existy(b)){var c=[];return e.each(b,function(b,d){c.indexOf(b[a])<0&&c.push(b[a])}),c}}},e.sorted=function(a){return function(b){return b.sort(a)}},e.sortedByArray=function(a,b){for(var c=[],d=0;d<b.length;d++){var e=a.filter(function(a){return a.x===b[d]});c.push(e)}return d3.merge(c)},e.sortByDate=e.sorted(function(a,b){return e.existy(a.getTime)?a.getTime()-b.getTime():(a=new Date(a),b=new Date(b),a.getTime()-b.getTime())}),e.typeDate=function(a){return isNaN(new Date(a).getTime())},e.each=function(a,b){if(e.isArrayLike(a))for(var c=e.getLength(a),d=0;c>d;d++)b(a[d],d,a);else for(var f in a)b(a[f],f,a)},e.property=function(a){return function(b){return e.existy(b)?b[a]:void 0}},e.hasProperty=function(a,b){if(e.typeString(b)){if(b.indexOf(".")>=0){var c=b.split(".");return e.existy(a[c[0]][c[1]])}return e.existy(a[b])}},e.setProperty=function(a,b,c){if(e.typeString(b))if(b.indexOf(".")>=0){var d=b.split(".");if(e.hasProperty(a,d[0])||(a[d[0]]={}),e.isArrayLike(a[d[0]])&&"all"===d[1])for(var f=0;f<a[d[0]].length;f++)a[d[0]][f]=c;else a[d[0]][d[1]]=c}else e.hasProperty(a,b)||(a[b]={}),e.typeObject(c)?e.copyPropertyOfObject(c,a[b]):a[b]=c},e.getLength=e.property("length"),e.isArrayLike=function(a){if(e.typeString(a))return!1;var b=e.getLength(a);return e.typeNumber(b)&&b>=0},e.typeofObject=function(a){return function(b){return a(b)}},e.typeNumber=e.typeofObject(function(a){return!isNaN(a)}),e.typeString=e.typeofObject(function(a){return"string"==typeof a}),e.typeObject=e.typeofObject(function(a){return"object"==typeof a}),e.existy=function(a){return null!=a},e.truthy=function(a){return a!==!1&&e.existy(a)},e.hexToRGBA=function(a,b){var c=a.replace("#",""),d=parseInt(c.substring(0,2),16),e=parseInt(c.substring(2,4),16),f=parseInt(c.substring(4,6),16);return"rgba("+d+","+e+","+f+","+b+")"},e.getIndexOfElement=function(a,b){return e.existy(b)?b.indexOf(a):-1},e.isElementInArray=function(a,b){return e.getIndexOfElement(a,b)>=0},e.concatNoDuplicate=function(a,b){var c=a.concat(b);return c.filter(function(a,b){return e.getIndexOfElement(a,c)===b})},e.removeDuplicateFromArray=function(a){return a.filter(function(b,c){return e.getIndexOfElement(b,a)===c})},e.removeElementFromArray=function(a,b){return e.isElementInArray(a,b)?(b.splice(e.getIndexOfElement(a,b),1),b):void 0},e.removeArrayFromArray=function(a,b){return a.filter(function(a,c){return!e.isElementInArray(a,b)})},e.isOverlapArray=function(a,b){var c=a.concat(b),d=c.filter(function(a,b){return e.getIndexOfElement(a,c)===b});return c.length!==d.length},e.isSubArray=function(a,b){var c=b.filter(function(b,c){return!e.isElementInArray(b,a)});return c.length>0?!1:!0},e.getSubArray=function(a,b){return e.isSubArray(a,b)?b:b.filter(function(b,c){return e.isElementInArray(b,a)})},e.generateDateFormatter=function(a){if(!e.existy(a))return console.log("Please input a date format string"),c;var b=function(a){switch(a){case"MM":return"%m";case"mm":return"%B";case"Mm":return"%b";default:return""}},d=function(a){switch(a){case"DD":return"%d";case"dd":return"%e";default:return""}},f=function(a){switch(a){case"YYYY":case"yyyy":return"%Y";case"YY":case"yy":return"%y";default:return""}},g=function(a){return function(c){var g=c.split(a),h="";return e.each(g,function(c){h+=d(c)+b(c)+f(c),h+=a}),h=h.slice(0,-1),d3.time.format(h)}},h=g("/"),i=g("-"),j=g(",");return a.indexOf("/")>=0?h(a):a.indexOf("-")>=0?i(a):a.indexOf(",")>=0?j(a):(console.log("Please input a date format string"),c)},e.computeTimeTick=function(a){return a>315569e5?d3.time.years:a>262974e4?d3.time.months:a>6048e5?d3.time.weeks:a>864e5?d3.time.days:d3.time.hours},e.concatObject=function(a,b){return e.each(b,function(b,c){if("object"==typeof b)for(var d in b)e.hasProperty(a,c)||(a[c]={}),a[c][d]=b[d];else a[c]=b}),a},e.initStyleProperty=function(a,b){return function(c,d){var f=this;f._options[b][a][c]=e.existy(f._options[b][a][c])?f._options[b][a][c]:d}},e.removeStyleProperty=function(a,b){return function(c){var d=this;e.existy(d._options[b][a][c])&&delete d._options[b][a][c]}},e.prototype.area=function(a){var b=this;return e.existy(a)?(b._setSpecificPropertiesByChart(a,"area"),b):b._options.area},e.prototype._drawAreaSVG=function(a){var b,c=this,d=c._options._dataset,f=c._options._uniqueGroupTmp.length?c._options._uniqueGroupTmp:c._options._uniqueGroupArrayAll;b=d3.select(c._options.selector).select(".bChart_wrapper").empty()?d3.select(c._options.selector).append("div").attr("class","bChart_wrapper"):d3.select(c._options.selector).select(".bChart_wrapper");var g,h,i=b.select("g.bChart"),j=[];if(g=i.select(".bChart_areas").empty()?i.append("g").attr("class","bChart_areas"):i.select(".bChart_areas"),e.existy(a)){c._options.isStack&&(d=c.stackDataset(d,c._options._uniqueGroupArrayAll,c._options._uniqueXArray));var k=function(a){var b=d.filter(function(b){return c._options.isStack?b[0].group===a:b.group===a});c._options.isStack?j.push(b[0]):j.push(b)};e.each(c._options._uniqueGroupArrayAll,k),h=g.selectAll(".bChart_groups").data(j),h.enter().append("path"),h.exit().remove();var l=d3.svg.area().x(function(b){return c._options.xAxis.isTimeSeries?a.x0(new Date(b.x)):a.x0(b.x)}).y0(function(b){return c._options.isStack?b.y0<c._options.minDefault?a.y(c._options.minDefault):a.y(b.y0):c._options._chartSVGHeight}).y1(function(b){return c._options.isStack?a.y(parseFloat(b.y0)+parseFloat(b.y)):b._secondAxis?a.y2(b.value):a.y(b.value)});h.attr("d",l)}else h=g.selectAll(".bChart_groups");return h.empty()||h.attr("class",function(a,b){var c=f.indexOf(a[b].group);return"bChart_groups bChart_groups_"+c}).attr("fill",function(a,b){return c._options._colorMap[a[b].group]}).attr("fill-opacity",function(a,b){var d=f.indexOf(a[b].group);return c._options.area.fillOpacity[d]}).attr("stroke",function(a,b){return c._options._colorMap[a[b].group]}).attr("stroke-width",function(a,b){var d=f.indexOf(a[b].group);return c._options.area.strokeWidth[d]}).attr("stroke-opacity",function(a,b){var d=f.indexOf(a[b].group);return c._options.area.strokeOpacity[d]}).style("opacity",.1).transition().duration(c._options.duration).style("opacity",1),c},e.initAreaType=e.initStyleProperty("type","area"),e.initAreaFillOpacity=e.initStyleProperty("fillOpacity","area"),e.initAreaStrokeWidth=e.initStyleProperty("strokeWidth","area"),e.initAreaStrokeOpacity=e.initStyleProperty("strokeOpacity","area"),e.removeAreaType=e.removeStyleProperty("type","area"),e.removeAreaStrokeWidth=e.removeStyleProperty("strokeWidth","area"),e.removeAreaStrokeOpacity=e.removeStyleProperty("strokeOpacity","area"),e.removeAreaFillOpacity=e.removeStyleProperty("fillOpacity","area");var f={title:{text:"Area Chart"},area:{strokeWidth:[],strokeOpacity:[],fillOpacity:[]}},g=function(a){return e._customConstructor(this,a,arguments,"area")};e.AreaChart=g,g.prototype=Object.create(e.prototype),g.prototype.constructor=g,g.prototype._drawAreaChart=function(){var a=this,b=a._initXYAxis();return a._drawAreaSVG(b),a},e.prototype.background=function(a){function b(){var a,b;b=d3.select(c._options.selector).select(".bChart_wrapper").empty()?d3.select(c._options.selector).append("div").attr("class","bChart_wrapper"):d3.select(c._options.selector).select(".bChart_wrapper"),a=b.select(".bChart_background").empty()?b.append("div").attr("class","bChart_background"):b.select(".bChart_background"),a.style("width",c._options.width+"px").style("height",c._options.height+"px"),c._options.background.displayImage?e.existy(c._options.background.imageURL)?a.style("background-image","url("+c._options.background.imageURL+")").style("opacity",c._options.background.opacity):c._options.background.displayImage=!1:a.style("background-image","none").style("background-color",c._options.background.color).style("opacity",c._options.background.opacity)}var c=this;return e.existy(a)?(e.typeString(a)&&"refresh"===a?b():(c.setOptions(arguments,"background"),b()),c):c._options.background},e.prototype._drawStackBarSVG=function(a){var b,c=this,d=c._options._dataset,f=c._options._uniqueGroupTmp.length?c._options._uniqueGroupTmp:c._options._uniqueGroupArrayAll;b=d3.select(c._options.selector).select(".bChart_wrapper").empty()?d3.select(c._options.selector).append("div").attr("class","bChart_wrapper"):d3.select(c._options.selector).select(".bChart_wrapper");var g,h=b.select("g.bChart");g=h.select(".bChart_bar_parent").empty()?h.append("g").attr("class","bChart_bar_parent"):h.select(".bChart_bar_parent");var i=c.stackDataset(d,c._options._uniqueGroupArrayAll,c._options._uniqueXArray),j=g.selectAll(".bChart_Bars").data(i);j.enter().append("g").attr("class",function(a,b){return"bChart_Bars"}),j.exit().remove();var k=j.selectAll("rect").data(function(a){return a});k.enter().append("rect").attr("class",function(a){return"bChart_groups bChart_groups_"+f.indexOf(a.group)}),k.attr("class",function(a){return"bChart_groups bChart_groups_"+f.indexOf(a.group)}).attr("width",a.x0.rangeBand()-c._options.barDistance).attr("x",function(b){return e.existy(this._current)||(this._current={}),this._current.x=e.existy(this._current.x)?this._current.x:a.x0(b.x)+c._options.barDistance/2,this._current.x}).attr("y",function(a){return e.existy(this._current.y)?this._current.y:c._options._chartSVGHeight}).attr("height",function(a){return e.existy(this._current.height)?this._current.height:0}).style("fill",function(a){return c._options._colorMap[a.group]}).style("stroke",function(a,b){return c._options._colorMap[a.group]}).style("stroke-width",0).transition().duration(c._options.duration).attr("x",function(b){return this._current.x=a.x0(b.x)+c._options.barDistance/2,this._current.x}).attr("y",function(b){return this._current.y=a.y(b.y0+b.y),this._current.y}).attr("height",function(b,d){var e;return e=b.group===c._options._uniqueGroupArrayAll[0]?c._options._chartSVGHeight-a.y(b.y+b.y0):a.y(b.y0)-a.y(b.y+b.y0),this._current.height=e,e}),k.exit().remove()},e.prototype._drawGroupBarSVG=function(a){var b,c=this,d=c._options._dataset,f=c._options._uniqueGroupTmp.length?c._options._uniqueGroupTmp:c._options._uniqueGroupArrayAll;b=d3.select(c._options.selector).select(".bChart_wrapper").empty()?d3.select(c._options.selector).append("div").attr("class","bChart_wrapper"):d3.select(c._options.selector).select(".bChart_wrapper");var g=b.select("g.bChart"),h=[];e.each(c._options._uniqueXArray,function(a,b){var c=d.filter(function(b){return b.x===a});h.push({x:a,data:c})});var i;i=g.select(".bChart_bar_parent").empty()?g.append("g").attr("class","bChart_bar_parent"):g.select(".bChart_bar_parent");var j=i.selectAll(".bChart_Bars").data(h);j.enter().append("g").attr("class",function(a,b){return"bChart_Bars"}),j.exit().remove();var k=j.selectAll("rect").data(function(a){return a.data});k.exit().transition().attr("height",0).remove(),k.enter().append("rect").attr("class",function(a){return"bChart_groups bChart_groups_"+f.indexOf(a.group)}),k.attr("class",function(a){return"bChart_groups bChart_groups_"+f.indexOf(a.group)}).attr("width",a.x1.rangeBand()-c._options.barDistance).attr("x",function(b,d){return e.existy(this._current)||(this._current={}),this._current.group=e.existy(this._current.group)?this._current.group:b.group,this._current.value=e.existy(this._current.value)?this._current.value:b.value,this._current._secondAxis=e.existy(this._current._secondAxis)?this._current._secondAxis:b._secondAxis,this._current.x=e.existy(this._current.x)?this._current.x:a.x0(b.x)+a.x1(b.group)+c._options.barDistance/2,this._current.x}).attr("y",function(){return e.existy(this._current.y)?this._current.y:c._options._chartSVGHeight}).attr("height",function(){return e.existy(this._current.height)?this._current.height:0}).style("fill",function(a,b){return c._options._colorMap[this._current.group]}).style("stroke",function(a,b){return c._options._colorMap[this._current.group]}).style("stroke-width",0).transition().duration(c._options.duration).attr("x",function(b){return this._current.x=a.x0(b.x)+a.x1(this._current.group)+c._options.barDistance/2,this._current.x}).attr("y",function(b){return this._current.y=this._current._secondAxis?a.y2(this._current.value):a.y(this._current.value),this._current.y}).attr("height",function(b){return this._current.height=this._current._secondAxis?c._options._chartSVGHeight-a.y2(this._current.value):c._options._chartSVGHeight-a.y(this._current.value),this._current.height})};var h={barDistance:2,title:{text:"Bar Chart"}},i=function(a){return e._customConstructor(this,a,arguments,"bar")};e.BarChart=i,i.prototype=Object.create(e.prototype),i.prototype.constructor=i,i.prototype._drawBarChart=function(){var a=this,b=a._initXYAxis();return a._options.isStack?a._drawStackBarSVG(b):a._drawGroupBarSVG(b),a},e.prototype.options=function(a){var b=this;return e.existy(a)?e.typeString(a)&&1===arguments.length?b._options[a]:(b.setOptions(arguments).draw(),b):b._options},e.prototype.setOptions=function(a,b){var c,d,f=this,g=function(a){return function(b){if(e.existy(b)){var c={};e.typeString(b)?1==arguments.length?c={selector:b}:c[arguments[0]]=arguments[1]:c=b,e.existy(a)?e.typeString(a)&&"_dataset"===a?(e.each(b,function(a,b,c){e.existy(c[b].group)||(c[b].group="")}),f._options[a]=b):e.each(c,function(b,c){e.setProperty(f._options[a],c,b)}):e.each(c,function(a,b){"data"===b?setTimeout(function(){f.loadColumn(a)},1):"_"!==b[0]&&e.setProperty(f._options,b,a)})}}};if(c=e.existy(b)?g(b):g(),e.isArrayLike(a))if(1==a.length){if(!e.typeObject(a[0]))return console.log("Can't update the property!"),f;d=a[0],c(d)}else c(a[0],a[1]);else d=a,c(d);return f},e.prototype.getOptions=function(a){var b=this;return e.existy(a)?e.hasProperty(b._options,a)?b._options[a]:void 0:b.options},e.prototype.width=function(a){var b=this;return e.existy(a)&&e.typeNumber(a)?(b._options.width=a,e.typeNumber(a)?(b._options.width=a,b._updateChartSize()._drawChartSVG().xLabel("refresh").legend("refresh").title("refresh")):e.typeString(a)&&"refresh"===a&&b._updateChartSize()._drawChartSVG().xLabel("refresh").legend("refresh").title("refresh"),b):b._options.width},e.prototype.height=function(a){var b=this;return e.existy(a)?(e.typeNumber(a)?(b._options.height=a,b._updateChartSize()._drawChartSVG().yLabel("refresh").yLabel2("refresh").legend("refresh").title("refresh")):e.typeString(a)&&"refresh"===a&&b._updateChartSize()._drawChartSVG().yLabel("refresh").yLabel2("refresh").legend("refresh").title("refresh"),b):b._options.height},e.prototype._updateChartSize=function(){var a,b,c=this;c._options.legend.position.indexOf("right")>=0&&c._options._secondAxis?c._options.padding.right=120:c._options.padding.right=90,c._options._chartSVGWidth=c._options.width-c._options.padding.left-c._options.padding.right,c._options._chartSVGHeight=c._options.height-c._options.padding.top-c._options.padding.bottom;var d;return d=d3.select(c._options.selector).select(".bChart_wrapper").empty()?d3.select(c._options.selector).append("div").attr("class","bChart_wrapper"):d3.select(c._options.selector).select(".bChart_wrapper"),a=d.select("svg").empty()?d.append("svg"):d.select("svg"),a.attr("width",c._options.width).attr("height",c._options.height),b=a.select("g.bChart").empty()?a.append("g").attr("class","bChart"):a.select("g.bChart"),b.attr("width",c._options._chartSVGWidth).attr("height",c._options._chartSVGHeight).attr("transform","translate("+c._options.padding.left+","+c._options.padding.top+")"),c},e.prototype._drawChartSVG=function(){var a=this;switch(a.constructor){case i:return a._drawBarChart();case q:return a._drawScatterChart();case k:return a._drawBubbleChart();case m:return a._drawLineChart();case g:return a._drawAreaChart();case o:return a._drawPieChart()}},e.prototype.draw=function(){var a=this;return e.getLength(d3.select(a._options.selector))?(a.min("refresh").max("refresh").updateMin(),a._options._secondAxis&&a.min2("refresh").max2("refresh").updateMin2(),a.colors("refresh")._drawChartSVG(),a.background("refresh").xLabel("refresh").yLabel("refresh").xAxis("refresh").yAxis("refresh").title("refresh").tooltip("refresh").legend("refresh"),void a.yLabel2("refresh").yAxis2("refresh")):void console.log("Please make sure the element exists in your template.")},e.prototype._initXYAxis=function(){var a=this;a._updateChartSize(),a._options.xAxis.tickSize=-a._options._chartSVGHeight,a._options.yAxis.tickSize=-a._options._chartSVGWidth;var b,c,d,f,g,h,i,j=a._getComputedX();b=j.x0,e.existy(j.x1)&&(c=j.x1),i=a._getXAxis(b),a._renderXAxis(i);var k=a._getComputedY();return d=k.y1,g=a._getYAxis(d,!1),a._renderYAxis(g,!1),a._options._secondAxis&&(f=k.y2,h=a._getYAxis(f,!0),a._renderYAxis(h,!0)),{x0:b,x1:c,y:d,y2:f}},e.prototype._setSpecificPropertiesByChart=function(a,b){var c,d=this,f=function(a){if(2===a.length)if(a[0].indexOf(".")>=0&&a[0].indexOf("$")>=0){var b=parseInt(a[0].split(".")[1].split("$")[1]);a[0]=a[0].split(".")[0]+"."+b}else a[0]=a[0]+".all";return a};return e.typeString(a)?"refresh"===a?d._drawChartSVG():(c=f(arguments),setTimeout(function(){d.setOptions(c,b),d._drawChartSVG()},10)):(e.each(a,function(a,b,c){var d=[b,a];delete c[b];var e=f(d);c[e[0]]=a}),setTimeout(function(){d.setOptions(a,b),d._drawChartSVG()},10)),d},e.prototype.bubble=function(a){var b=this;if(!e.existy(a))return b._options.bubble;if(e.isArrayLike(a)){var c={};e.each(a,function(a,d){var f,g;e.typeNumber(a[0])?e.existy(b._options._uniqueGroupArrayAll[d])&&(f=b._options._uniqueGroupArrayAll[d],g=a):(f=a[0],g=a,g.shift()),c[f]=g;var h=0;e.each(b._options._dataset,function(a){a.group===f&&(a.size=g[h],h++)})})}else b._setSpecificPropertiesByChart(a,"bubble");return b};var j={bubble:{},title:{text:"Bubble Chart"},node:{display:[],type:[],size:[],fillOpacity:[],solidCircle:[],strokeWidth:[]}},k=function(a){return e._customConstructor(this,a,arguments,"bubble")};e.BubbleChart=k,k.prototype=Object.create(e.prototype),k.prototype.constructor=k,k.prototype._drawBubbleChart=function(){var a=this,b=a._initXYAxis();return a._drawNodeSVG(b).node("refresh"),a},e.prototype.colors=function(a){function b(){var a="";e.each(c._options._uniqueGroupArrayAll,function(b,d){a=c._options.colors[d].indexOf("#")>=0?e.hexToRGBA(c._options.colors[d%c._options.colors.length],c._options.colorOpacity):c._options.colors[d%c._options.colors.length],c._options._colorMap[b]=a})}var c=this;return e.existy(a)?(e.typeString(a)&&"refresh"===a?b():(c.setOptions(arguments,"colors"),b()),c):c._options.colors},e.prototype.stackDataset=function(a,b,c){var d=d3.layout.stack(),f=d(b.map(function(b){var d=[],f=[];return e.each(a,function(a,c,e){b===e[c].group&&d.push(e[c])}),f=d.filter(function(a,b){return c.indexOf(a.x)>=0}),f.map(function(a){return{x:a.x,value:+parseFloat(a.value),_secondAxis:a._secondAxis,y:+parseFloat(a.value),group:a.group}})}));return f},e.prototype.parseGroupIndex=function(a,b){var c=[],d=[];if(e.isArrayLike(b))b.forEach(function(b){if(e.typeNumber(b))c.push(b),d.push(a[b]);else{var f=a.indexOf(b);f>=0&&(c.push(f),d.push(b))}});else if(e.typeNumber(b))c.push(b),d.push(a[b]);else{var f=a.indexOf(b);f>=0&&(c.push(f),d.push(b))}return{groupIndex:c,groupValue:d}},e.prototype.loadCSV=function(a,b){var c=this;e.existy(a)||console.log("Please load data with a file path."),d3.text(a,function(a){var d=d3.csv.parseRows(a),f=[];if(e.existy(b)){var g=-1,h=[],i=[],j=[],k=[],l=[],m={};if(e.hasProperty(b,"x")&&(g=e.typeNumber(b.x)?b.x:d[0].indexOf(b.x)),e.hasProperty(b,"groups")){var n=c.parseGroupIndex(d[0],b.groups);i=n.groupIndex,j=n.groupValue}if(e.hasProperty(b,"groups2")){var o=c.parseGroupIndex(d[0],b.groups2);k=o.groupIndex,l=o.groupValue}if(i.length>0){for(var p=0;p<d[0].length;p++)if(i.indexOf(p)>=0){var q=[];d.forEach(function(a,b){q.push(a[p]),b>0&&g>-1&&h.push(a[g])}),f.push(q)}m.dataValue=f,m.groups=j}k.length>0&&(m.groups2=l),h.length>0&&(m.x=h),c.load(m)}else{for(var r=[],p=0;p<d[1].length;p++)e.typeNumber(d[1][p])||r.push(p);for(var s=0;s<d[0].length;s++)if(!(r.indexOf(s)>=0)){var q=[];d.forEach(function(a){q.push(a[s])}),f.push(q)}c.load(f)}})},e.prototype.load=function(a){var b=this;if(e.existy(a)){var c=[];if(e.isArrayLike(a))for(var d=0;d<a.length;d++){var f=e.typeNumber(a[d][0])?"data":a[d][0];c.push(f)}else e.typeObject(a)&&e.hasProperty(a,"groups")&&(c=a.groups);b.unloadData(c),b.loadColumn(a),d3.select(b._options.selector).select("svg").empty()||b.draw()}},e.prototype.loadColumn=function(a){var b=this;return e.existy(a)&&(e.isArrayLike(a)?b.loadArrayData(a):e.typeObject(a)&&b.loadObjectData(a)),b},e.prototype.loadObjectData=function(a){var b=this;e.hasProperty(a,"dataValue")&&(e.hasProperty(a,"groups")&&(a.groups=a.groups.splice(0,a.dataValue.length),b._options._uniqueGroupArrayAll=e.concatNoDuplicate(b._options._uniqueGroupArrayAll,a.groups)),e.hasProperty(a,"x")&&(b._options._uniqueXArray=e.concatNoDuplicate(b._options._uniqueXArray,a.x)),e.hasProperty(a,"groups2")&&a.groups2.length>0&&(b._options._secondAxis=!0,b._options._uniqueGroupArray2=e.concatNoDuplicate(b._options._uniqueGroupArray2,a.groups2)),e.isArrayLike(a.dataValue)&&b.loadArrayData(a.dataValue,a))},e.prototype.loadArrayData=function(a,b){function c(a,b,c){e.each(a[c],function(h,j){if(e.typeNumber(a[c][1])&&e.typeNumber(a[c][j])){var k={x:"",group:i,value:a[c][j]};if(k=e.typeNumber(a[c][0])?d(k,b,j):d(k,b,j-1),e.existy(b)&&e.hasProperty(b,"bubbleValue")){var l=b.bubbleValue.filter(function(a){return a[0]===i});e.existy(l[0])&&l[0].length>0&&(f._options.bubble[i]=l[0],k.size=l[0][j])}g||f._options._uniqueXArray.indexOf(k.x)<0&&f._options._uniqueXArray.push(k.x),e.isElementInArray(i,f._options._uniqueGroupArray2)?k._secondAxis=!0:k._secondAxis=!1,f._options._dataset.push(k)}})}function d(a,b,c){return e.existy(b)&&e.hasProperty(b,"x")&&e.existy(b.x[c])?a.x=b.x[c]:e.existy(f._options._uniqueXArray[c])?a.x=f._options._uniqueXArray[c]:a.x=c,a}var f=this,g=f._options._uniqueXArray.length>0;if(e.isArrayLike(a[0])&&!e.typeNumber(a[0][0]))for(var h=0;h<a.length;h+=1){var i="",j=-1;i=e.existy(b)&&e.hasProperty(b,"groups")&&e.existy(b.groups[h])?b.groups[h]:e.typeNumber(a[h][0])?"data":a[h][0],e.isElementInArray(i,f._options._uniqueGroupArrayAll)||f._options._uniqueGroupArrayAll.push(i),j=f._options._uniqueGroupArrayAll.indexOf(i),e.hasProperty(f._options,"node")&&(e.existy(b)&&e.hasProperty(b,"nodeType")?e.initNodeType.call(f,j,b.nodeType[h]):e.initNodeType.call(f,j,"circle"),e.initNodeSize.call(f,j,128),e.initNodeFillOpacity.call(f,j,1),e.initNodeStrokeWidth.call(f,j,1),e.initNodeDisplay.call(f,j,!0),e.initNodeSolidCircle.call(f,j,!1)),e.hasProperty(f._options,"line")&&(e.initLineType.call(f,j,"linear"),e.initLineStrokeWidth.call(f,j,"3"),e.initLineStrokeOpacity.call(f,j,"1")),e.hasProperty(f._options,"area")&&(f.options.isStack?e.initAreaFillOpacity.call(f,j,"0.8"):e.initAreaFillOpacity.call(f,j,"0.4"),e.initAreaStrokeOpacity.call(f,j,"1"),e.initAreaStrokeWidth.call(f,j,"0")),c(a,b,h)}},e.prototype.unload=function(a){var b=this;b.unloadColumn(a),d3.select(b._options.selector).select("svg").empty()||b.draw()},e.prototype.unloadGroup=function(a){var b=this;e.each(a,function(a){e.removeElementFromArray(a,b._options._uniqueGroupArrayAll)})},e.prototype.unloadData=function(a){var b=this;e.each(a,function(a){var c=b._options._uniqueGroupArrayAll.indexOf(a.group);b._options._dataset=b._options._dataset.filter(function(b){return a!==b.group}),e.isElementInArray(a,b._options._uniqueGroupArray2)&&(e.removeElementFromArray(a,b._options._uniqueGroupArray2),b._options._secondAxis=!!b._options._uniqueGroupArray2.length),e.hasProperty(b._options,"node")&&e.existy(b._options.node.type[c])&&(e.removeNodeType.call(b,c),e.removeNodeSize.call(b,c),e.removeNodeStrokeWidth.call(b,c),e.removeNodeStrokeOpacity.call(b,c),e.removeNodeFillOpacity.call(b,c),e.removeNodeDisplay.call(b,c),e.removeNodeSolidCircle.call(b,c)),e.hasProperty(b._options,"line")&&e.existy(b._options.line.type[c])&&(e.removeLineType.call(b,c),e.removeLineStrokeWidth.call(b,c),e.removeLineStrokeOpacity.call(b,c)),e.hasProperty(b._options,"area")&&e.existy(b._options.area.fillOpacity[c])&&(e.removeAreaFillOpacity.call(b,c),e.removeAreaStrokeOpacity.call(b,c),e.removeAreaStrokeWidth.call(b,c))})},e.prototype.unloadColumn=function(a){var b=this;e.existy(a)&&(e.isArrayLike(a)?(b.unloadGroup(a),b.unloadData(a)):(e.hasProperty(a,"x")&&e.isArrayLike(a.x)&&e.each(a.x,function(a){e.removeElementFromArray(a,b._options._uniqueXArray),b._options._dataset=b._options._dataset.filter(function(b){return a!==b.x})}),e.hasProperty(a,"groups")&&e.isArrayLike(a.groups)&&(b.unloadGroup(a.groups),b.unloadData(a.groups))))},e.prototype.legend=function(a){function b(){var a=[],b=d3.select(c._options.selector).select("g.bChart");if(c._options.legend.display){b.selectAll(".bChart_legend").empty()||b.selectAll(".bChart_legend").remove();var d,f,g,h,i,j,k=c._options._uniqueGroupArrayAll,l=b.selectAll(".bChart_legend").data(k).enter().append("g").attr("class","bChart_legend");switch(c._options.legend.position){case"topright":c._options.legend.textFirst?(d=c._options._chartSVGWidth+c._options.padding.right+c._options.legend.offsetAdjust.horizontal-20,f=-60-c._options.legend.offsetAdjust.vertical,g=c._options._chartSVGWidth+c._options.padding.right+c._options.legend.offsetAdjust.horizontal-20-c._options.legend.offsetAdjust.textToSymbol,h=-56-c._options.legend.offsetAdjust.vertical,i="end"):(g=c._options._chartSVGWidth+c._options.padding.right+c._options.legend.offsetAdjust.horizontal-50,h=-56-c._options.legend.offsetAdjust.vertical,d=c._options._chartSVGWidth+c._options.padding.right+c._options.legend.offsetAdjust.horizontal-60-c._options.legend.offsetAdjust.textToSymbol,f=-60-c._options.legend.offsetAdjust.vertical,i="start"),j=1;break;case"right":c._options.legend.textFirst?(d=c._options._chartSVGWidth+c._options.padding.right+c._options.legend.offsetAdjust.horizontal-20,f=c._options._chartSVGHeight/2-c._options.legend.offsetAdjust.vertical-60,g=c._options._chartSVGWidth+c._options.padding.right+c._options.legend.offsetAdjust.horizontal-20-c._options.legend.offsetAdjust.textToSymbol,h=c._options._chartSVGHeight/2-c._options.legend.offsetAdjust.vertical-56,i="end"):(g=c._options._chartSVGWidth+c._options.padding.right+c._options.legend.offsetAdjust.horizontal-50,h=c._options._chartSVGHeight/2-c._options.legend.offsetAdjust.vertical-56,d=c._options._chartSVGWidth+c._options.padding.right+c._options.legend.offsetAdjust.horizontal-60-c._options.legend.offsetAdjust.textToSymbol,f=c._options._chartSVGHeight/2-c._options.legend.offsetAdjust.vertical-60,i="start"),j=1;break;case"bottomright":c._options.legend.textFirst?(d=c._options._chartSVGWidth+c._options.padding.right+c._options.legend.offsetAdjust.horizontal-20,f=c._options._chartSVGHeight+15-c._options.legend.offsetAdjust.vertical-60,
g=c._options._chartSVGWidth+c._options.padding.right+c._options.legend.offsetAdjust.horizontal-20-c._options.legend.offsetAdjust.textToSymbol,h=c._options._chartSVGHeight+15-c._options.legend.offsetAdjust.vertical-56,i="end"):(g=c._options._chartSVGWidth+c._options.padding.right+c._options.legend.offsetAdjust.horizontal-50,h=c._options._chartSVGHeight+15-c._options.legend.offsetAdjust.vertical-56,d=c._options._chartSVGWidth+c._options.padding.right+c._options.legend.offsetAdjust.horizontal-60-c._options.legend.offsetAdjust.textToSymbol,f=c._options._chartSVGHeight+15-c._options.legend.offsetAdjust.vertical-60,i="start"),j=1;break;case"top":c._options.legend.textFirst?(d=c._options.legend.offsetAdjust.horizontal,f=-30+c._options.legend.offsetAdjust.vertical,g=c._options.legend.offsetAdjust.horizontal-c._options.legend.offsetAdjust.textToSymbol,h=-25+c._options.legend.offsetAdjust.vertical,i="end"):(g=c._options.legend.offsetAdjust.horizontal,h=-25+c._options.legend.offsetAdjust.vertical,d=c._options.legend.offsetAdjust.horizontal-c._options.legend.offsetAdjust.textToSymbol-10,f=-30+c._options.legend.offsetAdjust.vertical,i="start"),j=0;break;case"bottom":c._options.legend.textFirst?(d=c._options.legend.offsetAdjust.horizontal,f=c._options.legend.offsetAdjust.vertical+c._options._chartSVGHeight+45,g=c._options.legend.offsetAdjust.horizontal-c._options.legend.offsetAdjust.textToSymbol,h=c._options.legend.offsetAdjust.vertical+c._options._chartSVGHeight+50,i="end"):(g=c._options.legend.offsetAdjust.horizontal,h=c._options.legend.offsetAdjust.vertical+c._options._chartSVGHeight+50,d=c._options.legend.offsetAdjust.horizontal-c._options.legend.offsetAdjust.textToSymbol-10,f=c._options.legend.offsetAdjust.vertical+c._options._chartSVGHeight+45,i="start"),j=0}l.attr("transform",function(a,b){if(1===j)return"translate(0, "+b*c._options.legend.offsetAdjust.between+")";var d=(c._options._chartSVGWidth-60*c._options._uniqueGroupArrayAll.length)/2;return"translate("+(b*(c._options.legend.offsetAdjust.between+50)+d)+",0)"}).append("text").attr("x",g).attr("y",h).attr("dy",".35em").style("font-family",c._options.legend.fontType).style("text-decoration",function(){return c._options.legend.fontUnderline?"underline":"none"}).style("font-weight",function(){return c._options.legend.fontBold?"bold":"normal"}).style("font-style",function(){return c._options.legend.fontItalic?"italic":"normal"}).style("text-anchor",i).style("font-size",c._options.legend.fontSize).style("fill",c._options.legend.fontColor).text(function(a){return a}),l.append("rect").attr("x",d).attr("y",f).attr("width",c._options.legend.symbolSize).attr("height",c._options.legend.symbolSize).style("fill",function(a){return c._options._colorMap[a]}),l.on("mouseover",function(a){b.selectAll(".bChart_legend").classed("unhover",!0),b.selectAll(".bChart_groups").classed("unhover",!0),d3.select(this).classed("unhover",!1);var d=c._options._uniqueGroupTmp.length?c._options._uniqueGroupTmp:c._options._uniqueGroupArrayAll,e=d.indexOf(a),f=".bChart_groups_"+e;b.selectAll(f).classed("unhover",!1)}).on("mouseout",function(a){b.selectAll(".bChart_legend").classed("unhover",!1),b.selectAll(".bChart_groups").classed("unhover",!1)}).on("click",function(d){var f=b.selectAll(".bChart_legend");a.length||(f.classed("inactive",!0),c._options._datasetTmp=c._options._dataset,c._options._uniqueGroupTmp=c._options._uniqueGroupArrayAll),e.isElementInArray(d,a)?(a.splice(e.getIndexOfElement(d,a),1),d3.select(this).classed("inactive",!0).classed("active",!1)):(a.push(d),d3.select(this).classed("inactive",!1).classed("active",!0)),c._options._uniqueGroupArrayAll=a,c._options._uniqueGroupArrayAll.sort(function(a,b){return e.getIndexOfElement(a,c._options._uniqueGroupTmp)-e.getIndexOfElement(b,c._options._uniqueGroupTmp)}),e.existy(c._options._secondAxis)&&(c._options._secondAxis=e.isOverlapArray(c._options._uniqueGroupArray2,a)||!a.length&&c._options._uniqueGroupArray2.length),a.length&&a.length!==c._options._uniqueGroupTmp.length||(f.classed("inactive",!1).classed("active",!1).classed("unhover",!1),c._options._uniqueGroupArrayAll=c._options._uniqueGroupTmp),c._updateDatasetBySelection(a),a.length===c._options._uniqueGroupTmp.length&&(a=[])})}else b.select(".legend").style("display","none")}var c=this;return e.existy(a)?(e.typeString(a)&&"refresh"===a?b():(c.setOptions(arguments,"legend"),b()),c):c._options.legend},e.prototype._updateDatasetBySelection=function(a){var b=this,c=[];a.length?c=b._options._datasetTmp.filter(function(b,c){return a.indexOf(b.group)>=0}):(c=b._options._datasetTmp,b._options._datasetTmp=[],b._options._uniqueGroupTmp=[]),b.constructor===o?b.setOptions([c],"_dataset")._drawChartSVG().title("refresh").tooltip("refresh"):(b.setOptions([c],"_dataset"),b.min("refresh").max("refresh").updateMin(),b._options._secondAxis&&b.min2("refresh").max2("refresh").updateMin2(),b._drawChartSVG(),b.background("refresh").xLabel("refresh").yLabel("refresh").xAxis("refresh").yAxis("refresh").title("refresh").tooltip("refresh"),b.yLabel2("refresh").yAxis2("refresh"))},e.prototype.line=function(a){var b=this;return e.existy(a)?(b._setSpecificPropertiesByChart(a,"line"),b):b._options.line},e.prototype._drawLineSVG=function(a){var b,c=this,d=c._options._dataset,f=c._options._uniqueGroupTmp.length?c._options._uniqueGroupTmp:c._options._uniqueGroupArrayAll;b=d3.select(c._options.selector).select(".bChart_wrapper").empty()?d3.select(c._options.selector).append("div").attr("class","bChart_wrapper"):d3.select(c._options.selector).select(".bChart_wrapper");var g,h,i=b.select("g.bChart"),j=[];if(g=i.select(".bChart_lines").empty()?i.append("g").attr("class","bChart_lines"):i.select(".bChart_lines"),e.existy(a)){var k=function(a){var b=d.filter(function(b){return b.group===a});j.push(b)};e.each(c._options._uniqueGroupArrayAll,k),h=g.selectAll(".bChart_groups").data(j),h.enter().append("path"),h.exit().remove();var l=d3.svg.line().x(function(b){return c._options.xAxis.isTimeSeries?a.x0(new Date(b.x)):a.x0(b.x)}).y(function(b){return b._secondAxis?a.y2(b.value):a.y(b.value)});h.attr("d",l)}else h=g.selectAll(".bChart_groups");return h.empty()||h.attr("class",function(a,b){return"bChart_groups bChart_groups_"+f.indexOf(a[b].group)}).attr("fill-opacity",function(){return 0}).attr("stroke",function(a,b){return c._options._colorMap[a[b].group]}).attr("stroke-width",function(a,b){return c._options.line.strokeWidth[f.indexOf(a[b].group)]}).style("opacity",.1).transition().duration(c._options.duration).style("opacity",function(a,b){return c._options.line.strokeOpacity[f.indexOf(a[b].group)]}),c},e.initLineType=e.initStyleProperty("type","line"),e.initLineStrokeWidth=e.initStyleProperty("strokeWidth","line"),e.initLineStrokeOpacity=e.initStyleProperty("strokeOpacity","line"),e.removeLineType=e.removeStyleProperty("type","line"),e.removeLineStrokeWidth=e.removeStyleProperty("strokeWidth","line"),e.removeLineStrokeOpacity=e.removeStyleProperty("strokeOpacity","line");var l={title:{text:"Line Chart"},node:{display:[],type:[],size:[],fillOpacity:[],solidCircle:[],strokeWidth:[]},line:{type:[],strokeWidth:[],strokeOpacity:[]}},m=function(a){return e._customConstructor(this,a,arguments,"line")};e.LineChart=m,m.prototype=Object.create(e.prototype),m.prototype.constructor=m,m.prototype._drawLineChart=function(){var a=this,b=a._initXYAxis();return a._drawLineSVG(b)._drawNodeSVG(b),a},e.prototype.max2=function(a){var b=this;if(!e.existy(a))return b._options.maxDefault2;if(e.typeNumber(a))b._options.max2=a,b._options.maxDefault2=a;else if(e.typeString(a)&&"refresh"===a)if(b._options.isStack){var c=[];e.each(b._options._uniqueXArray,function(a,d,e){var f=b._options._dataset.filter(function(b){return a===b.x&&b._secondAxis});c.push(d3.sum(f,function(a){return parseFloat(a.value)}))}),b._options.maxDefault2=d3.max(c)}else e.existy(b._options.max2)?b._options.maxDefault2=b._options.max2:b._options.maxDefault2=d3.max(b._options._dataset,function(a){return a._secondAxis?parseFloat(a.value):void 0});return b},e.prototype.max=function(a){var b=this;if(!e.existy(a))return b._options.maxDefault;if(e.typeNumber(a))b._options.max=a,b._options.maxDefault=a;else if(e.typeString(a)&&"refresh"===a)if(b._options.isStack){var c=[];e.each(b._options._uniqueXArray,function(a,d,e){var f=b._options._dataset.filter(function(b){return a===b.x});c.push(d3.sum(f,function(a){return parseFloat(a.value)}))}),b._options.maxDefault=d3.max(c)}else e.existy(b._options.max)?b._options.maxDefault=b._options.max:b._options.maxDefault=d3.max(b._options._dataset,function(a){return parseFloat(a.value)});return b},e.prototype.min2=function(a){var b=this;return e.existy(a)?(e.typeNumber(a)?(b._options.min2=a,b._options.minDefault2=a):e.typeString(a)&&"refresh"===a&&(e.existy(b._options.min2)?b._options.minDefault2=b._options.min2:b._options.minDefault2=d3.min(b._options._dataset,function(a){return a._secondAxis?parseFloat(a.value):void 0})),b):b._options.minDefault2},e.prototype.min=function(a){var b=this;return e.existy(a)?(e.typeNumber(a)?(b._options.min=a,b._options.minDefault=a):e.typeString(a)&&"refresh"===a&&(e.existy(b._options.min)?b._options.minDefault=b._options.min:b._options.minDefault=d3.min(b._options._dataset,function(a){return parseFloat(a.value)})),b):b._options.minDefault},e.prototype.updateMin2=function(){var a=this;return e.existy(a._options.max2)||e.existy(a._options.min2)||(a._options.minDefault2-=(a._options.maxDefault2-a._options.minDefault2)/a._options.yAxis2.tickNumber),a._options.minDefault2=a._options.minDefault2<=0?0:a._options.minDefault2,a},e.prototype.updateMin=function(){var a=this;return e.existy(a._options.max)||e.existy(a._options.min)||(a._options.minDefault-=(a._options.maxDefault-a._options.minDefault)/a._options.yAxis.tickNumber),a._options.minDefault=a._options.minDefault<0?0:a._options.minDefault,a},e.prototype.node=function(a){var b=this;return e.existy(a)?(b._setSpecificPropertiesByChart(a,"node"),b):b._options.node},e.prototype._drawNodeSVG=function(a){var b,c=this,d=c._options._dataset,f=c._options._uniqueGroupTmp.length?c._options._uniqueGroupTmp:c._options._uniqueGroupArrayAll;b=d3.select(c._options.selector).select(".bChart_wrapper").empty()?d3.select(c._options.selector).append("div").attr("class","bChart_wrapper"):d3.select(c._options.selector).select(".bChart_wrapper");var g,h,i=b.select("g.bChart");g=i.select(".bChart_nodes").empty()?i.append("g").attr("class","bChart_nodes"):i.select(".bChart_nodes");var j=d3.svg.symbol().type(function(a){var b=f.indexOf(a.group);return c._options.node.type[b]}).size(function(a){var b=f.indexOf(a.group);return e.existy(a.size)?a.size:c._options.node.size[b]});return e.existy(a)?(h=g.selectAll(".bChart_groups").data(d),h.enter().append("path"),h.exit().remove(),h.attr("class",function(a){return"bChart_groups bChart_groups_"+f.indexOf(a.group)}).attr("d",j).attr("transform",function(b){var d;return d=c._options.xAxis.isTimeSeries?a.x0(new Date(b.x)):a.x0(b.x),b._secondAxis?"translate("+d+","+a.y2(b.value)+")":"translate("+d+","+a.y(b.value)+")"}).style("opacity",0).transition().duration(c._options.duration).style("opacity",1)):h=g.selectAll(".bChart_groups"),h.empty()||h.attr("fill",function(a){var b=f.indexOf(a.group);if(c._options.node.solidCircle[b])return c._options.background.color;var d=c._options._colorMap[a.group],e=d.split(",");return e[0]+","+e[1]+","+e[2]+","+c._options.node.fillOpacity[b]+")"}).attr("stroke",function(a){return c._options._colorMap[a.group]}).attr("stroke-width",function(a){var b=f.indexOf(a.group);return c._options.node.strokeWidth[b]}).attr("d",j).style("display",function(a){var b=f.indexOf(a.group);return c._options.node.display[b]?"block":"none"}),c},e.initNodeDisplay=e.initStyleProperty("display","node"),e.initNodeType=e.initStyleProperty("type","node"),e.initNodeSize=e.initStyleProperty("size","node"),e.initNodeFillOpacity=e.initStyleProperty("fillOpacity","node"),e.initNodeStrokeWidth=e.initStyleProperty("strokeWidth","node"),e.initNodeStrokeOpacity=e.initStyleProperty("strokeOpacity","node"),e.initNodeSolidCircle=e.initStyleProperty("solidCircle","node"),e.removeNodeDisplay=e.removeStyleProperty("display","node"),e.removeNodeType=e.removeStyleProperty("type","node"),e.removeNodeSize=e.removeStyleProperty("size","node"),e.removeNodeFillOpacity=e.removeStyleProperty("fillOpacity","node"),e.removeNodeStrokeWidth=e.removeStyleProperty("strokeWidth","node"),e.removeNodeStrokeOpacity=e.removeStyleProperty("strokeOpacity","node"),e.removeNodeSolidCircle=e.removeStyleProperty("solidCircle","node");var n={width:400,height:400,_textRadiusDefault:"",_outerRadiusDefault:"",_innerRadiusDefault:"",valueDisplay:{display:!0},title:{text:"Pie Chart"},_originCentroid:[],isDonut:!1,isPullOut:!1,pullOutSize:10,tooltip:{type:0}},o=function(a){return e._customConstructor(this,a,arguments,"pie")};e.PieChart=o,o.prototype=Object.create(e.prototype),o.prototype.constructor=o,o.prototype.draw=function(){var a=this;return e.getLength(d3.select(a._options.selector))?(a.colors("refresh")._drawChartSVG(),void a.background("refresh").title("refresh").legend("refresh").tooltip("refresh")):void console.log("Please make sure the element exists in your template.")},o.prototype._drawPieChart=function(){var a=this;a._updateChartSize();var b,c=a._options._dataset,d=a._options._uniqueGroupTmp.length?a._options._uniqueGroupTmp:a._options._uniqueGroupArrayAll;b=d3.select(a._options.selector).select(".bChart_wrapper").empty()?d3.select(a._options.selector).append("div").attr("class","bChart_wrapper"):d3.select(a._options.selector).select(".bChart_wrapper");var f=b.select("g.bChart"),g=d3.sum(c,function(a){return parseFloat(a.value)});e.existy(a._options.outerRadius)&&a._options.outerRadius?a._options._outerRadiusDefault=a._options.outerRadius:a._options._outerRadiusDefault=a._options._chartSVGWidth>a._options._chartSVGHeight?a._options._chartSVGHeight/2:a._options._chartSVGWidth/2,e.existy(a._options.textRadius)&&a._options.textRadius?a._options._textRadiusDefault=a._options.textRadius:a._options._textRadiusDefault=2*a._options._outerRadiusDefault/3,e.existy(a._options.innerRadius)&&a._options.innerRadius?a._options._innerRadiusDefault=a._options.innerRadius:a._options._innerRadiusDefault=a._options._outerRadiusDefault/3;var h,i,j,k,l,m=a.getArc(),n=d3.layout.pie().value(function(a){return a.value}).sort(null);j=n(c),h=f.select(".bChart_pie").empty()?f.append("g").attr("class","bChart_pie"):f.select(".bChart_pie"),h.attr("transform","translate("+a._options._chartSVGWidth/2+","+a._options._chartSVGHeight/2+")");var o=function(a){var b=d3.interpolate(this._current,a);return this._current=b(0),function(a){return m(b(a))}};return l=h.selectAll(".bChart_groups").data(j),l.enter().append("g").attr("class",function(a){return"bChart_groups bChart_groups_"+d.indexOf(a.data.group)}),l.exit().remove(),i=l.selectAll(".bChart_arc").data(function(a){return[a]}),i.exit().remove(),i.enter().append("path").attr("class",function(a){return"bChart_arc"}).attr("fill",function(b){return a._options._colorMap[b.data.group]}).attr("stroke","#ffffff").each(function(a,b){b>0?this._current=j[b-1]:this._current={startAngle:0,endAngle:0}}).transition().duration(a._options.duration).attr("d",o),i.attr("class",function(a){return"bChart_arc"}).attr("fill",function(b){return a._options._colorMap[b.data.group]}).transition().duration(a._options.duration).attrTween("d",o),k=l.selectAll(".bChart_arc_text").data(function(a){return[a]}),a._options.valueDisplay.display?(k.style("display","block"),k.exit().remove(),k.enter().append("text").attr("class",function(a){return"bChart_arc_text"}),k.attr("class",function(a){return"bChart_arc_text"}).attr("transform",function(b){return"translate("+Math.cos((b.startAngle+b.endAngle-Math.PI)/2)*a._options._textRadiusDefault+","+Math.sin((b.startAngle+b.endAngle-Math.PI)/2)*a._options._textRadiusDefault+")"}).attr("text-anchor","middle").text(function(a){return d3.format("%")(a.data.value/g)}).attr("fill","#ffffff")):k.style("display","none"),a},o.prototype.pullOutSegement=function(a){var b=this,c=d3.select(a),d=b.getArc();c.transition().duration(b._options.duration).attr("transform",function(a){b._options._originCentroid=d.centroid(a);var c=b._options._originCentroid[0],e=b._options._originCentroid[1],f=Math.sqrt(c*c+e*e);return"translate("+c/f*b._options.pullOutSize+","+e/f*b._options.pullOutSize+")"})},o.prototype.restoreOutSegement=function(a){var b=this,c=d3.select(a),d=b.getArc();c.transition().duration(b._options.duration).attr("transform",function(a){var c=d.centroid(a),e=c[0],f=c[1];return"translate("+(b._options._originCentroid[0]-e)+","+(b._options._originCentroid[1]-f)+")"})},o.prototype.getArc=function(){var a,b=this;return a=b._options.isDonut?d3.svg.arc().innerRadius(b._options._innerRadiusDefault).outerRadius(b._options._outerRadiusDefault).startAngle(function(a){return a.startAngle}).endAngle(function(a){return a.endAngle}):d3.svg.arc().outerRadius(b._options._outerRadiusDefault).startAngle(function(a){return a.startAngle}).endAngle(function(a){return a.endAngle})};var p={title:{text:"Scatter Chart"},tooltip:{type:0},node:{display:[],solidCircle:[],type:[],size:[],fillOpacity:[],strokeWidth:[]}},q=function(a){return e._customConstructor(this,a,arguments,"scatter")};return e.ScatterChart=q,q.prototype=Object.create(e.prototype),q.prototype.constructor=q,q.prototype._drawScatterChart=function(){var a=this,b=a._initXYAxis();return a._drawNodeSVG(b),a},e.prototype.title=function(a){function b(){var a,b=d3.select(c._options.selector).select("g.bChart");c._options.title.display?(a=b.select(".bChart_title").empty()?b.append("g").append("text").attr("class","bChart_title"):b.select(".bChart_title").style("display","block"),a.attr("x",c._options._chartSVGWidth/2+c._options.title.offsetAdjust.horizontal).attr("y",-c._options.padding.top+c._options.title.offsetAdjust.vertical+30).attr("text-anchor","middle").style("font-size",c._options.title.fontSize).style("font-family",c._options.title.fontType).style("fill",c._options.title.fontColor).style("text-decoration",function(){return c._options.title.fontUnderline?"underline":"none"}).style("font-weight",function(){return c._options.title.fontBold?"bold":"normal"}).style("font-style",function(){return c._options.title.fontItalic?"italic":"normal"}).text(c._options.title.text)):b.select(".bChart_title").style("display","none")}var c=this;return e.existy(a)?(e.typeString(a)&&"refresh"===a?b():(c.setOptions(arguments,"title"),b()),c):c._options.title},e.prototype.tooltip=function(a){function b(){function a(a){function b(){var a,b=c._getComputedX(),j={};if(e.existy(b.x0.invert)){var k=b.x0.invert(d3.mouse(this)[0]),l=f(g,k,1),m=g[l-1],n=g[l];e.existy(n)?e.existy(m.x)&&e.existy(n.x)&&(j=c._options.xAxis.isTimeSeries?k.getTime()-new Date(m.x).getTime()>new Date(n.x).getTime()-k.getTime()?n:m:k-m.x>n.x-k?n:m):j=m,a=c._options.xAxis.isTimeSeries?b.x0(new Date(j.x)):b.x0(j.x),a+=80}else{var o,p=d3.mouse(this)[0],q=b.x0.range(),r=0===b.x0.rangeBand()?(q[1]-q[0])/2:b.x0.rangeBand();for(o=0;p>q[o]+r;o++);o>=q.length&&(o=q.length-1),j=g[o],a=0===b.x0.rangeBand()?q[o]+80:q[o]+r/2+80}var s="";if(e.existy(c._options.tooltip.html)&&c._options.tooltip.html)s=c._options.tooltip.html,s=h(s,j);else{s+="<div class='bchart-tooltip-header'>"+j.x+"</div>";for(var t=0;t<c._options._uniqueGroupArrayAll.length;t++){var u=c._options._uniqueGroupArrayAll[t];s+="<div class='bchart-tooltip-row'><div class='bchart-tooltip-group'>"+u+"</div><div class='bchart-tooltip-value'>"+j[u]+"</div></div>"}}var v=d3.event.hasOwnProperty("offsetY")?d3.event.offsetY:d3.event.layerY;i.attr("x2",0).attr("transform","translate("+(a-80)+",0)"),d.style("background",c._options.tooltip.background).style("top",v+10+"px").style("left",a+"px").style("font-family",c._options.tooltip.fontType).style("text-decoration",function(){return c._options.tooltip.fontUnderline?"underline":"none"}).style("font-weight",function(){return c._options.tooltip.fontBold?"bold":"normal"}).style("font-style",function(){return c._options.tooltip.fontItalic?"italic":"normal"}).style("font-size",c._options.tooltip.fontSize).style("color",c._options.tooltip.fontColor).html(s),d.selectAll(".bchart-tooltip-group").style("background",function(a,b){return c._options._colorMap[c._options._uniqueGroupArrayAll[b]]}),d.selectAll(".bchart-tooltip-value").style("background",function(a,b){return c._options._colorMap[c._options._uniqueGroupArrayAll[b]]})}var f=d3.bisector(function(a){return c._options.xAxis.isTimeSeries?new Date(a.x):a.x}).left,g=[];e.each(c._options._uniqueXArray,function(a){var b={};e.each(c._options._dataset,function(c){c.x===a&&(b.x=a,b[c.group]=c.value)}),g.push(b)});var i;i=a.selectAll(".bchart-focus-x-line").empty()?a.select(".bChart").append("line").attr("class","bchart-focus-x-line"):a.select(".bchart-focus-x-line"),i.style("stroke",c._options.tooltip.xLine.stroke).style("stroke-width",c._options.tooltip.xLine.strokeWidth).style("opacity",0).attr("y1",0).attr("y2",c._options._chartSVGHeight);var j;j=a.selectAll(".bchart-focus-rect").empty()?a.select(".bChart").append("rect").attr("class","bchart-focus-rect"):a.select(".bchart-focus-rect"),j.attr("width",c._options._chartSVGWidth).attr("height",c._options._chartSVGHeight).style("fill","none").attr("pointer-events","all").on("mouseover",function(){d.transition().duration(c._options.duration).style("opacity",1).style("display","block"),i.transition().duration(c._options.duration).style("opacity",1)}).on("mousemove",b).on("mouseout",function(){d.transition().duration(c._options.duration).style("opacity",0).style("display","none"),i.transition().duration(c._options.duration).style("opacity",0)})}function b(a){var b=a.selectAll(".bChart_groups");if(a.select(".bchart-focus-rect").remove(),a.select(".bchart-focus-x-line").remove(),b.on("mouseover",function(a){d3.select(this).style("opacity",.7),d.transition().duration(c._options.duration).style("opacity",1).style("display","block"),c.constructor===o&&c._options.isPullOut&&c.pullOutSegement(this)}).on("mousemove",function(a){var b;b=c.constructor===o?a.data.group+" : "+a.value:a.group+"("+a.x+") :"+a.value;var e;e=c.constructor===o?d3.select(this).select(".bChart_arc").style("fill"):d3.select(this).style("fill");var f=d3.event.hasOwnProperty("offsetX")?d3.event.offsetX:d3.event.layerX,g=d3.event.hasOwnProperty("offsetY")?d3.event.offsetY:d3.event.layerY;d.style("background",e).style("top",g-10+"px").style("left",f+10+"px").style("font-family",c._options.tooltip.fontType).style("text-decoration",function(){return c._options.tooltip.fontUnderline?"underline":"none"}).style("font-weight",function(){return c._options.tooltip.fontBold?"bold":"normal"}).style("font-style",function(){return c._options.tooltip.fontItalic?"italic":"normal"}).style("font-size",c._options.tooltip.fontSize).style("color",c._options.tooltip.fontColor).html(b)}).on("mouseout",function(a){d3.select(this).style("opacity",1),d.transition().duration(c._options.duration).style("opacity",0).style("display","none"),c.constructor===o&&c._options.isPullOut&&c.restoreOutSegement(this)}),!a.select(".bChart_lines").empty()){var e=a.select(".bChart_lines").selectAll(".bChart_groups");e.on("mouseover",null).on("mousemove",null).on("mouseout",null)}if(!a.select(".bChart_areas").empty()){var f=a.select(".bChart_areas").selectAll(".bChart_groups");f.on("mouseover",null).on("mousemove",null).on("mouseout",null)}}var d;if(c._options.tooltip.display){var f;f=d3.select(c._options.selector).select(".bChart_wrapper").empty()?d3.select(c._options.selector).append("div").attr("class","bChart_wrapper"):d3.select(c._options.selector).select(".bChart_wrapper"),d=f.select(".bChart_tooltip").empty()?f.append("div").attr("class","bChart_tooltip").style("opacity",0):f.select(".bChart_tooltip").style("opacity",0),1===c._options.tooltip.type?a(f):b(f)}else d.remove();var g=function(a,b,c){for(var d=/\#([^#]+)\#/g,f=a.match(d),g=a,h=0;h<f.length;h++){var i,j=f[h],k=j.substring(1,j.length-1).toLowerCase();switch(k){case"group":i=e.existy(c)?c:b.group;break;case"x":i=b.x;break;case"value":i=e.existy(c)?b[c]:b.value}g=g.replace(j,i)}return g},h=function(a,b){for(var d=/\{\{([^{}]+)\}\}/g,e=a.match(d),f=a,h="",i=0;i<e.length;i++){var j=e[i],k=j.split(":"),l="";if(k[0].indexOf("group")>=0){c._options.tooltip.groupHTML?(c._options.tooltip._groupHTML=c._options.tooltip.groupHTML,l=c._options.tooltip._groupHTML,f=f.replace(j,l)):(c._options.tooltip._groupHTML=k[1].slice(0,-2),l=j);for(var m=0;m<c._options._uniqueGroupArrayAll.length;m++){var n=c._options._uniqueGroupArrayAll[m];h=g(c._options.tooltip._groupHTML,b,n),f=f.replace(l,h),m<c._options._uniqueGroupArrayAll.length-1&&(f+=l)}}else k[0].indexOf("x")>=0&&(c._options.tooltip.xHTML?(c._options.tooltip._xHTML=c._options.tooltip.xHTML,l=c._options.tooltip._xHTML,f=f.replace(j,l)):(c._options.tooltip._xHTML=k[1].slice(0,-2),l=j),h=g(c._options.tooltip._xHTML,b),f=f.replace(l,h))}return f}}var c=this;return e.existy(a)?(e.typeString(a)&&"refresh"===a?b():(c.setOptions(arguments,"tooltip"),b()),c):c._options.tooltip},e.prototype._getComputedX=function(){var a,b,c=this;if(c._options.xAxis.isTimeSeries){var d,f,g;c._options._uniqueXArray.length>0?(e.sortByDate(c._options._uniqueXArray),d=c._options._uniqueXArray[c._options._uniqueXArray.length-1],f=new Date(d),g=new Date(c._options._uniqueXArray[0]),1===c._options._uniqueXArray.length?(g.setHours(f.getHours()-1),f.setHours(f.getHours()+1)):f.setDate(f.getDate()+1)):(f=new Date,g=new Date),a=d3.time.scale().range([0,c._options._chartSVGWidth]).domain([g,f])}else c.constructor===i?(a=d3.scale.ordinal().rangeRoundBands([0,c._options._chartSVGWidth],.1).domain(c._options._uniqueXArray),b=d3.scale.ordinal().rangeRoundBands([0,a.rangeBand()]).domain(c._options._uniqueGroupArrayAll)):a=d3.scale.ordinal().rangePoints([0,c._options._chartSVGWidth],.1).domain(c._options._uniqueXArray);return c._options._dataset=e.sortedByArray(c._options._dataset,c._options._uniqueXArray),{x0:a,x1:b}},e.prototype._getXAxis=function(a){var b,c,d=this;b="auto"===d._options.xAxis.innerTickSize?-d._options._chartSVGHeight:d._options.xAxis.innerTickSize,c="auto"===d._options.xAxis.outerTickSize?-d._options._chartSVGHeight:d._options.xAxis.outerTickSize;var f=d3.svg.axis().scale(a).orient(d._options.xAxis.orientation).tickPadding(d._options.xAxis.offsetAdjust+3).innerTickSize(b).outerTickSize(c);if(d._options.xAxis.isTimeSeries){var g,h;if(d._options.xAxis.timeTick)g=d3.time[d._options.xAxis.timeTick];else if(d._options._uniqueXArray.length>0){var i=new Date(d._options._uniqueXArray[d._options._uniqueXArray.length-1]).getTime()-new Date(d._options._uniqueXArray[0]).getTime();g=e.computeTimeTick(i)}else g=d3.time.days;h=d._options.xAxis.timeFormat?e.generateDateFormatter(d._options.xAxis.timeFormat):e.generateDateFormatter(),f.ticks(g).tickFormat(h)}else f.ticks(d._options.xAxis.tickNumber);return f},e.prototype._renderXAxis=function(a){var b=this,c=d3.select(b._options.selector).select("g.bChart");return c.select(".bChart_x_axis").empty()?c.append("g").attr("class","bChart_x_axis bChart_grid").attr("transform","translate(0,"+b._options._chartSVGHeight+")").call(a):c.select(".bChart_x_axis").attr("transform","translate(0,"+b._options._chartSVGHeight+")").transition().duration(b._options.duration).ease("sin-in-out").call(a),c.select(".bChart_x_axis").select("text").empty()||b._updateXAxisStyle(),b},e.prototype._updateXAxisStyle=function(){var a=this,b=d3.select(a._options.selector).select("g.bChart"),c=b.select(".bChart_x_axis").selectAll("path"),d=b.select(".bChart_x_axis").selectAll("line"),e=b.select(".bChart_x_axis").selectAll("text");if(a._options.xAxis.display){c.style("stroke-width",a._options.xAxis.axisWidth).style("stroke",a._options.xAxis.axisColor).style("display","block"),e.style("display","block");var f;switch(a._options.xAxis.rotation){case-45:f="end";break;case-90:f="end";break;case 45:f="start";break;case 90:f="start";break;case 0:f="middle"}var g=0,h=+e.attr("y");e.attr("transform",function(b){return"rotate("+a._options.xAxis.rotation+" "+g+","+h+")"}).style("text-anchor",f).style("font-size",a._options.xAxis.fontSize).style("fill",a._options.xAxis.fontColor).style("text-decoration",function(){return a._options.xAxis.fontUnderline?"underline":"none"}).style("font-weight",function(){return a._options.xAxis.fontBold?"bold":"normal"}).style("font-style",function(){return a._options.xAxis.fontItalic?"italic":"normal"}).style("font-family",a._options.xAxis.fontType)}else c.style("display","none"),e.style("display","none");a._options.xAxis.displayTicksLine?d.style("stroke-width",a._options.xAxis.tickLineWidth).style("stroke",a._options.xAxis.tickLineColor).style("display","block"):d.style("display","none")},e.prototype.xAxis=function(a){function b(){var a=c._getComputedX().x0,b=c._getXAxis(a);c._renderXAxis(b)}var c=this;return e.existy(a)?(e.typeString(a)&&"refresh"===a?b():(c.setOptions(arguments,"xAxis"),b()),c):c._options.xAxis},e.prototype.xLabel=function(a){function b(){var a,b,d,e=d3.select(c._options.selector).select("g.bChart");c._options.xLabel.display?(a=e.select(".bChart_xlabel").empty()?e.append("g").append("text").attr("class","bChart_xlabel"):e.select(".bChart_xlabel").style("display","block"),b=c._options._chartSVGWidth/2+c._options.xLabel.offsetAdjust.horizontal,d=c._options._chartSVGHeight+c._options.padding.bottom-20-c._options.xLabel.offsetAdjust.vertical,a.style("font-size",c._options.xLabel.fontSize).style("font-family",c._options.xLabel.fontType).style("fill",c._options.xLabel.fontColor).attr("x",b).attr("y",d).style("text-anchor","middle").style("text-decoration",function(){return c._options.xLabel.fontUnderline?"underline":"none"}).style("font-weight",function(){return c._options.xLabel.fontBold?"bold":"normal"}).style("font-style",function(){return c._options.xLabel.fontItalic?"italic":"normal"}).attr("transform",function(a){return"rotate("+c._options.xLabel.rotation+" "+b.toString()+" "+d.toString()+")"}).text(c._options.xLabel.text)):e.select(".bChart_xlabel").style("display","none")}var c=this;return e.existy(a)?(e.typeString(a)&&"refresh"===a?b():(c.setOptions(arguments,"xLabel"),b()),c):c._options.xLabel},e.prototype._getComputedY=function(){var a,b,c=this;return a=d3.scale.linear().range([c._options._chartSVGHeight,0]).domain([c._options.minDefault,c._options.maxDefault]),c._options._secondAxis&&(b=d3.scale.linear().range([c._options._chartSVGHeight,0]).domain([c._options.minDefault2,c._options.maxDefault2])),{y1:a,y2:b}},e.prototype._getYAxis=function(a,b){var c=this,d="";d=e.existy(b)&&b?"yAxis2":"yAxis";var f,g;return f="auto"===c._options[d].innerTickSize?-c._options._chartSVGWidth:c._options[d].innerTickSize,g="auto"===c._options[d].outerTickSize?-c._options._chartSVGWidth:c._options[d].outerTickSize,d3.svg.axis().scale(a).orient(c._options[d].orientation).tickFormat(c._options[d].tickFormat).tickPadding(c._options[d].offsetAdjust+3).ticks(c._options[d].tickNumber).innerTickSize(f).outerTickSize(g)},e.prototype._renderYAxis=function(a,b){var c=this,d=d3.select(c._options.selector).select("g.bChart");return e.existy(b)&&b?(d.select(".bChart_y_axis_2").empty()?d.append("g").attr("class","bChart_y_axis_2 bChart_grid").attr("transform","translate("+c._options._chartSVGWidth+",0)").call(a):d.select(".bChart_y_axis_2").attr("transform","translate("+c._options._chartSVGWidth+",0)").transition().duration(c._options.duration).ease("sin-in-out").call(a),d.select(".bChart_y_axis_2").select("text").empty()||c._updateYAxisStyle(b)):(d.select(".bChart_y_axis").empty()?d.append("g").attr("class","bChart_y_axis bChart_grid").call(a):d.select(".bChart_y_axis").transition().duration(c._options.duration).ease("sin-in-out").call(a),d.select(".bChart_y_axis").select("text").empty()||c._updateYAxisStyle()),c},e.prototype.yAxis2=function(a){var b=this;if(e.existy(a)){if(e.typeString(a)&&"refresh"===a||b.setOptions(arguments,"yAxis2"),
b._options._secondAxis)b.yAxis("yAxis2");else{var c=d3.select(b._options.selector).select("g.bChart");c.select(".bChart_y_axis_2").style("display","none")}return b}return b._options.yAxis2},e.prototype._updateYAxisStyle=function(a){var b,c,d,f,g,h=this,i=d3.select(h._options.selector).select("g.bChart");if(e.existy(a)&&a?(b="yAxis2",c=i.select(".bChart_y_axis_2"),d=i.select(".bChart_y_axis_2").selectAll("path"),f=i.select(".bChart_y_axis_2").selectAll("line"),g=i.select(".bChart_y_axis_2").selectAll("text")):(b="yAxis",c=i.select(".bChart_y_axis"),d=i.select(".bChart_y_axis").selectAll("path"),f=i.select(".bChart_y_axis").selectAll("line"),g=i.select(".bChart_y_axis").selectAll("text")),h._options[b].display){c.style("display","block"),d.style("stroke-width",h._options[b].axisWidth).style("stroke",h._options[b].axisColor).style("display","block"),g.style("display","block");var j;switch(h._options[b].rotation){case-45:j=a?"start":"end";break;case-90:j="middle";break;case 45:j=a?"start":"end";break;case 90:j="middle";break;case 0:j=a?"start":"end"}var k=+g.attr("x"),l=0;g.style("text-anchor",j).attr("transform",function(){return"rotate("+h._options[b].rotation+" "+k+","+l+")"}).style("font-size",h._options[b].fontSize).style("fill",h._options[b].fontColor).style("text-decoration",function(){return h._options[b].fontUnderline?"underline":"none"}).style("font-weight",function(){return h._options[b].fontBold?"bold":"normal"}).style("font-style",function(){return h._options[b].fontItalic?"italic":"normal"}).style("font-family",h._options[b].fontType)}else d.style("display","none"),g.style("display","none");h._options[b].displayTicksLine?f.style("stroke-width",h._options[b].tickLineWidth).style("stroke",h._options[b].tickLineColor).style("display","block"):f.style("display","none")},e.prototype.yAxis=function(a){function b(a){var b,d,f=c._getComputedY();e.existy(a)&&a?(b=f.y2,d=c._getYAxis(b,!0),c._renderYAxis(d,!0)):(b=f.y1,d=c._getYAxis(b,!1),c._renderYAxis(d,!1))}var c=this;return e.existy(a)?(e.typeString(a)&&"refresh"===a?b():"yAxis2"===a?b(!0):(c.setOptions(arguments,"yAxis"),b()),c):c._options.yAxis},e.prototype.yLabel2=function(a){var b=this;if(e.existy(a)){if(e.typeString(a)&&"refresh"===a||b.setOptions(arguments,"yLabel2"),b._options._secondAxis)b.yLabel("yLabel2");else{var c=d3.select(b._options.selector).select("g.bChart");c.select(".bChart_ylabel_2").style("display","none")}return b}return b._options.yLabel2},e.prototype.yLabel=function(a){function b(a){var b,d,f,g;b=e.existy(a)&&a?"yLabel2":"yLabel";var h=d3.select(c._options.selector).select("g.bChart");c._options[b].display?(g=e.existy(a)&&a?h.select(".bChart_ylabel_2").empty()?h.append("g").append("text").attr("class","bChart_ylabel_2"):h.select(".bChart_ylabel_2").style("display","block"):h.select(".bChart_ylabel").empty()?h.append("g").append("text").attr("class","bChart_ylabel"):h.select(".bChart_ylabel").style("display","block"),d=c._options._chartSVGHeight/2-c._options[b].offsetAdjust.vertical,f=e.existy(a)&&a?c._options.padding.left+c._options._chartSVGWidth+c._options[b].offsetAdjust.horizontal:-c._options.padding.left+25+c._options[b].offsetAdjust.horizontal,g.style("text-anchor","middle").style("fill",c._options[b].fontColor).attr("y",d).attr("x",f).attr("transform",function(a){return"rotate("+c._options[b].rotation+" "+f.toString()+" "+d.toString()+")"}).style("font-size",c._options[b].fontSize).style("font-family",c._options[b].fontType).style("text-decoration",function(){return c._options[b].fontUnderline?"underline":"none"}).style("font-weight",function(){return c._options[b].fontBold?"bold":"normal"}).style("font-style",function(){return c._options[b].fontItalic?"italic":"normal"}).text(c._options[b].text)):e.existy(a)&&a?h.select(".bChart_ylabel_2").style("display","none"):h.select(".bChart_ylabel").style("display","none")}var c=this;return e.existy(a)?(e.typeString(a)&&"refresh"===a?b():"yLabel2"===a?b(!0):(c.setOptions(arguments,"yLabel"),b()),c):c._options.yLabel},e});