var jfc;if(!jfc)jfc={};jfc.Utils={};jfc.Utils.makeArrayOf=function(value,length){var arr=[],i=length;while(i--)arr[i]=value;return arr};jfc.Utils.findChartRef=function(element){var id=element.getAttribute("jfreesvg:ref");var found=false;var current=element;while(!found){current=current.parentNode;if(current!=null){id=current.getAttribute("jfreesvg:ref");found=id!=null}else found=true}return id};
jfc.Utils.findChartId=function(element){var id=null;var found=false;var current=element;while(!found){current=current.parentNode;if(current!=null){var ref=current.getAttribute("jfreesvg:ref");if(ref=="JFREECHART_TOP_LEVEL"){found=true;id=current.getAttribute("id")}}else found=true}return id};if(!jfc)jfc={};orsoncharts.KeyedValuesDataset=function(){if(!(this instanceof jfc.KeyedValuesDataset))return new orsoncharts.KeyedValuesDataset;this.data=[];this.listeners=[]};orsoncharts.KeyedValuesDataset.prototype.itemCount=function(){return this.data.length};orsoncharts.KeyedValuesDataset.prototype.isEmpty=function(){return this.data.length===0};orsoncharts.KeyedValuesDataset.prototype.key=function(index){return this.data[index][0]};orsoncharts.KeyedValuesDataset.prototype.keys=function(){return this.data.map(function(d){return d[0]})};
orsoncharts.KeyedValuesDataset.prototype.indexOf=function(sectionKey){var arrayLength=this.data.length;for(var i=0;i<arrayLength;i++)if(this.data[i][0]===sectionKey)return i;return-1};orsoncharts.KeyedValuesDataset.prototype.valueByIndex=function(index){return this.data[index][1]};orsoncharts.KeyedValuesDataset.prototype.valueByKey=function(sectionKey){var sectionIndex=this.indexOf(sectionKey);if(sectionIndex<0)return null;return this.valueByIndex(sectionIndex)};
orsoncharts.KeyedValuesDataset.prototype.addListener=function(listenerMethod){this.listeners.push(listenerMethod)};orsoncharts.KeyedValuesDataset.prototype.removeListener=function(listenerMethod){var i=this.listeners.indexOf(listenerMethod);if(i>=0)this.listeners.splice(i,1)};orsoncharts.KeyedValuesDataset.prototype.notifyListeners=function(){};orsoncharts.KeyedValuesDataset.prototype.add=function(sectionKey,value){this.data.push([sectionKey,value])};
orsoncharts.KeyedValuesDataset.prototype.remove=function(sectionKey){if(!sectionKey)throw new Error("The 'sectionKey' must be defined.");var i=this.indexOf(sectionKey);if(i<0)throw new Error("The sectionKey '"+sectionKey.toString()+"' is not recognised.");this.data.splice(i,1)};orsoncharts.KeyedValuesDataset.prototype.dataFromJSON=function(jsonStr){this.data=JSON.parse(jsonStr);this.notifyListeners()};
orsoncharts.KeyedValuesDataset.prototype.removeByIndex=function(itemIndex){this.data.splice(itemIndex,1)};orsoncharts.KeyedValuesDataset.prototype.totalForDataset=function(dataset){var total=0;var itemCount=dataset.itemCount();for(var i=0;i<itemCount;i++){var v=dataset.valueByIndex(i);if(v)total=total+v}return total};
orsoncharts.KeyedValuesDataset.prototype.minForDataset=function(dataset){var min=null;var itemCount=dataset.itemCount();for(var i=0;i<itemCount;i++){var v=dataset.valueByIndex(i);if(v)if(min)min=Math.min(min,v);else min=v}return min};orsoncharts.KeyedValuesDataset.prototype.maxForDataset=function(dataset){var max=null;var itemCount=dataset.itemCount();for(var i=0;i<itemCount;i++){var v=dataset.valueByIndex(i);if(v)if(max)max=Math.max(max,v);else max=v}return max};
orsoncharts.KeyedValuesDataset.prototype.total=function(){return this.totalForDataset(this)};orsoncharts.KeyedValuesDataset.prototype.min=function(){return this.minForDataset(this)};orsoncharts.KeyedValuesDataset.prototype.max=function(){return this.maxForDataset(this)};if(!jfc)jfc={};jfc.KeyedValueLabels=function(){if(!(this instanceof orsoncharts.KeyedValueLabels))return new orsoncharts.KeyedValueLabels;this.format="{K} = {V}";this.valueDP=2;this.percentDP=2};
jfc.KeyedValueLabels.prototype.itemLabel=function(keyedValues,itemIndex){var labelStr=new String(this.format);var keyStr=keyedValues.key(itemIndex);var value=keyedValues.valueByIndex(itemIndex);var valueStr=value.toFixed(this.valueDP);var total=keyedValues.total();var percentStr=(value/total*100).toFixed(this.percentDP);labelStr=labelStr.replace(/{K}/g,keyStr);labelStr=labelStr.replace(/{V}/g,valueStr);labelStr=labelStr.replace(/{P}/g,percentStr);return labelStr};
