Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

amend author

  • Loading branch information...
commit 243ee8e4e1ec9799099c11a02139460c8d60d909 0 parents
@rflow rflow authored
11 .project
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>spending</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
2,493 data/cabinet_office_spend_data.csv
2,493 additions, 0 deletions not shown
110 index.html
@@ -0,0 +1,110 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
+ <title>Principle areas of Cabinet office spending 2010/2011</title>
+ <script type="text/javascript" src="js/jquery-1.7.js">
+ </script>
+ <script type="text/javascript" src="js/miso.ds.deps.js">
+ </script>
+ <script type="text/javascript" src="js/d3.v2.min.js">
+ </script>
+ <script src="js/main.js">
+ </script>
+ <style type="text/css">
+
+ html, body {
+ margin: 0;
+ padding: 0;
+ }
+
+ #container {
+ width: 980px;
+ height: 700px;
+ margin: auto;
+ }
+
+ #header {
+ width: 970px;
+ height: 25px;
+ font-size: 12px;
+ font-family: Arial;
+ border: solid 5px white;
+ padding-top: 5px;
+ }
+
+ #legend {
+ float: left;
+ font-size: 20px;
+ font-family: Georgia;
+ }
+
+ #daterange {
+ float: right;
+ display: none;
+ padding-left: 10px;
+ }
+
+ #grouping {
+ float: right;
+ display: none;
+ padding-left: 10px;
+ }
+
+ #chart {
+ width: 980px;
+ border: solid 5px white;
+ }
+
+ .cell {
+ color: white;
+ border: solid 1px white;
+ overflow: hidden;
+ position: absolute;
+ }
+
+ .selection {
+ z-index: 100;
+ }
+
+ .label {
+ font-family: sans-serif;
+ font-weight: bold;
+ margin: 5px;
+ }
+
+ .label .cost {
+ font-family: Georgia;
+ font-size: 1.5em;
+ font-weight: normal;
+ padding-bottom: 3px;
+ display: block;
+ width: 100%;
+ }
+ </style>
+ </head>
+ <body>
+ <div id=container>
+ <div id="header">
+ <div id="legend">
+ Loading spending data
+ </div>
+ <div id="daterange">
+ <label for="range">
+ in period:
+ </label>
+ <select name="id" id="range">
+ </select>
+ </div>
+ <div id="grouping">
+ <label for="groupby">
+ grouped by:
+ </label>
+ <select name="id" id="groupby">
+ </select>
+ </div>
+ </div>
+ <div id="chart"></div>
+ </div>
+ </body>
+</html>
4 js/d3.v2.min.js
4 additions, 0 deletions not shown
9,300 js/jquery-1.7.js
9,300 additions, 0 deletions not shown
309 js/main.js
@@ -0,0 +1,309 @@
+$(document).ready(function(){
+
+ // Define a helper for pre-processing numeric values -
+ // ensures empty cells are set to 0 and the rest are stripped of commas and turned to floats
+ var processNumericValues = function(v){
+ return (_.isUndefined(v) || _.isNull(v)) ? 0 : parseFloat(v.replace(/\,/g, ''));
+ }
+
+ // Define the columns in the underlying dataset
+ var columns = [
+ { name: "Description", type: "string" },
+ { name: "Supplier", type: "string" },
+ { name: "URL", type: "string" },
+ { name: "Entity", type: "string" },
+ { name: "Expense Type", type: "string" },
+ { name: "Transaction Number", type: "string" },
+ { name: "Amount", type: "number", before: processNumericValues },
+ { name: "Expense Area", type: "string" },
+ { name: "Date", type: "time", format: "DD/MM/YYYY" },
+ { name: "Departmental Family", type: "string" }];
+
+ // Define the underlying dataset for this interactive, a CSV file containing
+ // every item of Cabinet Office spending above £25k during the 2010/2011 period.
+ // (source = )
+ var data = new Miso.Dataset({
+ url: "data/cabinet_office_spend_data.csv",
+ delimiter: ",",
+ columns: columns
+ });
+
+ // Define the start of the period we're interested in - 01 April 2010
+ var startDate = moment("01-04-2010", "DD-MM-YYYY");
+
+ // Define the end of the period we're interested in - 31 March 2011
+ var finalDate = moment("31-03-2011", "DD-MM-YYYY");
+
+ // Define a way to refer to all records within range
+ var wholeRange = "2010 / 2011";
+
+ // Define a function for selecting all rows in the range between startDate and finalDate
+ var selectWholeRange = function(row){
+ return (row["Date"].valueOf() >= startDate.valueOf())
+ && (row["Date"].valueOf() <= finalDate.valueOf());
+ };
+
+ // Define an array in which to store all possible date ranges
+ var dateRanges = [wholeRange];
+
+ // Store the name of the currently selected month range
+ var currentRange = wholeRange;
+
+ // Define which columns the data can be grouped by:
+ // "Expense Type","Expense Area","Supplier"
+ var groupings = [columns[4], columns[7], columns[1]];
+
+ // Store the name of the column by which the data is currently grouped:
+ // n.b. this is initially set as "Expense Type"
+ var currentGrouping = columns[4].name;
+
+ // Define the maximum number of groups to be included in the chart at any time
+ var maxGroups = 20;
+
+ // Fetch the data, showing the initial version of the chart on success,
+ // or an error message if this process failed
+ data.fetch({
+ success: function(){
+ setupGrouping(groupings);
+ setupDateRanges(data);
+
+ showFilters();
+ showExpenses(wholeRange, currentGrouping, maxGroups);
+ },
+ error: function(){
+ setTitle("Failed to load data from " + data.url);
+ }
+ });
+
+ // Populate a dropdown box with a list of grouping options,
+ // then set up an event handler to update the chart whenever this changes value
+ function setupGrouping(columns) {
+ var options = "";
+
+ for(var i = 0; i < columns.length; i++){
+ options += '<option value="' + columns[i].name + '">' + columns[i].name + '</option>';
+ }
+
+ $("#groupby").html(options).change(function(){
+ currentGrouping = $(this).val();
+ showExpenses(currentRange, currentGrouping, maxGroups);
+ });
+ }
+
+ // Calculate all possible month ranges in the required period, add an extra column
+ // to the data containing appropriate grouping values and then populate the date
+ // range dropdown with all of the possible values
+ function setupDateRanges(data){
+ var month = moment(startDate);
+
+ while(month.valueOf() < finalDate.valueOf()){
+ dateRanges.push(month.format("MMM YYYY"));
+ month.add("months", 1);
+ }
+
+ var monthRangeValues = [];
+
+ data.each(function(row){
+ monthRangeValues.push(row["Date"].format("MMM YYYY"));
+ });
+
+ data.addColumn({ name: "Period", type: "String", data: monthRangeValues });
+
+ var options = "";
+
+ for(var i = 0; i < dateRanges.length; i++){
+ options += '<option value="' + dateRanges[i] + '">' + dateRanges[i] + '</option>';
+ }
+
+ $("#range").html(options).change(function(){
+ currentRange = $(this).val();
+ showExpenses(currentRange, currentGrouping, maxGroups);
+ });
+ }
+
+ // Reveal two dropdown boxes that can be used to filter the data being charted
+ function showFilters(){
+ $("#grouping").show();
+ $("#daterange").show();
+ }
+
+ // Select the appropriate range of rows for the date filter, group them
+ // according to the field specified and then chart the results using the
+ // treemap builder routine below
+ function showExpenses(range, grouping, maxGroups){
+
+ var chartTitle = "Principle areas of Cabinet Office spending";
+
+ var categoryKey = ["#CF3D1E", "#F15623", "#F68B1F", "#FFC60B", "#DFCE21", "#BCD631",
+ "#95C93D", "#48B85C", "#00833D", "#00B48D", "#60C4B1", "#27C4F4",
+ "#478DCB", "#3E67B1", "#4251A3", "#59449B", "#6E3F7C", "#6A246D",
+ "#8A4873", "#EB0080", "#EF58A0", "#C05A89"];
+
+ var rangeSelector = (range == wholeRange) ? selectWholeRange : function(row){ return (row["Period"] === range) };
+
+ var dataInRange = data.rows(rangeSelector);
+
+ var expenseData = { name: grouping, elements: [] };
+ var groupedData = dataInRange.groupBy(grouping, ["Amount"]);
+
+ groupedData.comparator = function(a,b){ return b["Amount"] - a["Amount"] };
+ groupedData.sort();
+
+ groupedData.each(function(row, index){
+ if (index >= maxGroups) return;
+ expenseData.elements.push({ name: row[grouping], total: row["Amount"], color: categoryKey[index%categoryKey.length] });
+ });
+
+ var calcCellSize = function(d){ return d.total; };
+ var calcCellLabel = function(d){
+ return "<span class='cost'>" + formatMoney("&pound;",d.value.toFixed(0),3,",") + "</span>" + toTitleCase(d.name);
+ };
+
+ var onHighlightCell = function(item){
+ setTitle(toTitleCase(item.name) + " - " + formatMoney("&pound;", item.value.toFixed(0), 3, ","));
+ };
+
+ var onRemoveHighlight = function(){
+ setTitle(chartTitle);
+ };
+
+ var onCellSelect = function(item, cell){
+ showTopItemsInGroup(grouping, item.name, 20);
+ };
+
+ $("#chart").empty();
+
+ buildTreemap(970, 600, "#chart", [expenseData], calcCellLabel, calcCellSize, onHighlightCell, onRemoveHighlight, onCellSelect);
+
+ hideGroup("#chart .cell");
+ setTitle(chartTitle);
+ showGroup("#chart .cell", 300, 10);
+ }
+
+ // Update the chart legend as required
+ function setTitle(text){
+ $("#legend").html(text);
+ }
+
+ // Build a treemap chart with the supplied data (using D3 to create, size, color and layout a series of DOM elements).
+ // Add labels to each cell, applying dynamic styling choices according to the space available.
+ // Bind custom handlers to cell highlighting and selection events.
+ function buildTreemap(width, height, element, data, calcCellLabel, calcCellSize, onHighlightCell, onRemoveHighlight, onCellSelect){
+
+ var layout = d3.layout.treemap()
+ .sort(function(a,b){ return a.value - b.value; })
+ .children(function(d){ return d.elements; })
+ .size([width, height])
+ .value(calcCellSize);
+
+ var formatChart = function(){
+ this.attr("class", "chart")
+ .style("position", "relative")
+ .style("width", width + "px")
+ .style("height", height + "px");
+ }
+
+ var formatCell = function(){
+ this.attr("class", "cell")
+ .style("left", function(d){ return d.x + "px"; })
+ .style("top", function(d){ return d.y + "px"; })
+ .style("width", function(d){ return d.dx - 1 + "px"; })
+ .style("height", function(d){ return d.dy - 1 + "px"; })
+ .style("background", function(d){ return d.color || "#FFF"; });
+ }
+
+ var formatLabel = function(){
+ this.attr("class", "label")
+ .style("font-size", function(d){ return d.area > 55000 ? "14px" : d.area > 20000 ? "12px" : d.area > 13000 ? "10px" : "0px"; })
+ .style("text-transform", function(d){ return d.area > 20000 ? "none" : "uppercase"; });
+ }
+
+ var chart = d3.select(element).append("div").call(formatChart);
+
+ var selected = null;
+ var handleSelection = function(d){
+ if (selected) { selected.toggleClass("selection") };
+ selected = $(this);
+ selected.toggleClass("selection");
+ onCellSelect(d, selected);
+ }
+
+ var handleMouseover = function(d){
+ onHighlightCell(d);
+ $(".cell").stop().fadeTo(300, 0.2);
+ $(this).stop().fadeTo(0, 1.0);
+ };
+
+ var handleMouseout = function(d){
+ $(".cell").stop().fadeTo("fast", 1.0);
+ onRemoveHighlight();
+ }
+
+ chart.data(data).selectAll("div")
+ .data(function(d){return layout.nodes(d);})
+ .enter()
+ .append("div")
+ .call(formatCell)
+ .on("click", handleSelection)
+ .on("mouseover", handleMouseover)
+ .on("mouseout", handleMouseout)
+ .append("p")
+ .call(formatLabel)
+ .html(calcCellLabel);
+ }
+
+ // Reveal a group of elements over the required number of milliseconds,
+ // staggering the fade of each one according to the required offset
+ function showGroup(elType, fadeTime, offset){
+ if (fadeTime) {
+ offset = offset || 0;
+ $(elType).each(function(index){
+ $(this).delay(offset*index).fadeIn(fadeTime);
+ });
+ } else {
+ $(elType).show();
+ }
+ }
+
+ // Hide a group of elements over the required number of milliseconds,
+ // staggering the fade of each one according to the required offset
+ function hideGroup(elType, fadeTime, offset){
+ if (fadeTime) {
+ offset = offset || 0;
+ $(elType).each(function(index){
+ $(this).delay(offset*index).fadeOut(fadeTime);
+ });
+ } else {
+ $(elType).hide();
+ }
+ }
+
+ // Return the string supplied with its first character converted to upper case
+ function toTitleCase(str) {
+ return str.charAt(0).toUpperCase() + str.substr(1);
+ }
+
+ // Format currency values for display using the required prefix and separator
+ function formatMoney(prefix, amount, segLength, separator) {
+ var money = amount.toString();
+
+ money = (money.length > segLength) ? segment(money, segLength, separator) : money;
+
+ return prefix + money;
+ }
+
+ // Segment a numeric value into chunks of the required length and
+ // return a string joining them together with the required separator
+ function segment(value, segLength, separator) {
+ var segments = [];
+ var segCount = Math.ceil(value.length / segLength);
+
+ for(var i = -segLength; segments.length < segCount-1; i -= segLength){
+ segments.unshift(value.substr(i,segLength));
+ }
+
+ segments.unshift(value.substr(0, value.length%segLength || segLength));
+
+ return segments.join(separator);
+ }
+});
5,304 js/miso.ds.deps.js
5,304 additions, 0 deletions not shown
22 test/chroma.min.js
@@ -0,0 +1,22 @@
+/**
+ chroma.js - a neat JS lib for color conversions
+ Copyright (C) 2011 Gregor Aisch
+
+ The JavaScript code in this page is free software: you can
+ redistribute it and/or modify it under the terms of the GNU
+ General Public License (GNU GPL) as published by the Free Software
+ Foundation, either version 3 of the License, or (at your option)
+ any later version. The code is distributed WITHOUT ANY WARRANTY;
+ without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
+
+ As additional permission under GNU GPL version 3 section 7, you
+ may distribute non-source (e.g., minimized or compacted) forms of
+ that code without the copy of the GNU GPL normally required by
+ section 4, provided you include this license notice and a URL
+ through which recipients can access the Corresponding Source.
+
+ @source: https://github.com/gka/chroma.js
+
+**/
+(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m=Object.prototype.hasOwnProperty,n=function(a,b){function d(){this.constructor=a}for(var c in b)m.call(b,c)&&(a[c]=b[c]);d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype;return a};h=typeof exports!="undefined"&&exports!==null?exports:this,g=(j=h.chroma)!=null?j:h.chroma={},typeof module!="undefined"&&module!==null&&(module.exports=g),g.version="0.3.0",c=function(){function a(b,c,d,e){var f,g;f=this,b==null&&c==null&&d==null&&e==null&&(b=[255,0,255]),i(b)==="array"&&b.length===3&&(e==null&&(e=c),g=b,b=g[0],c=g[1],d=g[2]),i(b)==="string"?e="hex":e==null&&(e="rgb"),e==="rgb"?f.rgb=[b,c,d]:e==="hsl"?f.rgb=a.hsl2rgb(b,c,d):e==="hsv"?f.rgb=a.hsv2rgb(b,c,d):e==="hex"?f.rgb=a.hex2rgb(b):e==="lab"?f.rgb=a.lab2rgb(b,c,d):e==="hcl"?f.rgb=a.hcl2rgb(b,c,d):e==="hsi"&&(f.rgb=a.hsi2rgb(b,c,d))}a.prototype.hex=function(){return a.rgb2hex(this.rgb)},a.prototype.toString=function(){return this.hex()},a.prototype.hsl=function(){return a.rgb2hsl(this.rgb)},a.prototype.hsv=function(){return a.rgb2hsv(this.rgb)},a.prototype.lab=function(){return a.rgb2lab(this.rgb)},a.prototype.hcl=function(){return a.rgb2hcl(this.rgb)},a.prototype.hsi=function(){return a.rgb2hsi(this.rgb)},a.prototype.interpolate=function(b,c,d){var e,f,g,h,j,k,l,m,n,o,p,q,r;m=this,d==null&&(d="rgb"),i(c)==="string"&&(c=new a(c));if(d==="hsl"||d==="hsv"||d==="hcl"||d==="hsi"){d==="hsl"?(q=m.hsl(),r=c.hsl()):d==="hsv"?(q=m.hsv(),r=c.hsv()):d==="hcl"?(q=m.hcl(),r=c.hcl()):d==="hsi"&&(q=m.hsi(),r=c.hsi()),g=q[0],o=q[1],k=q[2],h=r[0],p=r[1],l=r[2];if(!isNaN(g)&&!isNaN(h))h>g&&h-g>180?e=h-(g+360):h<g&&g-h>180?e=h+360-g:e=h-g,f=g+b*e;else if(!isNaN(g)){f=g;if(l===1||l===0)n=o}else if(!isNaN(h)){f=h;if(k===1||k===0)n=p}else f=void 0;n==null&&(n=o+b*(p-o)),j=k+b*(l-k);return new a(f,n,j,d)}if(d==="rgb"){q=m.rgb,r=c.rgb;return new a(q[0]+b*(r[0]-q[0]),q[1]+b*(r[1]-q[1]),q[2]+b*(r[2]-q[2]),d)}if(d==="lab"){q=m.lab(),r=c.lab();return new a(q[0]+b*(r[0]-q[0]),q[1]+b*(r[1]-q[1]),q[2]+b*(r[2]-q[2]),d)}throw"color mode "+d+" is not supported"};return a}(),c.hex2rgb=function(a){var b,c,d,e;if(!a.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/))if(g.colors!=null&&g.colors[a])a=g.colors[a];else throw"unknown color format: "+a;if(a.length===4||a.length===7)a=a.substr(1);a.length===3&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),e=parseInt(a,16),d=e>>16,c=e>>8&255,b=e&255;return[d,c,b]},c.rgb2hex=function(a,b,c){var d,e,f;a!==void 0&&a.length===3&&(f=a,a=f[0],b=f[1],c=f[2]),e=a<<16|b<<8|c,d="000000"+e.toString(16).toUpperCase();return"#"+d.substr(d.length-6)},c.hsv2rgb=function(a,b,c){var d,e,f,g,h,j,k,l,m,n,o,p,q,r,s,t;i(a)==="array"&&a.length===3&&(n=a,a=n[0],b=n[1],h=n[2]),c*=255;if(b===0&&isNaN(a))l=f=d=c;else{a===360&&(a=0),a>360&&(a-=360),a<0&&(a+=360),a/=60,g=Math.floor(a),e=a-g,j=c*(1-b),k=c*(1-b*e),m=c*(1-b*(1-e));switch(g){case 0:o=[c,m,j],l=o[0],f=o[1],d=o[2];break;case 1:p=[k,c,j],l=p[0],f=p[1],d=p[2];break;case 2:q=[j,c,m],l=q[0],f=q[1],d=q[2];break;case 3:r=[j,k,c],l=r[0],f=r[1],d=r[2];break;case 4:s=[m,j,c],l=s[0],f=s[1],d=s[2];break;case 5:t=[c,j,k],l=t[0],f=t[1],d=t[2]}}l=Math.round(l),f=Math.round(f),d=Math.round(d);return[l,f,d]},c.rgb2hsv=function(a,b,c){var d,e,f,g,h,i,j;a!==void 0&&a.length===3&&(j=a,a=j[0],b=j[1],c=j[2]),g=Math.min(a,b,c),f=Math.max(a,b,c),d=f-g,i=f/255,h=d/f,h===0?(e=void 0,h=0):(a===f&&(e=(b-c)/d),b===f&&(e=2+(c-a)/d),c===f&&(e=4+(a-b)/d),e*=60,e<0&&(e+=360));return[e,h,i]},c.hsl2rgb=function(a,b,c){var d,e,f,g,h,i,j,k,l,m;a!==void 0&&a.length===3&&(l=a,a=l[0],b=l[1],c=l[2]);if(b===0)h=f=d=c*255;else{k=[0,0,0],e=[0,0,0],j=c<.5?c*(1+b):c+b-c*b,i=2*c-j,a/=360,k[0]=a+1/3,k[1]=a,k[2]=a-1/3;for(g=0;g<=2;g++)k[g]<0&&(k[g]+=1),k[g]>1&&(k[g]-=1),6*k[g]<1?e[g]=i+(j-i)*6*k[g]:2*k[g]<1?e[g]=j:3*k[g]<2?e[g]=i+(j-i)*(2/3-k[g])*6:e[g]=i;m=[Math.round(e[0]*255),Math.round(e[1]*255),Math.round(e[2]*255)],h=m[0],f=m[1],d=m[2]}return[h,f,d]},c.rgb2hsl=function(a,b,c){var d,e,f,g,h,i;a!==void 0&&a.length===3&&(i=a,a=i[0],b=i[1],c=i[2]),a/=255,b/=255,c/=255,g=Math.min(a,b,c),f=Math.max(a,b,c),e=(f+g)/2,f===g?(h=0,d=void 0):h=e<.5?(f-g)/(f+g):(f-g)/(2-f-g),a===f?d=(b-c)/(f-g):b===f?d=2+(c-a)/(f-g):c===f&&(d=4+(a-b)/(f-g)),d*=60,d<0&&(d+=360);return[d,h,e]},c.lab2xyz=function(a,b,c){var d,e,f,g,h,j,k;i(a)==="array"&&a.length===3&&(k=a,a=k[0],b=k[1],c=k[2]),d=function(a){return a>6/29?a*a*a:3*(6/29)*(6/29)*(a-4/29)},f=(a+.16)/1.16,e=[.96421,1,.82519],h=e[1]*d(f),g=e[0]*d(f+b/5),j=e[2]*d(f-c/2);return[g,h,j]},c.xyz2rgb=function(a,b,c){var d,e,f,g,h,j,k,l,m,n;i(a)==="array"&&a.length===3&&(m=a,a=m[0],b=m[1],c=m[2]),l=3.2406*a-1.5372*b-.4986*c,j=-0.9689*a+1.8758*b+.0415*c,e=.0557*a-.204*b+1.057*c,f=Math.min(l,j,e)<-0.001||Math.max(l,j,e)>1.001,f&&(l=l<0?0:l>1?1:l,j=j<0?0:j>1?1:j,e=e<0?0:e>1?1:e),f&&(n=[void 0,void 0,void 0],l=n[0],j=n[1],e=n[2]),g=function(a){var b;b=.055;return a<=.0031308?12.92*a:(1+b)*Math.pow(a,1/2.4)-b},k=Math.round(255*g(l)),h=Math.round(255*g(j)),d=Math.round(255*g(e));return[k,h,d]},c.lab2rgb=function(a,b,d){var e,f,g,h,i,j;a!==void 0&&a.length===3&&(h=a,a=h[0],b=h[1],d=h[2]),a!==void 0&&a.length===3&&(i=a,a=i[0],b=i[1],d=i[2]),j=c.lab2xyz(a,b,d),e=j[0],f=j[1],g=j[2];return c.xyz2rgb(e,f,g)},c.hcl2lab=function(a,b,c){var d,e,f,g,h,j,k;i(a)==="array"&&a.length===3&&(k=a,a=k[0],b=k[1],c=k[2]),a/=360,e=6.283185307179586,d=c*.61+.09,g=e/6-a*e,j=(c*.311+.125)*b,f=Math.sin(g)*j,h=Math.cos(g)*j;return[d,f,h]},c.hcl2rgb=function(a,b,d){var e,f,g,h;h=c.hcl2lab(a,b,d),e=h[0],f=h[1],g=h[2];return c.lab2rgb(e,f,g)},c.rgb2xyz=function(a,b,c){var d,e,f,g,h,i,j,k;a!==void 0&&a.length===3&&(k=a,a=k[0],b=k[1],c=k[2]),e=function(a){var b;b=.055;return a<=.04045?a/12.92:Math.pow((a+b)/(1+b),2.4)},g=e(a/255),f=e(b/255),d=e(c/255),h=.4124*g+.3576*f+.1805*d,i=.2126*g+.7152*f+.0722*d,j=.0193*g+.1192*f+.9505*d;return[h,i,j]},c.xyz2lab=function(a,b,c){var d,e,f,g,h,i;a!==void 0&&a.length===3&&(i=a,a=i[0],b=i[1],c=i[2]),g=[.96421,1,.82519],f=function(a){return a>Math.pow(6/29,3)?Math.pow(a,1/3):7.787037037037035*a+4/29},h=1.16*f(b/g[1])-.16,d=5*(f(a/g[0])-f(b/g[1])),e=2*(f(b/g[1])-f(c/g[2]));return[h,d,e]},c.rgb2lab=function(a,b,d){var e,f,g,h,i;a!==void 0&&a.length===3&&(h=a,a=h[0],b=h[1],d=h[2]),i=c.rgb2xyz(a,b,d),e=i[0],f=i[1],g=i[2];return c.xyz2lab(e,f,g)},c.lab2hcl=function(a,b,c){var d,e,f,g,h,j,k;i(a)==="array"&&a.length===3&&(k=a,a=k[0],b=k[1],c=k[2]),d=a,a=(a-.09)/.61,h=Math.sqrt(b*b+c*c),j=h/(a*.311+.125),e=6.283185307179586,f=Math.atan2(b,c),g=(e/6-f)/e,g*=360,g<0&&(g+=360);return[g,j,a]},c.rgb2hcl=function(a,b,d){var e,f,g,h;i(a)==="array"&&a.length===3&&(g=a,a=g[0],b=g[1],d=g[2]),h=c.rgb2lab(a,b,d),f=h[0],e=h[1],d=h[2];return c.lab2hcl(f,e,d)},c.rgb2hsi=function(a,b,c){var d,e,f,g,h,j;i(a)==="array"&&a.length===3&&(j=a,a=j[0],b=j[1],c=j[2]),d=Math.PI*2,a/=255,b/=255,c/=255,g=Math.min(a,b,c),f=(a+b+c)/3,h=1-g/f,h===0?e=0:(e=(a-b+(a-c))/2,e/=Math.sqrt((a-b)*(a-b)+(a-c)*(b-c)),e=Math.acos(e),c>b&&(e=d-e),e/=d);return[e*360,h,f]},c.hsi2rgb=function(a,b,c){var d,e,f,g,h,j,k;i(a)==="array"&&a.length===3&&(k=a,a=k[0],b=k[1],c=k[2]),e=Math.PI*2,d=Math.PI/3,g=Math.cos,a<0&&(a+=360),a>360&&(a-=360),a/=360,a<1/3?(f=(1-b)/3,j=(1+b*g(e*a)/g(d-e*a))/3,h=1-(f+j)):a<2/3?(a-=1/3,j=(1-b)/3,h=(1+b*g(e*a)/g(d-e*a))/3,f=1-(j+h)):(a-=2/3,h=(1-b)/3,f=(1+b*g(e*a)/g(d-e*a))/3,j=1-(h+f)),j=c*j*3,h=c*h*3,f=c*f*3;return[j*255,h*255,f*255]},g.Color=c,g.hsl=function(a,b,d){return new c(a,b,d,"hsl")},g.hsv=function(a,b,d){return new c(a,b,d,"hsv")},g.rgb=function(a,b,d){return new c(a,b,d,"rgb")},g.hex=function(a){return new c(a)},g.lab=function(a,b,d){return new c(a,b,d,"lab")},g.hcl=function(a,b,d){return new c(a,b,d,"hcl")},g.hsi=function(a,b,d){return new c(a,b,d,"hsi")},g.interpolate=function(a,b,d,e){i(a)==="string"&&(a=new c(a)),i(b)==="string"&&(b=new c(b));return a.interpolate(d,b,e)},d=function(){function a(a){var b,d,e,f,g,h,j,k,l,m;f=this,f.colors=e=(g=a.colors)!=null?g:["#ddd","#222"];for(b=0,h=e.length-1;0<=h?b<=h:b>=h;0<=h?b++:b--)d=e[b],i(d)==="string"&&(e[b]=new c(d));if(a.positions!=null)f.pos=a.positions;else{f.pos=[];for(b=0,j=e.length-1;0<=j?b<=j:b>=j;0<=j?b++:b--)f.pos.push(b/(e.length-1))}f.mode=(k=a.mode)!=null?k:"hsv",f.nacol=(l=a.nacol)!=null?l:"#ccc",f.setClasses((m=a.limits)!=null?m:[0,1]),f}a.prototype.getColor=function(a){var b,c,d,e;e=this;if(isNaN(a))return e.nacol;e.classLimits.length>2?(b=e.getClass(a),c=b/(e.numClasses-1)):(c=d=(a-e.min)/(e.max-e.min),c=Math.min(1,Math.max(0,c)));return e.fColor(c)},a.prototype.fColor=function(a){var b,c,d,e,f,h;e=this,c=e.colors;for(d=0,h=e.pos.length-1;0<=h?d<=h:d>=h;0<=h?d++:d--){f=e.pos[d];if(a<=f){b=c[d];break}if(a>=f&&d===e.pos.length-1){b=c[d];break}if(a>f&&a<e.pos[d+1]){a=(a-f)/(e.pos[d+1]-f),b=g.interpolate(c[d],c[d+1],a,e.mode);break}}return b},a.prototype.classifyValue=function(a){var b,c,d,e,f,g;g=this,c=g.classLimits,c.length>2&&(f=c.length-1,b=g.getClass(a),a=c[b]+(c[b+1]-c[b])*.5,e=c[0],d=c[f-1],a=g.min+(a-e)/(d-e)*(g.max-g.min));return a},a.prototype.setClasses=function(a){var b;a==null&&(a=[]),b=this,b.classLimits=a,b.min=a[0],b.max=a[a.length-1];return a.length===2?b.numClasses=0:b.numClasses=a.length-1},a.prototype.getClass=function(a){var b,c,d,e;e=this,c=e.classLimits;if(c!=null){d=c.length-1,b=0;while(b<d&&a>=c[b])b++;return b-1}},a.prototype.validValue=function(a){return!isNaN(a)};return a}(),g.ColorScale=d,f=function(){function a(b,c,d){b==null&&(b="#fe0000"),c==null&&(c="#feeeee"),d==null&&(d="hsl"),a.__super__.constructor.call(this,[b,c],[0,1],d)}n(a,d);return a}(),g.Ramp=f,e=function(){function a(b,c,d,e,f){var g;b==null&&(b="#d73027"),c==null&&(c="#ffffbf"),d==null&&(d="#1E6189"),e==null&&(e="mean"),f==null&&(f="hsl"),g=this,g.mode=f,g.center=e,a.__super__.constructor.call(this,[b,c,d],[0,.5,1],f)}n(a,d),a.prototype.parseData=function(b,c){var d,e;a.__super__.parseData.call(this,b,c),e=this,d=e.center,d==="median"?d=e.median:d==="mean"&&(d=e.mean);return e.pos[1]=(d-e.min)/(e.max-e.min)};return a}(),g.Diverging=e,b=function(){function a(a){var b;b=this,b.colors=a}n(a,d),a.prototype.parseData=function(a,b){},a.prototype.getColor=function(a){var b;b=this;return b.colors.hasOwnProperty(a)?b.colors[a]:"#cccccc"},a.prototype.validValue=function(a){return this.colors.hasOwnProperty(a)};return a}(),g.Categories=b,a=function(){function a(a){var b;b=this,b.name=a,b.setClasses(7),b}n(a,d),a.prototype.getColor=function(a){var b,c;c=this,b=c.getClass(a);return c.name+" l"+c.numClasses+" c"+b};return a}(),g.CSSColors=a,(k=g.scales)==null&&(g.scales={}),g.scales.cool=function(){return new f(g.hsl(180,1,.9),g.hsl(250,.7,.4))},g.scales.hot=function(){return new d({colors:["#000000","#ff0000","#ffff00","#ffffff"],positions:[0,.25,.75,1],mode:"rgb"})},g.scales.BlWhOr=function(){return new e(g.hsl(30,1,.55),"#ffffff",new c(220,1,.55))},g.scales.GrWhPu=function(){return new e(g.hsl(120,.8,.4),"#ffffff",new c(280,.8,.4))},g.limits=function(a,b,c,d){var e,f,g,h,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z;b==null&&(b="equal"),c==null&&(c=7),d==null&&(d=null),r=Number.MAX_VALUE,q=Number.MAX_VALUE*-1,B=0,F=[];if(i(a)==="array")if(i(a[0])!=="object"&&i(a[0])!=="array")for(G=0,J=a.length;G<J;G++)D=a[G],isNaN(D)||F.push(Number(D));else for(H=0,K=a.length;H<K;H++)A=a[H],F.push(Number(A[d]));else if(i(a)==="object")for(n in a)D=a[n],i(D)==="object"&&i(d)==="string"?isNaN(D[d])||F.push(Number(D[d])):i(D)==="array"&&i(d)==="number"?isNaN(D[d])||F.push(Number(D[d])):i(D)==="number"&&(isNaN(D)||F.push(Number(D)));for(I=0,L=F.length;I<L;I++){D=F[I];if(!isNaN(D))D<r&&(r=D),D>q&&(q=D),B+=D;else continue}F=F.sort(function(a,b){return a-b}),p=[],b.substr(0,1)==="c"&&(p.push(r),p.push(q));if(b.substr(0,1)==="e"){p.push(r);for(l=1,T=c-1;1<=T?l<=T:l>=T;1<=T?l++:l--)p.push(r+l/c*(q-r));p.push(q)}else if(b.substr(0,1)==="q"){p.push(r);for(l=1,U=c-1;1<=U?l<=U:l>=U;1<=U?l++:l--)w=F.length*l/c,x=Math.floor(w),x===w?p.push(F[x]):(y=w-x,p.push(F[x]*y+F[x+1]*(1-y)));p.push(q)}else if(b.substr(0,1)==="k"){t=F.length,e=Array(t),j=Array(c),z=!0,u=0,g=null,g=[],g.push(r);for(l=1,V=c-1;1<=V?l<=V:l>=V;1<=V?l++:l--)g.push(r+l/c*(q-r));g.push(q);while(z){for(m=0,W=c-1;0<=W?m<=W:m>=W;0<=W?m++:m--)j[m]=0;for(l=0,X=t-1;0<=X?l<=X:l>=X;0<=X?l++:l--){E=F[l],s=Number.MAX_VALUE;for(m=0,Y=c-1;0<=Y?m<=Y:m>=Y;0<=Y?m++:m--)k=Math.abs(g[m]-E),k<s&&(s=k,f=m);j[f]++,e[l]=f}v=Array(c);for(m=0,Z=c-1;0<=Z?m<=Z:m>=Z;0<=Z?m++:m--)v[m]=null;for(l=0,M=t-1;0<=M?l<=M:l>=M;0<=M?l++:l--)h=e[l],v[h]===null?v[h]=F[l]:v[h]+=F[l];for(m=0,N=c-1;0<=N?m<=N:m>=N;0<=N?m++:m--)v[m]*=1/j[m];z=!1;for(m=0,O=c-1;0<=O?m<=O:m>=O;0<=O?m++:m--)if(v[m]!==g[l]){z=!0;break}g=v,u++,u>200&&(z=!1)}o={};for(m=0,P=c-1;0<=P?m<=P:m>=P;0<=P?m++:m--)o[m]=[];for(l=0,Q=t-1;0<=Q?l<=Q:l>=Q;0<=Q?l++:l--)h=e[l],o[h].push(F[l]);C=[];for(m=0,R=c-1;0<=R?m<=R:m>=R;0<=R?m++:m--)C.push(o[m][0]),C.push(o[m][o[m].length-1]);C=C.sort(function(a,b){return a-b}),p.push(C[0]);for(l=1,S=C.length-1;l<=S;l+=2)isNaN(C[l])||p.push(C[l])}return p},h=typeof exports!="undefined"&&exports!==null?exports:this,i=function(){var a,b,c,d,e;a={},e="Boolean Number String Function Array Date RegExp Undefined Null".split(" ");for(c=0,d=e.length;c<d;c++)b=e[c],a["[object "+b+"]"]=b.toLowerCase();return function(b){var c;c=Object.prototype.toString.call(b);return a[c]||"object"}}(),(l=h.type)==null&&(h.type=i),Array.max=function(a){return Math.max.apply(Math,a)},Array.min=function(a){return Math.min.apply(Math,a)}}).call(this)
126 test/hackday.js
@@ -0,0 +1,126 @@
+$(document).ready(function(){
+ var TARGET_COLOURS = {"facebook": "#3B5998", "twitter": "#4099FF", "other": "#4A7801" };
+ var wordcloud = new metaaps.nebulos(document.getElementById('word-cloud'));
+ var piedish = document.getElementById('pie-dish');
+ var raphael = Raphael(piedish, 300, 300);
+ var pie = {};
+
+ function getSegmentsFrom(totals, count){
+ var segments = [];
+
+ for (var target in totals) {
+ var total = totals[target];
+
+ if (total > 0) {
+ segments.push({
+ value: total / count,
+ fill: TARGET_COLOURS[target] || "#000",
+ stroke: "none"
+ });
+ }
+ }
+
+ return segments;
+ }
+
+ function makepie(totals){
+ var diameter = 280;
+ var radius = diameter / 2;
+ var center = { x:150, y:280 };
+ var segments = getSegmentsFrom(totals, 100);
+ var offset = 0;
+
+ pie.radius = radius;
+
+ if (pie.ingredients) {
+ pie.ingredients.remove();
+ pie.ingredients = null;
+ }
+
+ if (pie.chart) {
+ pie.chart.remove();
+ }
+
+ pie.ingredients = raphael.set();
+
+ pie.spot = raphael.circle(center.x, center.y, 3).attr({
+ stroke: 'none',
+ fill: '#444',
+ opacity: 1.0
+ });
+
+ pie.ingredients.push(pie.spot);
+
+ pie.chart = drawPieChart({
+ radius: radius,
+ segments: segments,
+ resolution: 0.1
+ }, raphael);
+
+ pie.chart.translate(center.x, center.y - radius - offset);
+
+ pie.circle = raphael.circle(center.x, center.y - radius - offset, radius / 2).attr({
+ stroke: 'none',
+ fill: '#fff',
+ opacity: 1.0
+ });
+
+ pie.count = raphael.text(center.x, center.y - radius - offset, "%").attr({
+ "font-family": "Arial",
+ "font-size": 48
+ });
+
+ pie.ingredients.push(pie.circle, pie.count);
+ }
+
+ function drawPieChart(p, r){
+ var TWO_PI = Math.PI * 2;
+ var pie = r.set();
+ var leng = p.segments.length;
+ var offsetAngle = 0;
+
+ for (var i = 0; i < leng; i++) {
+ var segData = p.segments[i];
+ var angle = TWO_PI * segData.value; // angle is percent of TWO_PI
+ var seg = drawSegment(p.radius, angle, offsetAngle, p.resolution || 0.1, r);
+
+ seg.attr({
+ stroke: segData.stroke,
+ fill: segData.fill
+ });
+
+ pie.push(seg);
+ offsetAngle += angle;
+ }
+
+ return pie;
+ }
+
+ function polarPath(radius, theta, rotation){
+ var x, y;
+ x = radius * Math.cos(theta + rotation);
+ y = radius * Math.sin(theta + rotation);
+ return "L " + x + " " + y + " ";
+ }
+
+ function drawSegment(radius, value, rotation, resolution, r){
+ var path = "M 0 0 ";
+
+ for (var i = 0; i < value; i += resolution) {
+ path += polarPath(radius, i, rotation);
+ }
+ path += polarPath(radius, value, rotation);
+
+ path += "L 0 0";
+
+ return r.path(path);
+ }
+
+ makepie({ "facebook": 30, "twitter":40, "other": 30 });
+
+ $('#test-form').submit(function() {
+ wordcloud.setFontFamily("Arial");
+ wordcloud.draw($('#test-text').val());
+ return false;
+ });
+});
276 test/main.longer.js
@@ -0,0 +1,276 @@
+Miso.types.number.coerce = function(v) { if (_.isNull(v)) { return null }; return _.isNaN(v) ? null : parseFloat((""+v).replace(/,/,'') ); }
+
+$(document).ready(function(){
+
+ var data = new Miso.Dataset({
+ url: "data/cabinet_office_spend_data.csv",
+ delimiter: ",",
+ columns: [
+ { name: "Description", type: "string" },
+ { name: "Supplier", type: "string" },
+ { name: "URL", type: "string" },
+ { name: "Entity", type: "string" },
+ { name: "Expense Type", type: "string" },
+ { name: "Transaction Number", type: "string" },
+ { name: "Amount", type: "number" },
+ { name: "Expense Area", type: "string" },
+ { name: "Date", type: "time", format: "DD/MM/YYYY" },
+ { name: "Departmental Family", type: "string" }
+ ]
+ });
+
+ data.fetch({
+ success: function(){
+ showGroupings(["Expense Type","Expense Area","Supplier"]);
+ showExpenses("Expense Type", 20);
+ },
+ error: function(){
+ setTitle("Failed to load data from " + data.url);
+ }
+ });
+
+ function showGroupings(columns) {
+ var options = "";
+
+ for(var i = 0; i < columns.length; i++){
+ options += '<option value="' + columns[i] + '">' + columns[i] + '</option>';
+ }
+
+ $("#groupby").html(options).change(function(){ showExpenses($(this).val(), 20); });
+ $("#grouping").fadeIn();
+ }
+
+ function showExpenses(grouping, maxGroups){
+
+ var categoryKey = ["#CF3D1E", "#F15623", "#F68B1F", "#FFC60B", "#DFCE21", "#BCD631",
+ "#95C93D", "#48B85C", "#00833D", "#00B48D", "#60C4B1", "#27C4F4",
+ "#478DCB", "#3E67B1", "#4251A3", "#59449B", "#6E3F7C", "#6A246D",
+ "#8A4873", "#EB0080", "#EF58A0", "#C05A89"];
+
+ var expenseData = { name: grouping, elements: [] };
+ var groupedData = data.groupBy(grouping, ["Amount"]);
+
+ groupedData.comparator = function(a,b){ return b["Amount"] - a["Amount"] };
+ groupedData.sort();
+
+ groupedData.each(function(row, index){
+ if (index >= maxGroups) return;
+ expenseData.elements.push({ name: row[grouping], total: row["Amount"], color: categoryKey[index%categoryKey.length] });
+ });
+
+ var calcCellSize = function(d){ return d.total; };
+ var calcCellLabel = function(d){
+ return "<span class='cost'>" + formatMoney("&pound;",d.value.toFixed(0),3,",") + "</span>" + toTitleCase(d.name);
+ };
+
+ var onCellSelect = function(item, cell){
+ showItemsInGroup(grouping, item, cell);
+ }
+
+ $("#treemap").empty();
+
+ drawTreemap(960, 600, "#treemap", [expenseData], calcCellLabel, calcCellSize, onCellSelect);
+
+ hideGroup("#treemap .cell");
+ setTitle("Principle areas of Cabinet Office spending 2010/2011");
+ showGroup("#treemap .cell", 300, 10);
+ }
+
+ function setTitle(text){
+ $("#legend").text(text);
+ }
+
+ function selectExpenseType(grouping, item, cell){
+
+ var chartData = [];
+ var expenseType = item.name.toLowerCase();
+ var expenseRows = data.rows( function(r){ return r["Expense Type"].toLowerCase() === expenseType; });
+
+ var labelColor = $(cell).css("background-color");
+
+ expenseRows.comparator = function(a,b){ return b["Amount"] - a["Amount"] };
+ expenseRows.sort();
+
+ expenseRows.each(function(row, index){
+ if (index > 20) return;
+ chartData.push({ index: index, date: row["Date"].format("DD MMM YY"), supplier: row["Supplier"], desc: row["Description"], value: row["Amount"] });
+ });
+
+ buildExpenseTable(960, 600, "#barchart", chartData, labelColor);
+
+ hideGroup("#barchart .row");
+ createModalPanel("#barchart");
+ showGroup("#barchart .row", 300, 75);
+ }
+
+ function drawTreemap(width, height, element, data, calcCellLabel, calcCellSize, onCellSelect){
+
+ var layout = d3.layout.treemap()
+ .sort(function(a,b){ return a.value - b.value; })
+ .children(function(d){ return d.elements; })
+ .size([width, height])
+ .value(calcCellSize);
+
+ var formatChart = function(){
+ this.attr("class", "chart")
+ .style("position", "relative")
+ .style("width", width + "px")
+ .style("height", height + "px");
+ }
+
+ var formatCell = function(){
+ this.attr("class", "cell")
+ .style("left", function(d){ return d.x + "px"; })
+ .style("top", function(d){ return d.y + "px"; })
+ .style("width", function(d){ return d.dx - 1 + "px"; })
+ .style("height", function(d){ return d.dy - 1 + "px"; })
+ .style("background", function(d){ return d.color || "#FFF"; });
+ }
+
+ var formatLabel = function(){
+ this.attr("class", "label")
+ .style("font-size", function(d){ return d.area > 55000 ? "14px" : d.area > 20000 ? "12px" : d.area > 13000 ? "10px" : "0px"; })
+ .style("text-transform", function(d){ return d.area > 20000 ? "none" : "uppercase"; });
+ }
+
+ var chart = d3.select(element).append("div").call(formatChart);
+
+ var selected = null;
+ var handleSelection = function(d){
+ if (selected) { selected.toggleClass("selection") };
+ selected = $(this);
+ selected.toggleClass("selection");
+ onCellSelect(d, selected);
+ }
+
+ chart.data(data).selectAll("div")
+ .data(function(d){return layout.nodes(d);})
+ .enter()
+ .append("div")
+ .call(formatCell)
+ .on("click", handleSelection)
+ .on("mouseover",function(d){ $(".cell").stop().fadeTo(300, 0.2); $(this).stop().fadeTo(0, 1.0); })
+ .on("mouseout",function(d){ $(".cell").stop().fadeTo("fast", 1.0); })
+ .append("p")
+ .call(formatLabel)
+ .html(calcCellLabel);
+ }
+
+ function buildExpenseTable(width, height, element, data, labelColor, calcNameLabel, calcValueLabel) {
+
+ var formatChart = function(){
+ this.attr("class", "chart")
+ .style("position", "relative")
+ .style("width", width + "px")
+ .style("height", height + "px");
+ }
+
+ var chart = d3.select(element).append("div").call(formatChart);
+ var scale = d3.scale.linear()
+ .domain([0, data[0].value])
+ .range(["0px", "300px"]);
+
+ var createDateCell = function(){
+ this.append("div")
+ .attr("class", "row-cell")
+ .style("width", "74px")
+ .html(function(d) { return d.date; });
+ };
+
+ var createDescriptionCell = function(){
+ this.append("div")
+ .attr("class", "row-cell")
+ .text(function(d) { return d.desc + " (" + d.date + ")"; });
+ };
+
+ var createValueCell = function(){
+ this.append("div")
+ .attr("class", "row-cell")
+ .style("width", "68px")
+ .style("text-align", "right")
+ .html(function(d) { return formatMoney("&pound;",d.value.toFixed(0),3,","); });
+ };
+
+ var createSupplierCell = function(){
+ this.append("div")
+ .attr("class", "bar")
+ .style("background-color", labelColor)
+ .call(createBarBackground)
+ .call(createBarLabel)
+ };
+
+ var createBarBackground = function(){
+ this.append("div")
+ .attr("class", "bar-background")
+ .style("width", function(d) { return scale(d.value); });
+ };
+
+ var createBarLabel = function(){
+ this.append("div")
+ .attr("class", "bar-label")
+ .text(function(d) { return d.supplier; });
+ };
+
+ chart.selectAll("div").data(data)
+ .enter()
+ .append("div")
+ .attr("class", "row")
+ .style("background-color", function(d) { return (d.index % 2) ? "#fff" : "#ececec"; })
+ .call(createValueCell)
+ .call(createSupplierCell)
+ .call(createDescriptionCell);
+ }
+
+ function createModalPanel(element){
+ $(element).fadeIn().click(function() {
+ $(this).fadeOut().empty().unbind('click');
+ });
+ }
+
+ function showGroup(elType, fadeTime, offset){
+ if (fadeTime) {
+ offset = offset || 0;
+ $(elType).each(function(index){
+ $(this).delay(offset*index).fadeIn(fadeTime);
+ });
+ } else {
+ $(elType).show();
+ }
+ }
+
+ function hideGroup(elType, fadeTime, offset){
+ if (fadeTime) {
+ offset = offset || 0;
+ $(elType).each(function(index){
+ $(this).delay(offset*index).fadeOut(fadeTime);
+ });
+ } else {
+ $(elType).hide();
+ }
+ }
+
+ function toTitleCase(str) {
+ return str.charAt(0).toUpperCase() + str.substr(1);
+ }
+
+ function formatMoney(currency, amount, segLength, separator) {
+ var money = amount.toString();
+
+ money = (money.length > segLength) ? segment(money, segLength, separator) : money;
+
+ return currency + money;
+ }
+
+ function segment(value, segLength, separator) {
+ var segments = [];
+ var segCount = Math.ceil(value.length / segLength);
+
+ for(var i = -segLength; segments.length < segCount-1; i -= segLength){
+ segments.unshift(value.substr(i,segLength));
+ }
+
+ segments.unshift(value.substr(0, value.length%segLength || segLength));
+
+ return segments.join(separator);
+ }
+});
7 test/miso.ds.deps.min.js
@@ -0,0 +1,7 @@
+/**
+* Miso.Dataset - v0.1.0 - 4/4/2012
+* http://github.com/misoproject/dataset
+* Copyright (c) 2012 Alex Graul, Irene Ros;
+* Dual Licensed: MIT, GPL
+*/
+(function(a,b){function q(a){this._d=a}function r(a,b){var c=a+"";while(c.length<b)c="0"+c;return c}function s(b,c,d,e){var f=typeof c=="string",g=f?{}:c,h,i,j,k;return f&&e&&(g[c]=+e),h=(g.ms||g.milliseconds||0)+(g.s||g.seconds||0)*1e3+(g.m||g.minutes||0)*6e4+(g.h||g.hours||0)*36e5,i=(g.d||g.days||0)+(g.w||g.weeks||0)*7,j=(g.M||g.months||0)+(g.y||g.years||0)*12,h&&b.setTime(+b+h*d),i&&b.setDate(b.getDate()+i*d),j&&(k=b.getDate(),b.setDate(1),b.setMonth(b.getMonth()+j*d),b.setDate(Math.min((new a(b.getFullYear(),b.getMonth()+1,0)).getDate(),k))),b}function t(a){return Object.prototype.toString.call(a)==="[object Array]"}function u(b){return new a(b[0],b[1]||0,b[2]||1,b[3]||0,b[4]||0,b[5]||0,b[6]||0)}function v(b,c){function t(c){var d,i;switch(c){case"M":return e+1;case"Mo":return e+1+p(e+1);case"MM":return r(e+1,2);case"MMM":return moment.monthsShort[e];case"MMMM":return moment.months[e];case"D":return f;case"Do":return f+p(f);case"DD":return r(f,2);case"DDD":return d=new a(g,e,f),i=new a(g,0,1),~~((d-i)/864e5+1.5);case"DDDo":return d=t("DDD"),d+p(d);case"DDDD":return r(t("DDD"),3);case"d":return h;case"do":return h+p(h);case"ddd":return moment.weekdaysShort[h];case"dddd":return moment.weekdays[h];case"w":return d=new a(g,e,f-h+5),i=new a(d.getFullYear(),0,4),~~((d-i)/864e5/7+1.5);case"wo":return d=t("w"),d+p(d);case"ww":return r(t("w"),2);case"YY":return r(g%100,2);case"YYYY":return g;case"a":return l>11?s.pm:s.am;case"A":return l>11?s.PM:s.AM;case"H":return l;case"HH":return r(l,2);case"h":return l%12||12;case"hh":return r(l%12||12,2);case"m":return m;case"mm":return r(m,2);case"s":return n;case"ss":return r(n,2);case"zz":case"z":return(b.toString().match(k)||[""])[0].replace(j,"");case"Z":return(o>0?"+":"-")+r(~~(Math.abs(o)/60),2)+":"+r(~~(Math.abs(o)%60),2);case"ZZ":return(o>0?"+":"-")+r(~~(10*Math.abs(o)/6),4);case"L":case"LL":case"LLL":case"LLLL":case"LT":return v(b,moment.longDateFormat[c]);default:return c.replace(/(^\[)|(\\)|\]$/g,"")}}var d=new q(b),e=d.month(),f=d.date(),g=d.year(),h=d.day(),l=d.hours(),m=d.minutes(),n=d.seconds(),o=-d.zone(),p=moment.ordinal,s=moment.meridiem;return c.replace(i,t)}function w(b,c){function o(a,b){var c;switch(a){case"M":case"MM":d[1]=~~b-1;break;case"MMM":case"MMMM":for(c=0;c<12;c++)if(moment.monthsParse[c].test(b)){d[1]=c;break}break;case"D":case"DD":case"DDD":case"DDDD":d[2]=~~b;break;case"YY":b=~~b,d[0]=b+(b>70?1900:2e3);break;case"YYYY":d[0]=~~Math.abs(b);break;case"a":case"A":k=b.toLowerCase()==="pm";break;case"H":case"HH":case"h":case"hh":d[3]=~~b;break;case"m":case"mm":d[4]=~~b;break;case"s":case"ss":d[5]=~~b;break;case"Z":case"ZZ":g=!0,c=(b||"").match(n),c&&c[1]&&(e=~~c[1]),c&&c[2]&&(f=~~c[2]),c&&c[0]==="+"&&(e=-e,f=-f)}}var d=[0,0,1,0,0,0,0],e=0,f=0,g=!1,h=b.match(m),i=c.match(l),j,k;for(j=0;j<i.length;j++)o(i[j],h[j]);return k&&d[3]<12&&(d[3]+=12),k===!1&&d[3]===12&&(d[3]=0),d[3]+=e,d[4]+=f,g?new a(a.UTC.apply({},d)):u(d)}function x(a,b){var c=Math.min(a.length,b.length),d=Math.abs(a.length-b.length),e=0,f;for(f=0;f<c;f++)~~a[f]!==~~b[f]&&e++;return e+d}function y(a,b){var c,d=a.match(m),e=[],f=99,g,h,i;for(g=0;g<b.length;g++)h=w(a,b[g]),i=x(d,v(h,b[g]).match(m)),i<f&&(f=i,c=h);return c}function z(a,b,c){var d=moment.relativeTime[a];return typeof d=="function"?d(b||1,!!c,a):d.replace(/%d/i,b||1)}function A(a,b){var d=c(Math.abs(a)/1e3),e=c(d/60),f=c(e/60),g=c(f/24),h=c(g/365),i=d<45&&["s",d]||e===1&&["m"]||e<45&&["mm",e]||f===1&&["h"]||f<22&&["hh",f]||g===1&&["d"]||g<=25&&["dd",g]||g<=45&&["M"]||g<345&&["MM",c(g/30)]||h===1&&["y"]||["yy",h];return i[2]=b,z.apply({},i)}function B(a,b){moment.fn[a]=function(a){return a!=null?(this._d["set"+b](a),this):this._d["get"+b]()}}var moment,c=Math.round,d={},e=typeof module!="undefined",f="months|monthsShort|monthsParse|weekdays|weekdaysShort|longDateFormat|calendar|relativeTime|ordinal|meridiem".split("|"),g,h=/^\/?Date\((\d+)/i,i=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|zz?|ZZ?|LT|LL?L?L?)/g,j=/[^A-Z]/g,k=/\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g,l=/(\\)?(MM?M?M?|dd?d?d|DD?D?D?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|ZZ?|T)/g,m=/(\\)?([0-9]+|([a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+|([\+\-]\d\d:?\d\d))/gi,n=/([\+\-]|\d\d)/gi,o="1.4.0",p="Month|Date|Hours|Minutes|Seconds|Milliseconds".split("|");moment=function(c,d){if(c===null)return null;var e,f;return c&&c._d instanceof a?e=new a(+c._d):d?t(d)?e=y(c,d):e=w(c,d):(f=h.exec(c),e=c===b?new a:f?new a(+f[1]):c instanceof a?c:t(c)?u(c):new a(c)),new q(e)},moment.version=o,moment.lang=function(a,b){var c,g,h,i=[];if(b){for(c=0;c<12;c++)i[c]=new RegExp("^"+b.months[c]+"|^"+b.monthsShort[c].replace(".",""),"i");b.monthsParse=b.monthsParse||i,d[a]=b}if(d[a])for(c=0;c<f.length;c++)g=f[c],moment[g]=d[a][g]||moment[g];else e&&(h=require("./lang/"+a),moment.lang(a,h))},moment.lang("en",{months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},meridiem:{AM:"AM",am:"am",PM:"PM",pm:"pm"},calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[last] dddd [at] LT",sameElse:"L"},relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},ordinal:function(a){var b=a%10;return~~(a%100/10)===1?"th":b===1?"st":b===2?"nd":b===3?"rd":"th"}}),moment.fn=q.prototype={clone:function(){return moment(this)},valueOf:function(){return+this._d},"native":function(){return this._d},toString:function(){return this._d.toString()},toDate:function(){return this._d},format:function(a){return v(this._d,a)},add:function(a,b){return this._d=s(this._d,a,1,b),this},subtract:function(a,b){return this._d=s(this._d,a,-1,b),this},diff:function(a,b,d){var e=moment(a),f=(this.zone()-e.zone())*6e4,g=this._d-e._d-f,h=this.year()-e.year(),i=this.month()-e.month(),j=this.date()-e.date(),k;return b==="months"?k=h*12+i+j/30:b==="years"?k=h+i/12:k=b==="seconds"?g/1e3:b==="minutes"?g/6e4:b==="hours"?g/36e5:b==="days"?g/864e5:b==="weeks"?g/6048e5:g,d?k:c(k)},from:function(a,b){var c=this.diff(a),d=moment.relativeTime,e=A(c,b);return b?e:(c<=0?d.past:d.future).replace(/%s/i,e)},fromNow:function(a){return this.from(moment(),a)},calendar:function(){var a=this.diff(moment().sod(),"days",!0),b=moment.calendar,c=b.sameElse,d=a<-6?c:a<-1?b.lastWeek:a<0?b.lastDay:a<1?b.sameDay:a<2?b.nextDay:a<7?b.nextWeek:c;return this.format(typeof d=="function"?d.apply(this):d)},isLeapYear:function(){var a=this.year();return a%4===0&&a%100!==0||a%400===0},isDST:function(){return this.zone()<moment([this.year()]).zone()||this.zone()<moment([this.year(),5]).zone()},day:function(a){var b=this._d.getDay();return a==null?b:this.add({d:a-b})},sod:function(){return this.clone().hours(0).minutes(0).seconds(0).milliseconds(0)},eod:function(){return this.sod().add({d:1,ms:-1})}};for(g=0;g<p.length;g++)B(p[g].toLowerCase(),p[g]);B("year","FullYear"),moment.fn.zone=function(){return this._d.getTimezoneOffset()},e&&(module.exports=moment),typeof window!="undefined"&&(window.moment=moment),typeof define=="function"&&define.amd&&define("moment",[],function(){return moment})})(Date),function(){function z(a,b,c){if(a===b)return a!==0||1/a==1/b;if(a==null||b==null)return a===b;a._chain&&(a=a._wrapped),b._chain&&(b=b._wrapped);if(a.isEqual&&_.isFunction(a.isEqual))return a.isEqual(b);if(b.isEqual&&_.isFunction(b.isEqual))return b.isEqual(a);var d=i.call(a);if(d!=i.call(b))return!1;switch(d){case"[object String]":return a==String(b);case"[object Number]":return a!=+a?b!=+b:a==0?1/a==1/b:a==+b;case"[object Date]":case"[object Boolean]":return+a==+b;case"[object RegExp]":return a.source==b.source&&a.global==b.global&&a.multiline==b.multiline&&a.ignoreCase==b.ignoreCase}if(typeof a!="object"||typeof b!="object")return!1;var e=c.length;while(e--)if(c[e]==a)return!0;c.push(a);var f=0,g=!0;if(d=="[object Array]"){f=a.length,g=f==b.length;if(g)while(f--)if(!(g=f in a==f in b&&z(a[f],b[f],c)))break}else{if("constructor"in a!="constructor"in b||a.constructor!=b.constructor)return!1;for(var h in a)if(_.has(a,h)){f++;if(!(g=_.has(b,h)&&z(a[h],b[h],c)))break}if(g){for(h in b)if(_.has(b,h)&&!(f--))break;g=!f}}return c.pop(),g}var a=this,b=a._,c={},d=Array.prototype,e=Object.prototype,f=Function.prototype,g=d.slice,h=d.unshift,i=e.toString,j=e.hasOwnProperty,k=d.forEach,l=d.map,m=d.reduce,n=d.reduceRight,o=d.filter,p=d.every,q=d.some,r=d.indexOf,s=d.lastIndexOf,t=Array.isArray,u=Object.keys,v=f.bind,_=function(a){return new D(a)};typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(exports=module.exports=_),exports._=_):a._=_,_.VERSION="1.3.1";var w=_.each=_.forEach=function(a,b,d){if(a==null)return;if(k&&a.forEach===k)a.forEach(b,d);else if(a.length===+a.length){for(var e=0,f=a.length;e<f;e++)if(e in a&&b.call(d,a[e],e,a)===c)return}else for(var g in a)if(_.has(a,g)&&b.call(d,a[g],g,a)===c)return};_.map=_.collect=function(a,b,c){var d=[];return a==null?d:l&&a.map===l?a.map(b,c):(w(a,function(a,e,f){d[d.length]=b.call(c,a,e,f)}),a.length===+a.length&&(d.length=a.length),d)},_.reduce=_.foldl=_.inject=function(a,b,c,d){var e=arguments.length>2;a==null&&(a=[]);if(m&&a.reduce===m)return d&&(b=_.bind(b,d)),e?a.reduce(b,c):a.reduce(b);w(a,function(a,f,g){e?c=b.call(d,c,a,f,g):(c=a,e=!0)});if(!e)throw new TypeError("Reduce of empty array with no initial value");return c},_.reduceRight=_.foldr=function(a,b,c,d){var e=arguments.length>2;a==null&&(a=[]);if(n&&a.reduceRight===n)return d&&(b=_.bind(b,d)),e?a.reduceRight(b,c):a.reduceRight(b);var f=_.toArray(a).reverse();return d&&!e&&(b=_.bind(b,d)),e?_.reduce(f,b,c,d):_.reduce(f,b)},_.find=_.detect=function(a,b,c){var d;return x(a,function(a,e,f){if(b.call(c,a,e,f))return d=a,!0}),d},_.filter=_.select=function(a,b,c){var d=[];return a==null?d:o&&a.filter===o?a.filter(b,c):(w(a,function(a,e,f){b.call(c,a,e,f)&&(d[d.length]=a)}),d)},_.reject=function(a,b,c){var d=[];return a==null?d:(w(a,function(a,e,f){b.call(c,a,e,f)||(d[d.length]=a)}),d)},_.every=_.all=function(a,b,d){var e=!0;return a==null?e:p&&a.every===p?a.every(b,d):(w(a,function(a,f,g){if(!(e=e&&b.call(d,a,f,g)))return c}),e)};var x=_.some=_.any=function(a,b,d){b||(b=_.identity);var e=!1;return a==null?e:q&&a.some===q?a.some(b,d):(w(a,function(a,f,g){if(e||(e=b.call(d,a,f,g)))return c}),!!e)};_.include=_.contains=function(a,b){var c=!1;return a==null?c:r&&a.indexOf===r?a.indexOf(b)!=-1:(c=x(a,function(a){return a===b}),c)},_.invoke=function(a,b){var c=g.call(arguments,2);return _.map(a,function(a){return(_.isFunction(b)?b||a:a[b]).apply(a,c)})},_.pluck=function(a,b){return _.map(a,function(a){return a[b]})},_.max=function(a,b,c){if(!b&&_.isArray(a))return Math.max.apply(Math,a);if(!b&&_.isEmpty(a))return-Infinity;var d={computed:-Infinity};return w(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;g>=d.computed&&(d={value:a,computed:g})}),d.value},_.min=function(a,b,c){if(!b&&_.isArray(a))return Math.min.apply(Math,a);if(!b&&_.isEmpty(a))return Infinity;var d={computed:Infinity};return w(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;g<d.computed&&(d={value:a,computed:g})}),d.value},_.shuffle=function(a){var b=[],c;return w(a,function(a,d,e){d==0?b[0]=a:(c=Math.floor(Math.random()*(d+1)),b[d]=b[c],b[c]=a)}),b},_.sortBy=function(a,b,c){return _.pluck(_.map(a,function(a,d,e){return{value:a,criteria:b.call(c,a,d,e)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c<d?-1:c>d?1:0}),"value")},_.groupBy=function(a,b){var c={},d=_.isFunction(b)?b:function(a){return a[b]};return w(a,function(a,b){var e=d(a,b);(c[e]||(c[e]=[])).push(a)}),c},_.sortedIndex=function(a,b,c){c||(c=_.identity);var d=0,e=a.length;while(d<e){var f=d+e>>1;c(a[f])<c(b)?d=f+1:e=f}return d},_.toArray=function(a){return a?a.toArray?a.toArray():_.isArray(a)?g.call(a):_.isArguments(a)?g.call(a):_.values(a):[]},_.size=function(a){return _.toArray(a).length},_.first=_.head=function(a,b,c){return b!=null&&!c?g.call(a,0,b):a[0]},_.initial=function(a,b,c){return g.call(a,0,a.length-(b==null||c?1:b))},_.last=function(a,b,c){return b!=null&&!c?g.call(a,Math.max(a.length-b,0)):a[a.length-1]},_.rest=_.tail=function(a,b,c){return g.call(a,b==null||c?1:b)},_.compact=function(a){return _.filter(a,function(a){return!!a})},_.flatten=function(a,b){return _.reduce(a,function(a,c){return _.isArray(c)?a.concat(b?c:_.flatten(c)):(a[a.length]=c,a)},[])},_.without=function(a){return _.difference(a,g.call(arguments,1))},_.uniq=_.unique=function(a,b,c){var d=c?_.map(a,c):a,e=[];return _.reduce(d,function(c,d,f){if(0==f||(b===!0?_.last(c)!=d:!_.include(c,d)))c[c.length]=d,e[e.length]=a[f];return c},[]),e},_.union=function(){return _.uniq(_.flatten(arguments,!0))},_.intersection=_.intersect=function(a){var b=g.call(arguments,1);return _.filter(_.uniq(a),function(a){return _.every(b,function(b){return _.indexOf(b,a)>=0})})},_.difference=function(a){var b=_.flatten(g.call(arguments,1));return _.filter(a,function(a){return!_.include(b,a)})},_.zip=function(){var a=g.call(arguments),b=_.max(_.pluck(a,"length")),c=new Array(b);for(var d=0;d<b;d++)c[d]=_.pluck(a,""+d);return c},_.indexOf=function(a,b,c){if(a==null)return-1;var d,e;if(c)return d=_.sortedIndex(a,b),a[d]===b?d:-1;if(r&&a.indexOf===r)return a.indexOf(b);for(d=0,e=a.length;d<e;d++)if(d in a&&a[d]===b)return d;return-1},_.lastIndexOf=function(a,b){if(a==null)return-1;if(s&&a.lastIndexOf===s)return a.lastIndexOf(b);var c=a.length;while(c--)if(c in a&&a[c]===b)return c;return-1},_.range=function(a,b,c){arguments.length<=1&&(b=a||0,a=0),c=arguments[2]||1;var d=Math.max(Math.ceil((b-a)/c),0),e=0,f=new Array(d);while(e<d)f[e++]=a,a+=c;return f};var y=function(){};_.bind=function(a,b){var c,d;if(a.bind===v&&v)return v.apply(a,g.call(arguments,1));if(!_.isFunction(a))throw new TypeError;return d=g.call(arguments,2),c=function(){if(this instanceof c){y.prototype=a.prototype;var e=new y,f=a.apply(e,d.concat(g.call(arguments)));return Object(f)===f?f:e}return a.apply(b,d.concat(g.call(arguments)))}},_.bindAll=function(a){var b=g.call(arguments,1);return b.length==0&&(b=_.functions(a)),w(b,function(b){a[b]=_.bind(a[b],a)}),a},_.memoize=function(a,b){var c={};return b||(b=_.identity),function(){var d=b.apply(this,arguments);return _.has(c,d)?c[d]:c[d]=a.apply(this,arguments)}},_.delay=function(a,b){var c=g.call(arguments,2);return setTimeout(function(){return a.apply(a,c)},b)},_.defer=function(a){return _.delay.apply(_,[a,1].concat(g.call(arguments,1)))},_.throttle=function(a,b){var c,d,e,f,g,h=_.debounce(function(){g=f=!1},b);return function(){c=this,d=arguments;var i=function(){e=null,g&&a.apply(c,d),h()};e||(e=setTimeout(i,b)),f?g=!0:a.apply(c,d),h(),f=!0}},_.debounce=function(a,b){var c;return function(){var d=this,e=arguments,f=function(){c=null,a.apply(d,e)};clearTimeout(c),c=setTimeout(f,b)}},_.once=function(a){var b=!1,c;return function(){return b?c:(b=!0,c=a.apply(this,arguments))}},_.wrap=function(a,b){return function(){var c=[a].concat(g.call(arguments,0));return b.apply(this,c)}},_.compose=function(){var a=arguments;return function(){var b=arguments;for(var c=a.length-1;c>=0;c--)b=[a[c].apply(this,b)];return b[0]}},_.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}},_.keys=u||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[];for(var c in a)_.has(a,c)&&(b[b.length]=c);return b},_.values=function(a){return _.map(a,_.identity)},_.functions=_.methods=function(a){var b=[];for(var c in a)_.isFunction(a[c])&&b.push(c);return b.sort()},_.extend=function(a){return w(g.call(arguments,1),function(b){for(var c in b)a[c]=b[c]}),a},_.defaults=function(a){return w(g.call(arguments,1),function(b){for(var c in b)a[c]==null&&(a[c]=b[c])}),a},_.clone=function(a){return _.isObject(a)?_.isArray(a)?a.slice():_.extend({},a):a},_.tap=function(a,b){return b(a),a},_.isEqual=function(a,b){return z(a,b,[])},_.isEmpty=function(a){if(_.isArray(a)||_.isString(a))return a.length===0;for(var b in a)if(_.has(a,b))return!1;return!0},_.isElement=function(a){return!!a&&a.nodeType==1},_.isArray=t||function(a){return i.call(a)=="[object Array]"},_.isObject=function(a){return a===Object(a)},_.isArguments=function(a){return i.call(a)=="[object Arguments]"},_.isArguments(arguments)||(_.isArguments=function(a){return!!a&&!!_.has(a,"callee")}),_.isFunction=function(a){return i.call(a)=="[object Function]"},_.isString=function(a){return i.call(a)=="[object String]"},_.isNumber=function(a){return i.call(a)=="[object Number]"},_.isNaN=function(a){return a!==a},_.isBoolean=function(a){return a===!0||a===!1||i.call(a)=="[object Boolean]"},_.isDate=function(a){return i.call(a)=="[object Date]"},_.isRegExp=function(a){return i.call(a)=="[object RegExp]"},_.isNull=function(a){return a===null},_.isUndefined=function(a){return a===void 0},_.has=function(a,b){return j.call(a,b)},_.noConflict=function(){return a._=b,this},_.identity=function(a){return a},_.times=function(a,b,c){for(var d=0;d<a;d++)b.call(c,d)},_.escape=function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")},_.mixin=function(a){w(_.functions(a),function(b){F(b,_[b]=a[b])})};var A=0;_.uniqueId=function(a){var b=A++;return a?a+b:b},_.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var B=/.^/,C=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};_.template=function(a,b){var c=_.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(c.escape||B,function(a,b){return"',_.escape("+C(b)+"),'"}).replace(c.interpolate||B,function(a,b){return"',"+C(b)+",'"}).replace(c.evaluate||B,function(a,b){return"');"+C(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return b?e(b,_):function(a){return e.call(this,a,_)}},_.chain=function(a){return _(a).chain()};var D=function(a){this._wrapped=a};_.prototype=D.prototype;var E=function(a,b){return b?_(a).chain():a},F=function(a,b){D.prototype[a]=function(){var a=g.call(arguments);return h.call(a,this._wrapped),E(b.apply(_,a),this._chain)}};_.mixin(_),w(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=d[a];D.prototype[a]=function(){var c=this._wrapped;b.apply(c,arguments);var d=c.length;return(a=="shift"||a=="splice")&&d===0&&delete c[0],E(c,this._chain)}}),w(["concat","join","slice"],function(a){var b=d[a];D.prototype[a]=function(){return E(b.apply(this._wrapped,arguments),this._chain)}}),D.prototype.chain=function(){return this._chain=!0,this},D.prototype.value=function(){return this._wrapped}}.call(this),function(){var a=this.math={};a.mean=a.ave=a.average=function(b,c){return a.sum(b,c)/_(b).size()},a.median=function(b){var c=(b.length+1)/2,d=a.sort(b);return d.length%2?d[c-1]:(d[c-1.5]+d[c-.5])/2},a.pow=function(a,b){if(_.isNumber(a))return Math.pow(a,b);if(_.isArray(a))return _.map(a,function(a){return _.pow(a,b)})},a.scale=function(a,b){var b=b||1,c=_.max(a);return _.map(a,function(a){return a*(b/c)})},a.slope=function(a,b){return(b[1]-a[1])/(b[0]-a[0])},a.sort=function(a){return a.sort(function(a,b){return a-b})},a.stdDeviation=a.sigma=function(a){return Math.sqrt(_(a).variance())},a.sum=function(a,b){if(_.isArray(a)&&typeof a[0]=="number")var c=a;else var b=b||"value",c=_(a).pluck(b);var d=0;for(var e=0,f=c.length;e<f;e++)d+=c[e];return d},a.transpose=function(a){var b=[];return _(a).each(function(a,c){_(a).each(function(a,d){b[d]||(b[d]=[]),b[d][c]=a})}),b},a.variance=function(a){var b=_(a).mean();return _(a).chain().map(function(a){return _(a-b).pow(2)}).mean().value()},_.mixin(a)}(),function(a){function q(a){var b=p[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c<d;c++)b[a[c]]=!0;return b}var b={},c=Array.prototype,d=Object.prototype,e=d.hasOwnProperty,f=d.toString,g=c.forEach,h=c.slice,i=function(a,c,d){var f,h,i;if(!a)return;if(g&&a.forEach===g)a.forEach(c,d);else if(a.length===+a.length){for(h=0,i=a.length;h<i;h++)if(h in a&&c.call(d,a[h],h,a)===b)return}else for(f in a)if(e.call(a,f)&&c.call(d,a[f],f,a)===b)return},j=function(a){return!!(a&&a.constructor&&a.call&&a.apply)},k=function(a){return i(h.call(arguments,1),function(b){var c;for(c in b)b[c]!==void 0&&(a[c]=b[c])}),a},l={"[object Array]":"array","[object Function]":"function"},m=function(a){return a?l[f.call(a)]||"object":String(a)},n="done fail isResolved isRejected promise then always pipe".split(" "),o={},p={};o.Callbacks=function(a){a=a?p[a]||q(a):{};var b=[],c=[],d,e,f,g,h,i=function(c){var d,e,f,g,h;for(d=0,e=c.length;d<e;d++)f=c[d],g=m(f),g==="array"?i(f):g==="function"&&(!a.unique||!k.has(f))&&b.push(f)},j=function(i,j){j=j||[],d=!a.memory||[i,j],e=!0,h=f||0,f=0,g=b.length;for(;b&&h<g;h++)if(b[h].apply(i,j)===!1&&a.stopOnFalse){d=!0;break}e=!1,b&&(a.once?d===!0?k.disable():b=[]:c&&c.length&&(d=c.shift(),k.fireWith(d[0],d[1])))},k={add:function(){if(b){var a=b.length;i(arguments),e?g=b.length:d&&d!==!0&&(f=a,j(d[0],d[1]))}return this},remove:function(){if(b){var c=arguments,d=0,f=c.length;for(;d<f;d++)for(var i=0;i<b.length;i++)if(c[d]===b[i]){e&&i<=g&&(g--,i<=h&&h--),b.splice(i--,1);if(a.unique)break}}return this},has:function(a){if(b){var c=0,d=b.length;for(;c<d;c++)if(a===b[c])return!0}return!1},empty:function(){return b=[],this},disable:function(){return b=c=d=undefined,this},disabled:function(){return!b},lock:function(){return c=undefined,(!d||d===!0)&&k.disable(),this},locked:function(){return!c},fireWith:function(b,f){return c&&(e?a.once||c.push([b,f]):(!a.once||!d)&&j(b,f)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},o.Deferred=function(a){var b=o.Callbacks("once memory"),c=o.Callbacks("once memory"),d=o.Callbacks("memory"),e="pending",f={resolve:b,reject:c,notify:d},g={done:b.add,fail:c.add,progress:d.add,state:function(){return e},isResolved:b.fired,isRejected:c.fired,then:function(a,b,c){return h.done(a).fail(b).progress(c),this},always:function(){return h.done.apply(h,arguments).fail.apply(h,arguments),this},pipe:function(a,b,c){return o.Deferred(function(d){i({done:[a,"resolve"],fail:[b,"reject"],progress:[c,"notify"]},function(a,b){var c=a[0],e=a[1],f;j(c)?h[b](function(){f=c.apply(this,arguments),f&&j(f.promise)?f.promise().then(d.resolve,d.reject,d.notify):d[e+"With"](this===h?d:this,[f])}):h[b](d[e])})}).promise()},promise:function(a){if(!a)a=g;else for(var b in g)a[b]=g[b];return a}},h=g.promise({}),k;for(k in f)h[k]=f[k].fire,h[k+"With"]=f[k].fireWith;return h.done(function(){e="resolved"},c.disable,d.lock).fail(function(){e="rejected"},b.disable,d.lock),a&&a.call(h,h),h},o.when=function(a){function l(a){return function(c){b[a]=arguments.length>1?h.call(arguments,0):c,--f||i.resolveWith(i,b)}}function m(a){return function(b){e[a]=arguments.length>1?h.call(arguments,0):b,i.notifyWith(k,e)}}var b=h.call(arguments,0),c=0,d=b.length,e=new Array(d),f=d,g=d,i=d<=1&&a&&j(a.promise)?a:o.Deferred(),k=i.promise();if(d>1){for(;c<d;c++)b[c]&&b[c].promise&&j(b[c].promise)?b[c].promise().then(l(c),i.reject,m(c)):--f;f||i.resolveWith(i,b)}else i!==a&&i.resolveWith(i,d?[a]:[]);return k},typeof module!="undefined"&&module.exports?module.exports=o:typeof a._!="undefined"?a._.mixin(o):a._=o}(this),function(a,_){var b=a.Miso={};b.typeOf=function(a,c){var d=_.keys(b.types),e;return d.push(d.splice(_.indexOf(d,"string"),1)[0]),d.push(d.splice(_.indexOf(d,"mixed"),1)[0]),e=_.find(d,function(d){return b.types[d].test(a,c)}),e=_.isUndefined(e)?"string":e,e},b.types={mixed:{name:"mixed",coerce:function(a){return a},test:function(a){return!0},compare:function(a,b){return a<b?-1:a>b?1:0},numeric:function(a){return _.isNaN(Number(a))?0:Number(a)}},string:{name:"string",coerce:function(a){return _.isNull(a)?null:a.toString()},test:function(a){return a===null||typeof a=="undefined"||typeof a=="string"},compare:function(a,b){return a<b?-1:a>b?1:0},numeric:function(a,b){return b}},"boolean":{name:"boolean",regexp:/^(true|false)$/,coerce:function(a){return a==="false"?!1:Boolean(a)},test:function(a){return a===null||typeof a=="undefined"||typeof a=="boolean"||this.regexp.test(a)?!0:!1},compare:function(a,b){return a===b?0:a<b?-1:1},numeric:function(a){return a?1:0}},number:{name:"number",regexp:/^[\-\.]?[0-9]+([\.][0-9]+)?$/,coerce:function(a){return _.isNull(a)?null:_.isNaN(a)?null:+a},test:function(a){return a===null||typeof a=="undefined"||typeof a=="number"||this.regexp.test(a)?!0:!1},compare:function(a,b){return a===b?0:a<b?-1:1},numeric:function(a){return a}},time:{name:"time",format:"DD/MM/YYYY",_formatLookup:[["DD","\\d{2}"],["D","\\d{1}|\\d{2}"],["MM","\\d{2}"],["M","\\d{1}|\\d{2}"],["YYYY","\\d{4}"],["YY","\\d{2}"],["A","[AM|PM]"],["hh","\\d{2}"],["h","\\d{1}|\\d{2}"],["mm","\\d{2}"],["m","\\d{1}|\\d{2}"],["ss","\\d{2}"],["s","\\d{1}|\\d{2}"],["ZZ","[-|+]\\d{4}"],["Z","[-|+]\\d{2}:\\d{2}"]],_regexpTable:{},_regexp:function(a){if(this._regexpTable[a])return new RegExp(this._regexpTable[a],"g");var b=a;return _.each(this._formatLookup,function(a){b=b.replace(a[0],a[1])},this),b=b.split("/").join("\\/"),this._regexpTable[a]=b,new RegExp(this._regexpTable[a],"g")},coerce:function(a,b){b=b||{};if(_.isString(a)){var c=b.format||this.format;return moment(a,b.format)}return _.isNumber(a)?moment(a):a},test:function(a,b){b=b||{};if(a===null||typeof a=="undefined")return!0;if(_.isString(a)){var c=b.format||this.format,d=this._regexp(c);return d.test(a)}return!0},compare:function(a,b){return a<b?-1:a>b?1:0},numeric:function(a){return a.valueOf()}}}}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Event=function(a){_.isArray(a)||(a=[a]),this.deltas=a},_.extend(b.Event.prototype,{affectedColumns:function(){var a=[];return _.each(this.deltas,function(b){a=_.union(a,_.keys(b.old),_.keys(b.changed))}),a}}),_.extend(b.Event,{isRemove:function(a){return _.isUndefined(a.changed)||_.keys(a.changed).length===0?!0:!1},isAdd:function(a){return _.isUndefined(a.old)||_.keys(a.old).length===0?!0:!1},isUpdate:function(a){return!this.isRemove(a)&&!this.isAdd(a)?!0:!1}}),b.Events={},b.Events.bind=function(a,b,c){var d=this._callbacks||(this._callbacks={}),e=d[a]||(d[a]={}),f=e.tail||(e.tail=e.next={});return f.callback=b,f.context=c,e.tail=f.next={},this},b.Events.unbind=function(a,b){var c,d,e;if(!a)this._callbacks=null;else if(c=this._callbacks)if(!b)c[a]={};else if(d=c[a])while((e=d)&&(d=d.next)){if(d.callback!==b)continue;e.next=d.next,d.context=d.callback=null;break}return this},b.Events.trigger=function(a){var b,c,d,e,f,g=["all",a];if(!(c=this._callbacks))return this;while(f=g.pop()){if(!(b=c[f]))continue;e=f==="all"?arguments:Array.prototype.slice.call(arguments,1);while(b=b.next)(d=b.callback)&&d.apply(b.context||this,e)}return this},b.Events._buildEvent=function(a){return new b.Event(a)}}(this,_),function(a,_){var b=a.Miso||{};b.Builder={detectColumnType:function(a,c){var d=_.inject(c.slice(0,5),function(a,c){var d=b.typeOf(c);return c!==""&&a.indexOf(d)===-1&&!_.isNull(c)&&a.push(d),a},[]);return d.length===1?a.type=d[0]:a.type="mixed",a},detectColumnTypes:function(a,c){_.each(c,function(c,d){var e=a.column(d);if(e.type){e.force=!0;return}b.Builder.detectColumnType(e,c)},this)},cacheRows:function(a){b.Builder.clearRowCache(a),_.each(a._columns[a._columnPositionByName._id].data,function(b,c){a._rowPositionById[b]=c,a._rowIdByPosition.push(b)},a);var c=_.uniq(_.map(a._columns,function(a){return a.data.length}));if(c.length>1)throw new Error("Row lengths need to be the same. Empty values should be set to null."+_.map(a._columns,function(a){return a.data+"|||"}));a.length=c[0]},clearRowCache:function(a){a._rowPositionById={},a._rowIdByPosition=[]},cacheColumns:function(a){a._columnPositionByName={},_.each(a._columns,function(b,c){a._columnPositionByName[b.name]=c})}},Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){for(var c=b||0,d=this.length;c<d;c++)if(this[c]===a)return c;return-1})}(this,_),function(a,_){var b=a.Miso;b.Column=function(a){return _.extend(this,a),this._id=a.id||_.uniqueId(),this.data=a.data||[],this},_.extend(b.Column.prototype,{toNumeric:function(a,c){return b.types[this.type].numeric(a,c)},numericAt:function(a){return this.toNumeric(this.data[a],a)},coerce:function(){this.data=_.map(this.data,function(a){return b.types[this.type].coerce(a,this)},this)},_sum:function(){return _.sum(this.data)},_mean:function(){var a=0;for(var c=0;c<this.data.length;c++)a+=this.numericAt(c);return a/=this.data.length,b.types[this.type].coerce(a,this)},_median:function(){return b.types[this.type].coerce(_.median(this.data),this)},_max:function(){var a=-Infinity;for(var c=0;c<this.data.length;c++)b.types[this.type].compare(this.data[c],a)>0&&(a=this.numericAt(c));return b.types[this.type].coerce(a,this)},_min:function(){var a=Infinity;for(var c=0;c<this.data.length;c++)b.types[this.type].compare(this.data[c],a)<0&&(a=this.numericAt(c));return b.types[this.type].coerce(a,this)}}),b.DataView=function(a){a=a||(a={});if(_.isUndefined(a.parent))throw new Error("A view must have a parent specified.");return this.parent=a.parent,this._initialize(a),this},_.extend(b.DataView.prototype,{_initialize:function(a){this.parent.syncable===!0&&(_.extend(this,b.Events),this.syncable=!0),this.filter={columns:this._columnFilter(a.filter.columns||undefined),rows:this._rowFilter(a.filter.rows||undefined)},this._columns=this._selectData(),b.Builder.cacheColumns(this),b.Builder.cacheRows(this),this.syncable&&this.parent.bind("change",this._sync,this)},_sync:function(a){var c=a.deltas,d=null;_.each(c,function(c,e){var f=this._rowPositionById[c._id];if(typeof f=="undefined"&&b.Event.isAdd(c))this.filter.rows&&this.filter.rows(c.changed)&&(this._add(c.changed),d="add");else{if(f==="undefined")return;_.each(c.changed,function(a,b){var c=this._columnPositionByName[b];if(_.isUndefined(c))return;this._columns[c].data[f]=a,d="update"},this)}var g=this.rowByPosition(f);if(b.Event.isRemove(c)||this.filter.row&&!this.filter.row(g)){var h={_id:c._id,old:this.rowByPosition(f),changed:{}};a.deltas.splice(e,1,h),this._remove(f),d="delete"}},this),this.syncable&&(this.trigger(d,a),this.trigger("change",a))},where:function(a,c){return c=c||{},c.parent=this,c.filter=a||{},new b.DataView(c)},_selectData:function(){var a=[];return _.each(this.parent._columns,function(c){this.filter.columns(c)&&a.push(new b.Column({name:c.name,data:[],type:c.type,_id:c._id}))},this),this.parent.each(function(b){if(!this.filter.rows(b))return;for(var c=0;c<a.length;c++)a[c].data.push(b[a[c].name])},this),a},_columnFilter:function(a){var b;return _.isUndefined(a)?b=function(){return!0}:(a.push("_id"),b=function(b){return _.indexOf(a,b.name)===-1?!1:!0}),b},_rowFilter:function(a){var b;return _.isNumber(a)&&(a=[a]),_.isUndefined(a)?b=function(){return!0}:_.isFunction(a)?b=a:b=function(b){return _.indexOf(a,b._id)===-1?!1:!0},b},column:function(a){return this._column(a)},_column:function(a){if(_.isUndefined(this._columnPositionByName))return undefined;var b=this._columnPositionByName[a];return this._columns[b]},columns:function(a){return new b.DataView({filter:{columns:a},parent:this})},columnNames:function(){var a=_.pluck(this._columns,"name");return _.reject(a,function(a){return a==="_id"||a==="_oids"})},hasColumn:function(a){return!_.isUndefined(this._columnPositionByName[a])},each:function(a,b){for(var c=0;c<this.length;c++)a.apply(b||this,[this.rowByPosition(c),c])},eachColumn:function(a,b){var c=this.columnNames();for(var d=0;d<c.length;d++)a.apply(b||this,[c[d],this.column(c[d]),d])},rowByPosition:function(a){return this._row(a)},rowById:function(a){return this._row(this._rowPositionById[a])},_row:function(a){var b={};return _.each(this._columns,function(c){b[c.name]=c.data[a]}),b},_remove:function(a){var b=this._rowPositionById[a];return _.each(this._columns,function(a){a.data.splice(b,1)}),delete this._rowPositionById[a],this._rowIdByPosition.splice(b,1),this.length--,this},_add:function(a,c){_.each(a,function(c,d){var e=this.column(d);if(typeof e!="undefined"){var f=b.types[e.type];if(e.force||f.test(a[e.name],e))a[e.name]=f.coerce(a[e.name],e);else throw"incorrect value '"+a[e.name]+"' of type "+b.typeOf(a[e.name],e)+" passed to column with type "+e.type}},this);if(_.isUndefined(this.comparator))_.each(this._columns,function(b){b.data.push(!_.isUndefined(a[b.name])&&!_.isNull(a[b.name])?a[b.name]:null)}),this.length++,this._rowIdByPosition=this._rowIdByPosition||(this._rowIdByPosition=[]),this._rowPositionById=this._rowPositionById||(this._rowPositionById={}),this._rowIdByPosition.push(a._id),this._rowPositionById[a._id]=this._rowIdByPosition.length;else{var d=function(a,b,c){Array.prototype.splice.apply(c,[a,0].concat(b))},e;this.length++;for(e=0;e<this.length;e++){var f=this.rowByPosition(e);if(_.isUndefined(f._id)||this.comparator(a,f)<0){_.each(this._columns,function(b){d(e,a[b.name]?a[b.name]:null,b.data)});break}}this._rowIdByPosition=[],this._rowPositionById={},this.each(function(a,b){this._rowIdByPosition.push(a._id),this._rowPositionById[a._id]=b})}return this},rows:function(a){return new b.DataView({filter:{rows:a},parent:this})},sort:function(a){a=a||{};if(_.isUndefined(this.comparator))throw new Error("Cannot sort without this.comparator.");var b=this.length,c;if(b===1)return;var d=_.bind(function(a,b){var c=this.rowByPosition(b);_.each(c,function(c,d){var e=this._columnPositionByName[d],f=this._columns[e].data[a];this._columns[e].data.splice(a,1,c),this._columns[e].data.splice(b,1,f)},this)},this),e=_.bind(function(a,b){var c=a,e;while(c*2<=b){e=c*2;var f=this.rowByPosition(c);e+1<b&&this.comparator(this.rowByPosition(e),this.rowByPosition(e+1))<0&&e++;if(this.comparator(f,this.rowByPosition(e))<0)d(c,e),c=e;else return}},this),f=function(a){var b=Math.round((a-2)/2);while(b>=0)e(b,a-1),b--};if(b>2){f(b),c=b-1;while(c>1)d(c,0),c--,e(0,c)}else this.comparator(this.rowByPosition(0),this.rowByPosition(1))>0&&d(0,1);this.comparator(this.rowByPosition(this.length-2),this.rowByPosition(this.length-1))>0&&d(this.length-1,this.length-2),this.syncable&&a.silent&&this.trigger("sort")},toJSON:function(){var a=[];for(var b=0;b<this.length;b++)a.push(this.rowByPosition(b));return a}})}(this,_),function(a,_){var b=a.Miso;b.Product=b.Product||function(a){a=a||{},this.func=a.func;if(a.columns){var b=a.columns;_.isArray(a.columns)&&(b=a.columns[0]),this.valuetype=b.type,this.numeric=function(){return b.toNumeric(this.value)}}return this.func({silent:!0}),this},_.extend(b.Product.prototype,b.Events,{val:function(){return this.value},type:function(){return this.valuetype},_sync:function(a){this.func()},_buildDelta:function(a,b){return{old:a,changed:b}}}),_.extend(b.DataView.prototype,{_findColumns:function(a){var b=[];return _.isUndefined(a)&&(a=this.columnNames()),a=_.isArray(a)?a:[a],_.each(a,function(a){a=this._columns[this._columnPositionByName[a]],b.push(a)},this),b},sum:function(a,c){c=c||{};var d=this._findColumns(a),e=function(a){return function(){return _.each(a,function(a){if(a.type===b.types.time.name)throw new Error("Can't sum up time")}),_.sum(_.map(a,function(a){return a._sum()}))}}(d);return this._calculated(d,e)},max:function(a,c){c=c||{};var d=this._findColumns(a),e=function(a){return function(){var c=_.max(_.map(a,function(a){return a._max()})),d=a[0].type,e=a[0].typeOptions;return b.types[d].coerce(c,e)}}(d);return this._calculated(d,e)},min:function(a,c){c=c||{};var d=this._findColumns(a),e=function(a){return function(){var c=_.min(_.map(a,function(a){return a._min()})),d=a[0].type,e=a[0].typeOptions;return b.types[d].coerce(c,e)}}(d);return this._calculated(d,e)},mean:function(a,c){c=c||{};var d=this._findColumns(a),e=function(a){return function(){var c=[];_.each(a,function(a){c.push(a.data)}),c=_.flatten(c);var d=a[0].type,e=a[0].typeOptions;return c=_.map(c,function(a){return b.types[d].numeric(a)}),b.types[d].coerce(_.mean(c),e)}}(d);return this._calculated(d,e)},_calculated:function(a,c){var d=this,e=new b.Product({columns:a,func:function(a){a=a||{};var b=this._buildDelta(this.value,c.apply(d));this.value=b.changed;if(d.syncable){var e=this._buildEvent(b);!_.isUndefined(b.old)&&!a.silent&&b.old!==b.changed&&this.trigger("change",e)}}});return this.syncable?(this.bind("change",e._sync,e),e):c()}})}(this,_),function(a,_,moment){var b=a.Miso;b.Dataset=function(a){return a=a||(a={}),this.length=0,this._initialize(a),this},_.extend(b.Dataset.prototype,b.DataView.prototype,{_initialize:function(a){a.sync===!0&&(_.extend(this,b.Events),this.syncable=!0),this.importer=a.importer||null,this.parser=a.parser||b.Parsers.Obj,_.isUndefined(a.parser)&&(a.strict?this.parser=b.Parsers.Strict:a.delimiter&&(this.parser=b.Parsers.Delimited)),a.delimiter&&(a.dataType="text"),this.importer===null&&(a.url?a.interval?(this.importer=b.Importers.Polling,this.interval=a.interval):this.importer=b.Importers.Remote:this.importer=b.Importers.Local),this.parser=new this.parser(a),this.importer=new this.importer(a),a.comparator&&(this.comparator=a.comparator),a.ready&&(this.ready=a.ready),a.resetOnFetch&&(this.resetOnFetch=a.resetOnFetch),a.uniqueAgainst&&(this.uniqueAgainst=a.uniqueAgainst),this._columns=[],this._columnPositionByName={},_.isUndefined(a.data)&&_.isUndefined(a.url)&&this._addIdColumn(),a.deferred&&(this.deferred=a.deferred),a.columns&&this.addColumns(a.columns)},fetch:function(a){a=a||{};var b=this.deferred||new _.Deferred;if(_.isNull(this.importer))throw"No importer defined";return this.importer.fetch({success:_.bind(function(c){this.apply(c),this.comparator&&this.sort(),this.ready&&this.ready.call(this),a.success&&a.success.call(this),b.resolveWith(this,[this])},this),error:_.bind(function(c){a.error&&a.error.call(this),b.reject(c)},this)}),b.promise()},_applications:{againstColumn:function(a){var b=[],c=_.keys(a),d,e=this.column(this.uniqueAgainst),f=a[this._columns[1].name].length,g=_.max(_.map(c,function(b){return a[b].length},this)),h=[],i;for(i=0;i<f;i++){var j=a[this.uniqueAgainst][i];e.data.indexOf(j)!==-1&&h.push(i)}h.sort().reverse();for(i=0;i<g;i++)if(h.indexOf(i)===-1){d={};for(var k=0;k<c.length;k++)d[c[k]]=a[c[k]][i];b.push(d)}this.add(b)},blind:function(a){var b,c,d=[],e,f=_.keys(a),g=_.max(_.map(f,function(b){return a[b].length},this));for(var h=0;h<g;h++){e={};for(var i=0;i<f.length;i++)e[f[i]]=a[f[i]][h];d.push(e)}this.add(d)}},apply:function(a){var c=this.parser.parse(a);if(!this.fetched)this._addIdColumn(),this.addColumns(_.map(c.columns,function(a){return{name:a}})),b.Builder.detectColumnTypes(this,c.data),this._applications.blind.call(this,c.data),this.fetched=!0;else if(this.resetOnFetch)this.reset(),this._applications.blind.call(this,c.data);else if(this.uniqueAgainst){if(!this.hasColumn(this.uniqueAgainst))throw new Error("You requested a unique add against a column that doesn't exist.");this._applications.againstColumn.call(this,c.data)}else this._applications.blind.call(this,c.data);b.Builder.cacheRows(this)},addColumns:function(a){_.each(a,function(a){this.addColumn(a)},this)},addColumn:function(a){return _.isUndefined(this.column(a.name))?(a=new b.Column(a),this._columns.push(a),this._columnPositionByName[a.name]=this._columns.length-1,a):!1},_addIdColumn:function(a){if(!_.isUndefined(this.column("_id")))return;var b=[];a&&a>0&&_.times(a,function(){b.push(_.uniqueId())}),this.addColumn({name:"_id",type:"number",data:b});if(this._columnPositionByName._id!==0){var c=this._columns[this._columnPositionByName._id],d=this._columnPositionByName._id;this._columns.splice(d,1),this._columns.unshift(c),this._columnPositionByName._id=0,_.each(this._columnPositionByName,function(a,b){b!=="_id"&&this._columnPositionByName[b]<d&&this._columnPositionByName[b]++},this)}},add:function(a,b){b=b||{},_.isArray(a)||(a=[a]);var c=[];_.each(a,function(a){a._id||(a._id=_.uniqueId()),this._add(a,b),this.syncable&&!b.silent&&c.push({changed:a})},this);if(this.syncable&&!b.silent){var d=this._buildEvent(c);this.trigger("add",d),this.trigger("change",d)}},remove:function(a,b){a=this._rowFilter(a);var c=[],d=[];this.each(function(b,e){a(b)&&(d.push(b._id),c.push({old:b}))}),_.each(d,function(a){this._remove(a)},this);if(this.syncable&&(!b||!b.silent)){var e=this._buildEvent(c);this.trigger("remove",e),this.trigger("change",e)}},update:function(a,c,d){a=this._rowFilter(a);var e=_.keys(c),f=[];this.each(function(d,g){a(d)&&(_.each(this._columns,function(a){if(_.indexOf(e,a.name)!==-1){var d=b.types[a.type];if(d)if(b.typeOf(c[a.name],a)===a.type)c[a.name]=d.coerce(c[a.name],a);else throw"incorrect value '"+c[a.name]+"' of type "+b.typeOf(c[a.name],a)+" passed to column with type "+a.type;a.data[g]=c[a.name]}},this),f.push({_id:d._id,old:d,changed:c}))},this);if(this.syncable&&(!d||!d.silent)){var g=this._buildEvent(f);this.trigger("update",g),this.trigger("change",g)}},reset:function(a){_.each(this._columns,function(a){a.data=[]}),this.length=0,this.syncable&&(!a||!a.silent)&&this.trigger("reset")}})}(this,_,moment),function(a,_){var b=a.Miso||(a.Miso={});b.Derived=b.Derived||function(a){return a=a||{},b.Dataset.call(this),this.parent=a.parent,this.method=a.method,this._addIdColumn(),this.addColumn({name:"_oids",type:"mixed"}),this.prototype=b.Derived.prototype,this.parent.syncable&&(_.extend(this,b.Events),this.syncable=!0,this.parent.bind("change",this._sync,this)),this},_.extend(b.Derived.prototype,b.Dataset.prototype,{_sync:function(a){this.func.call(this.args),this.trigger("change")}}),_.extend(b.Dataset.prototype,{movingAverage:function(a,c,d){d=d||{};var e=new b.Derived({parent:this,method:d.method||_.mean,size:c,args:arguments});this.eachColumn(function(a){e.addColumn({name:a,type:this.column(a).type,data:[]})},this),b.Builder.cacheColumns(e);var f=function(){var d=[];typeof a=="string"&&(a=[a]),this.column("_id").data=this.parent.column("_id").data.slice(c-1,this.parent.length),this.eachColumn(function(b,d,e){a.indexOf(b)===-1&&b!=="_oids"?d.data=this.parent.column(b).data.slice(c-1,this.parent.length):d.data=_.movingAvg(this.parent.column(b).data,c,this.method)},this),this.length=this.parent.length-c+1;var e=this.column("_oids");e.data=[];for(var f=0;f<this.length;f++)e.data.push(this.parent.column("_id").data.slice(f,f+c));return b.Builder.cacheRows(this),this};return e.func=_.bind(f,e),e.func.call(e.args)},groupBy:function(a,c,d){d=d||{};var e=new b.Derived({parent:this,method:d.method||_.sum,args:arguments});d&&d.preprocess&&(e.preprocess=d.preprocess);var f=_.union([a],c);_.each(f,function(a){this.addColumn({name:a,type:this.parent.column(a).type,data:[]})},e),b.Builder.cacheColumns(e);var g=function(){b.Builder.clearRowCache(this);var d={},e=0,f=this._columnPositionByName[a],g=this.parent.column(a);for(var h=0;h<this.parent.length;h++){var i=null;this.preprocess?i=this.preprocess(g.data[h]):i=g.data[h],_.isUndefined(d[i])&&(d[i]=e,_.each(c,function(a){var b=this.column(a),c=this.column("_id");b.data[e]=[],c.data[e]=_.uniqueId()},this),this.column(a).data[e]=i,e++),_.each(c,function(a){var b=this.column(a),c=this.parent.column(a).data[h],e=d[i];b.data[e].push(this.parent.rowByPosition(h))},this)}var j=this._columns[this._columnPositionByName._oids];return j.data=[],_.each(c,function(a){var b=this.column(a);_.each(b.data,function(c,d){_.isArray(c)&&(j.data[d]=j.data[d]||[],j.data[d].push(_.map(c,function(a){return a._id})),j.data[d]=_.flatten(j.data[d]),b.data[d]=this.method(_.map(c,function(b){return b[a]})),this.length++)},this)},this),b.Builder.cacheRows(this),this};return e.func=_.bind(g,e),e.func.call(e.args)}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers=function(a,b){},b.Importers.prototype.extract=function(a){return a=_.clone(a),a}}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.Local=function(a){a=a||{},this.data=a.data||null,this.extract=a.extract||this.extract},_.extend(b.Importers.Local.prototype,b.Importers.prototype,{fetch:function(a){var b=a.data?a.data:this.data;a.success(this.extract(b))}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.Remote=function(a){a=a||{},this._url=a.url,this.extract=a.extract||this.extract,this.params={type:"GET",url:_.isFunction(this._url)?_.bind(this._url,this):this._url,dataType:a.dataType?a.dataType:a.jsonp?"jsonp":"json"}},_.extend(b.Importers.Remote.prototype,b.Importers.prototype,{fetch:function(a){var c=_.bind(function(b){a.success(this.extract(b))},this);b.Xhr(_.extend(this.params,{success:c,error:a.error}))}});var c={url:"",data:"",dataType:"",success:function(){},type:"GET",async:!0,xhr:function(){return new a.XMLHttpRequest}},d=/\?/;b.Xhr=function(a){a.dataType=a.dataType&&a.dataType.toLowerCase()||null;var e=_.isFunction(a.url)?a.url():a.url;if(!(!a.dataType||a.dataType!=="jsonp"&&a.dataType!=="script")){b.Xhr.getJSONP(e,a.success,a.dataType==="script",a.error);return}var f=_.extend({},c,a,{url:e});f.ajax=f.xhr();if(f.ajax)return f.type==="GET"&&f.data&&(f.url+=(d.test(f.url)?"&":"?")+f.data,f.data=null),f.ajax.open(f.type,f.url,f.async),f.ajax.send(f.data||null),b.Xhr.httpData(f)},b.Xhr.getJSONP=function(a,b,c,d){if(c){var e=document.querySelectorAll('script[src="'+a+'"]');if(e.length){b&&b(!0);return}}var f=document.head||document.getElementsByTagName("head")[0]||document.documentElement,g=document.createElement("script"),h=a.split("?")[1],i=!1,j=[],k,l,m;h&&!c&&(j=h.split("&")),j.length&&(l=j[j.length-1].split("=")),k=j.length?l[1]?l[1]:l[0]:"jsonp",!h&&!c&&(a+="?callback="+k),k&&!c&&(!window[k]||(k=k+ +(new Date)+_.uniqueId()),window[k]=function(a){b&&b(a),i=!0},a=a.replace(l.join("="),l[0]+"="+k)),g.onload=g.onreadystatechange=function(){if(!g.readyState||/loaded|complete/.test(g.readyState)){c&&b&&b();if(i){try{delete window[k]}catch(a){window[k]=void 0}f.removeChild(g)}}},g.onerror=function(a){d&&d.call(null)},g.src=a,f.insertBefore(g,f.firstChild);return},b.Xhr.httpData=function(a){var b,c=null;return a.ajax.onreadystatechange=function(){if(a.ajax.readyState===4){try{c=JSON.parse(a.ajax.responseText)}catch(d){}b={xml:a.ajax.responseXML,text:a.ajax.responseText,json:c},a.dataType&&(b=b[a.dataType]),/(2..)/.test(a.ajax.status)?a.success.call(a.ajax,b):a.error&&a.error.call(null,a.ajax.statusText)}},b}}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.Polling=function(a){a=a||{},this.interval=a.interval||1e3,this._def=null,b.Importers.Remote.apply(this,[a])},_.extend(b.Importers.Polling.prototype,b.Importers.Remote.prototype,{fetch:function(c){this._def===null&&(this._def=_.Deferred(),this.success_callback=_.bind(function(a){c.success(this.extract(a)),this._def.resolve(this)},this),this.error_callback=_.bind(function(a){c.error(a),this._def.reject(a)},this)),_.when(this._def.promise()).then(function(a){var b=_.bind(function(){this.fetch({success:this.success_callback,error:this.error_callback})},a);setTimeout(b,a.interval),a._def=_.Deferred()}),b.Xhr(_.extend(this.params,{success:this.success_callback,error:this.error_callback})),a.imp=this},stop:function(){this._def!==null&&this._def.reject()},start:function(){this._def!==null&&(this._def=_.Deferred(),this.fetch())}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Importers.GoogleSpreadsheet=function(a){a=a||{};if(a.url)a.url=a.url;else{if(_.isUndefined(a.key))throw new Error("Set options 'key' properties to point to your google document.");a.worksheet=a.worksheet||1,a.url="https://spreadsheets.google.com/feeds/cells/"+a.key+"/"+a.worksheet+"/public/basic?alt=json-in-script&callback=",delete a.key,delete a.worksheet}return this.parser=b.Parsers.GoogleSpreadsheet,this.params={type:"GET",url:a.url,dataType:"jsonp"},this},_.extend(b.Importers.GoogleSpreadsheet.prototype,b.Importers.Remote.prototype)}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers=function(a){this.options=a||{}},_.extend(b.Parsers.prototype,{parse:function(){}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.Strict=function(a){this.options=a||{}},_.extend(b.Parsers.Strict.prototype,b.Parsers.prototype,{parse:function(a){var b={},c=[];return _.each(a.columns,function(a){c.push(a.name),b[a.name]=a.data}),{columns:c,data:b}}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.Obj=b.Parsers,_.extend(b.Parsers.Obj.prototype,b.Parsers.prototype,{parse:function(a){var b=_.keys(a[0]),c={};return _.each(b,function(a){c[a]=[]}),_.each(b,function(b){_.times(a.length,function(d){c[b].push(a[d][b])})}),{columns:b,data:c}}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.GoogleSpreadsheet=function(a){},_.extend(b.Parsers.GoogleSpreadsheet.prototype,b.Parsers.prototype,{parse:function(a){var b=[],c=[],d=/([A-Z]+)(\d+)/,e={};_.each(a.feed.entry,function(a,f){var g=d.exec(a.title.$t),h=g[1],i=parseInt(g[2],10);if(_.isUndefined(e[h]))e[h]=c.length,b[e[h]]=a.content.$t,c[e[h]]=[];else{var j=e[h];c[j][i-1]=a.content.$t}},this),c.length=_.max(_.pluck(c,"length"))-1;var f={};return _.each(c,function(a,c){a.splice(0,1);for(var d=0;d<a.length;d++)if(_.isUndefined(a[d])||a[d]==="")a[d]=null;f[b[c]]=a}),{columns:b,data:f}}})}(this,_),function(a,_){var b=a.Miso||(a.Miso={});b.Parsers.Delimited=function(a){a=a||{},this.delimiter=a.delimiter||",",this.__delimiterPatterns=new RegExp("(\\"+this.delimiter+"|\\r?\\n|\\r|^)"+'(?:"([^"]*(?:""[^"]*)*)"|'+'([^"\\'+this.delimiter+"\\r\\n]*))","gi")},_.extend(b.Parsers.Delimited.prototype,b.Parsers.prototype,{parse:function(a){var b=[],c={},d=function(a,d,e){e=e||",";var f=null,g=0,h=!1,i=-1;while(f=a.exec(d)){var j=f[1];j.length&&j!==e?(h=!0,i=0):(h||g++,i++);var k=null;f[2]?k=f[2].replace(new RegExp('""',"g"),'"'):k=f[3],h?c[b[i]].push(k):(b.push(k),c[k]=[])}return{columns:b,data:c}};return d(this.__delimiterPatterns,a,this.delimiter)}})}(this,_)
1  test/nebulos-min.js
@@ -0,0 +1 @@
+var metaaps={};metaaps.nebulos=function(b){this.container=b;var c=b.width;var a=b.height;this.canvas=canvasport.createCanvas(b,c,a,{margin:"0px",padding:"0px",border:"none"});this.opacityvalue=0.9;this.notestboxes=true;this.stroke=true;this.screenportion=0.3;this.fillstyle={red:0,green:0,blue:0};this.strokestyle="rgba(0, 0, 0, 0.1)";this.shaded=true;this.multicolor=false;this.boxes=[];this.running=false;this.restarthandler=null;this.directions=["ne","se","nw","sw"];this.fontfamily="serif";this.minWordSize=3;this.textlist=[{text:"Nebulos",weight:30},{text:"Cool",weight:15},{text:"Excellent",weight:2},{text:"Want It!",weight:5},{text:"Google",weight:25},{text:"Rules",weight:15},{text:"Visualisation",weight:10},{text:"Charts",weight:10}];this.symbols=[".","!",":","*","?","+","'",'"',",",";","#","%","&","/","=","[","]","{","}","- ","_","(",")","\r","\t","\n"];this.commonwords=["the","of","to","and","a","in","is","it","you","that","he","was","for","on","are","with","as","i","his","they","be","at","one","have","this","from","or","had","by","hot","word","but","what","some","we","can","out","other","were","all","there","when","up","use","your","how","said","an","each","she","which","do","their","time","if","will","way","about","many","then","them","write","don","doesn","didn","would","wouldn","like","so","these","her","long","thing","see","him","two","has","look","more","day","could","go","come","did","no","most","my","over","than","who","may","down","been","any","not"];this.measureText=function(g,f,e,d){if(e){return{height:canvasport.measureText(d,g),width:f}}else{return{width:canvasport.measureText(d,g),height:f}}};this.findPosition=function(g,e,d,i,n){for(var h=0;h<150;h+=3){var l=this.directions[i%this.directions.length];var k=this.getPosition(g,l,h);if(n.getImageData&&this.notestboxes){if(canvasport.hitTest(n,k.x,(d?k.y-e.height:k.y),e.width,e.height,true)==false){return k}}else{var m={x:k.x,y:(d?k.y-e.height:k.y),width:e.width,height:e.height};for(var f=0;f<this.boxes.length;f++){var j=this.boxes[f];if(j.x<m.x+m.width&&m.x<j.x+j.width&&j.y<m.y+m.height&&m.y<j.y+j.height){break}}if(f==this.boxes.length){return k}}i++}return null};this.getPosition=function(e,f,d){var g=e;switch(f){case"n":g.y-=d;break;case"s":g.y+=d;break;case"e":g.x+=d;break;case"w":g.x-=d;break;case"ne":g.y-=d;g.x+=d;break;case"se":g.y+=d;g.x+=d;break;case"nw":g.y-=d;g.x-=d;break;case"sw":g.y+=d;g.x-=d;break}return g};this.extendBounds=function(e,d){e.minx=Math.min(d.x,e.minx);e.miny=Math.min(d.y,e.miny);e.maxx=Math.max(d.x+d.width,e.maxx);e.maxy=Math.max(d.y+d.height,e.maxy)};this.drawText=function(h,g,d,f,e){canvasport.drawText(e,h,d.x,d.y,f,g,this.stroke)};this.getOpacityvalue=function(e,d){if(this.shaded==false){return this.opacityvalue}else{return e/d*0.6+0.3}}};metaaps.nebulos.prototype={setSymbols:function(a){this.symbols=a},changeMostCommonWords:function(a){this.commonwords=a},setMinWordSize:function(a){this.minWordSize=a},restart:function(a){this.restarthandler=a},setText:function(a){this.textlist=this.generateTextlist(a)},setTextList:function(a){this.textlist=a},setFontFamily:function(a){this.fontfamily=a},draw:function(v,e){if(v){if(typeof v=="string"){this.setText(v)}else{this.setTextList(v)}}this.boxes=[];this.running=true;this.restarthandler=null;var d=this.canvas;var q=canvasport.getDrawing(d);q.clearRect(0,0,d.width,d.height);q.fillStyle="rgba(255, 255, 255, 1)";q.fillRect(0,0,d.width,d.height);var r={x:d.width/2,y:d.height/2};var g={minx:r.x,miny:r.y,maxx:r.x,maxy:r.y};function o(C,A){var w={x:(g.maxx+g.minx)/2,y:(g.maxy+g.miny)/2};var y={x:w.x-A.width/2,y:(a?w.y+A.height/2:w.y-A.height/2)};var z=g.maxx-g.minx;var i=g.maxy-g.miny;var C="";if(w.y>r.y){C+="n"}else{C+="s"}if(w.x>r.x){C+="w"}else{C+="e"}var B=(Math.random())*z/3;var x=(Math.random())*i/3;switch(C){case"ne":return{x:y.x+B,y:y.y-x};break;case"nw":return{x:y.x-B,y:y.y-x};break;case"se":return{x:y.x+B,y:y.y+x};break;case"sw":return{x:y.x-B,y:y.y+x};break}return null}var k=this.directions;var s=this;var a=0;this.textlistcount=0;q.textBaseline="top";q.strokeStyle=this.strokestyle;q.textAlign="left";var l={area:0};var n=10;var m=this.textlist;for(var t=0;t<m.length;t++){var u=m[t];var c=u.weight*n;q.font=c+"px "+s.fontfamily;var j=s.measureText(u.text,c,a,q);l.area+=j.width*j.height}var p=Math.sqrt((d.width*d.height)/l.area*s.screenportion)*n;var f=p*m[0].weight;var b="Could not place: ";function h(){var C=m[s.textlistcount++];var x=C.weight;var F=Math.floor(x*p);q.font=F+"px "+s.fontfamily;q.textBaseline="top";var A=s.getOpacityvalue(F,f);q.fillStyle="rgba("+s.fillstyle.red+", "+s.fillstyle.green+", "+s.fillstyle.blue+", "+A+")";q.strokeStyle=s.strokestyle;q.textAlign="left";var E=C.text;a=(Math.random()<0.5);var y=s.measureText(E,F,a,q);try{for(var i=0;i<4;i++,a=!a,y=s.measureText(E,F,a,q)){var B=Math.floor(Math.random()*4);var D=k[B];var w=s.findPosition(o(D,y),y,a,B,q);if(w!=null){s.drawText(E,q.font,w,a,q);s.boxes.push({x:w.x,y:(a?w.y-y.height:w.y),width:y.width,height:y.height,position:w,text:E,vertical:a,font:q.font,fillstyle:q.fillstyle,fontSize:F});break}}if(i==4){b+=" "+E}s.extendBounds(g,{x:w.x,y:(a?w.y-y.height:w.y),width:y.width,height:y.height})}catch(z){}if(s.restarthandler!=null){setTimeout(function(){s.restarthandler()},500);s.running=false;return}if(s.textlistcount<m.length){setTimeout(h,1)}else{s.running=false}}setTimeout(h,1)},redraw:function(){var c=this.canvas;var b=this;var a=canvasport.getDrawing(c);a.clearRect(0,0,c.width,c.height);a.textBaseline="top";a.strokeStyle=b.strokestyle;a.textAlign="left";var g=b.boxes[0].fontSize;for(var d=0;d<b.boxes.length;d++){var f=b.boxes[d];var e=b.getOpacityvalue(f.fontSize,g);a.fillStyle="rgba("+b.fillstyle.red+", "+b.fillstyle.green+", "+b.fillstyle.blue+", "+e+")";b.drawText(f.text,f.font,f.position,f.vertical,a)}},generateTextlist:function(j){var h=[];var c=j+" ";c=c.toLowerCase();for(var f=0;f<this.symbols.length;f++){var k=this.symbols[f];c=c.replace(new RegExp("\\"+k,"g")," ")}for(var f=0;f<this.commonwords.length;f++){var k=this.commonwords[f];c=c.replace(new RegExp(" "+k+" ","g")," ")}var d=c.split(" ");var g={};var e=this.minWordSize;for(var f=0;f<d.length;f++){var k=d[f];if(k.length>e){if(g[k]){g[k]++}else{g[k]=1}}}for(var a in g){if(!isNaN(g[a])){h.push({text:a,weight:g[a]})}}function b(l,i){if(l.weight<i.weight){return 1}if(l.weight>i.weight){return -1}return 0}h.sort(b);h.splice(200,Math.max(0,h.length-200));return h}};var canvasport={createCanvas:function(b,e,a,d){var c=document.createElement("canvas");b.appendChild(c);c.style.width=e;c.style.height=a;c.style.margin="0px";c.style.padding="0px";if(window.G_vmlCanvasManager){window.G_vmlCanvasManager.initElement(c)}return c},getDrawing:function(a){return a.getContext("2d")},_fillText:function(b,d,a,e,c){if(b.fillText){b.font=c;b.fillText(d,a,e)}else{if(b.mozDrawText){b.save();b.mozTextStyle=c;b.translate(a,e);b.mozDrawText(d);b.restore()}}},_strokeText:function(b,d,a,e,c){if(b.strokeText){b.font=c;b.strokeText(d,a,e)}else{if(b.mozDrawText){b.save();b.mozTextStyle=c;b.translate(a,e);b.mozDrawText(d);b.restore()}}},drawText:function(b,f,a,g,d,c,e){if(d){b.save();b.translate(a,g);b.rotate(270*Math.PI/180);this._fillText(b,f,0,0,c);if(e){this._strokeText(b,f,0,0,c)}b.restore()}else{this._fillText(b,f,a,g,c);if(e){this._strokeText(b,f,a,g,c)}}},measureText:function(a,b){return(a.measureText?a.measureText(b).width:(a.mozMeasureText?a.mozMeasureText(b):100))},drawImage:function(m,f,b,a,d,k,h,g,c,l){try{var i=f[0];m.drawImage(i,b,a,d,k,h,g,c,l)}catch(j){alert("Problem with canvas "+j.message)}},drawImageslice:function(a,d,g){try{var c=d;var b=g;if(this.spriteimage!=null){a.drawImage(this.spriteimage,c.x,0,c.w,c.h,b.x-Math.floor(c.w/2),b.y-Math.floor(c.h/2),c.w,c.h)}}catch(f){llh.error("Problem with canvas "+f.message)}},roundedRect:function(k,h,g,a,j,f,m,c,e,l){var b=7;var d=(j-b)/2;function i(n){return(c?n+h:a+h-n)}k.beginPath();k.moveTo(i(0),g+e);k.lineTo(i(0),g+d-b/2);k.quadraticCurveTo(i(-h),g+d-b/2,f.x,f.y);k.quadraticCurveTo(i(-h),g+d+b/2,i(0),g+d+b/2);k.lineTo(i(0),g+j-e);k.quadraticCurveTo(i(0),g+j,i(e),g+j);k.lineTo(i(a-e),g+j);k.quadraticCurveTo(i(a),g+j,i(a),g+j-e);k.lineTo(i(a),g+e);k.quadraticCurveTo(i(a),g,i(a-e),g);k.lineTo(i(e),g);k.quadraticCurveTo(i(0),g,i(0),g+e);k.closePath();k.strokeStyle=(l&&l.color?l.color:"#723F3F");k.fillStyle=(l&&l.bkcolor?l.bkcolor:"rgba(255, 255, 255, 1.0)");k.fill();k.stroke()},customiseBubble:function(c,d,b,f,e){var a=d.position();a.top+=parseInt(d.css("padding-top").replace("px",""));a.left+=parseInt(d.css("padding-left").replace("px",""));var h=5;c.clearRect(0,0,c.canvas.width,c.canvas.height);var g={x:(f?0:c.canvas.width),y:(b?0:c.canvas.height)};this.roundedRect(c,a.left-h,a.top-h,d.width()+2*h,d.height()+2*h,g,b,f,15,e)},hitTest:function(j,k,h,b,m,a){var g=j.canvas.width;var f=j.canvas.height;if(a){if((k<0)||(h<0)||(k+b>g)||(h+m>f)){return true}}var l=j.getImageData(k,h,b,m);var d=l.data;for(var e=0,c=d.length;e<c;e+=4){if(d[e]!=255){return true}}return false}};
13 test/raphaelboth.js
@@ -0,0 +1,13 @@
+/*
+ * Raphael 1.2.8 - JavaScript Vector Library
+ *
+ * Copyright (c) 2008 - 2009 Dmitry Baranovskiy (http://raphaeljs.com)
+ * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
+ */
+window.Raphael=(function(){var a=/[, ]+/,aH=/^(circle|rect|path|ellipse|text|image)$/,G=document,an=window,k={was:"Raphael" in an,is:an.Raphael},ai=function(){if(ai.is(arguments[0],"array")){var e=arguments[0],E=t[aO](ai,e.splice(0,3+ai.is(e[0],ag))),aS=E.set();for(var S=0,aT=e[l];S<aT;S++){var R=e[S]||{};aH.test(R.type)&&aS[d](E[R.type]().attr(R));}return aS;}return t[aO](ai,arguments);},aE="appendChild",aO="apply",aL="concat",am="",ah=" ",A="click dblclick mousedown mousemove mouseout mouseover mouseup".split(ah),L="hasOwnProperty",ae=/^\[object\s+|\]$/gi,ar="join",l="length",aQ="prototype",aR=String[aQ].toLowerCase,W=Math,f=W.max,aB=W.min,ag="number",at="toString",ap=Object[aQ][at],aJ={},aF=W.pow,d="push",aM=/^(?=[\da-f]$)/,c=/^url\(['"]?([^\)]+)['"]?\)$/i,u=/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgb\(\s*([\d\.]+\s*,\s*[\d\.]+\s*,\s*[\d\.]+)\s*\)|rgb\(\s*([\d\.]+%\s*,\s*[\d\.]+%\s*,\s*[\d\.]+%)\s*\)|hs[bl]\(\s*([\d\.]+\s*,\s*[\d\.]+\s*,\s*[\d\.]+)\s*\)|hs[bl]\(\s*([\d\.]+%\s*,\s*[\d\.]+%\s*,\s*[\d\.]+%)\s*\))\s*$/i,J=W.round,s="setAttribute",w="split",P=parseFloat,B=parseInt,aG=String[aQ].toUpperCase,h={"clip-rect":"0 0 10e9 10e9",cursor:"default",cx:0,cy:0,fill:"#fff","fill-opacity":1,font:'10px "Arial"',"font-family":'"Arial"',"font-size":"10","font-style":"normal","font-weight":400,gradient:0,height:0,href:"http://raphaeljs.com/",opacity:1,path:"M0,0",r:0,rotation:0,rx:0,ry:0,scale:"1 1",src:"",stroke:"#000","stroke-dasharray":"","stroke-linecap":"butt","stroke-linejoin":"butt","stroke-miterlimit":0,"stroke-opacity":1,"stroke-width":1,target:"_blank","text-anchor":"middle",title:"Raphael",translation:"0 0",width:0,x:0,y:0},U={"clip-rect":"csv",cx:ag,cy:ag,fill:"colour","fill-opacity":ag,"font-size":ag,height:ag,opacity:ag,path:"path",r:ag,rotation:"csv",rx:ag,ry:ag,scale:"csv",stroke:"colour","stroke-opacity":ag,"stroke-width":ag,translation:"csv",width:ag,x:ag,y:ag},aI="replace";ai.version="1.2.8";ai.type=(an.SVGAngle||G.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1")?"SVG":"VML");ai.svg=!(ai.vml=ai.type=="VML");ai._id=0;ai._oid=0;ai.fn={};ai.is=function(i,e){e=aR.call(e);return((e=="object"||e=="undefined")&&typeof i==e)||(i==null&&e=="null")||aR.call(ap.call(i)[aI](ae,am))==e;};ai.setWindow=function(e){an=e;G=an.document;};var aw=function(E){if(ai.vml){var e=/^\s+|\s+$/g;aw=ad(function(S){var aS;S=(S+am)[aI](e,am);try{var aT=new ActiveXObject("htmlfile");aT.write("<body>");aT.close();aS=aT.body;}catch(aV){aS=createPopup().document.body;}var i=aS.createTextRange();try{aS.style.color=S;var aU=i.queryCommandValue("ForeColor");aU=((aU&255)<<16)|(aU&65280)|((aU&16711680)>>>16);return"#"+("000000"+aU[at](16)).slice(-6);}catch(aV){return"none";}});}else{var R=G.createElement("i");R.title="Rapha\xebl Colour Picker";R.style.display="none";G.body[aE](R);aw=ad(function(i){R.style.color=i;return G.defaultView.getComputedStyle(R,am).getPropertyValue("color");});}return aw(E);};ai.hsb2rgb=ad(function(aW,aU,a0){if(ai.is(aW,"object")&&"h" in aW&&"s" in aW&&"b" in aW){a0=aW.b;aU=aW.s;aW=aW.h;}var S,aS,a1;if(a0==0){return{r:0,g:0,b:0,hex:"#000"};}if(aW>1||aU>1||a0>1){aW/=255;aU/=255;a0/=255;}var aT=~~(aW*6),aX=(aW*6)-aT,R=a0*(1-aU),E=a0*(1-(aU*aX)),a2=a0*(1-(aU*(1-aX)));S=[a0,E,R,R,a2,a0,a0][aT];aS=[a2,a0,a0,E,R,R,a2][aT];a1=[R,R,a2,a0,a0,E,R][aT];S*=255;aS*=255;a1*=255;var aY={r:S,g:aS,b:a1},e=(~~S)[at](16),aV=(~~aS)[at](16),aZ=(~~a1)[at](16);e=e[aI](aM,"0");aV=aV[aI](aM,"0");aZ=aZ[aI](aM,"0");aY.hex="#"+e+aV+aZ;return aY;},ai);ai.rgb2hsb=ad(function(e,i,aU){if(ai.is(e,"object")&&"r" in e&&"g" in e&&"b" in e){aU=e.b;i=e.g;e=e.r;}if(ai.is(e,"string")){var aW=ai.getRGB(e);e=aW.r;i=aW.g;aU=aW.b;}if(e>1||i>1||aU>1){e/=255;i/=255;aU/=255;}var aT=f(e,i,aU),E=aB(e,i,aU),S,R,aS=aT;if(E==aT){return{h:0,s:0,b:aT};}else{var aV=(aT-E);R=aV/aT;if(e==aT){S=(i-aU)/aV;}else{if(i==aT){S=2+((aU-e)/aV);}else{S=4+((e-i)/aV);}}S/=6;S<0&&S++;S>1&&S--;}return{h:S,s:R,b:aS};},ai);var ax=/,?([achlmqrstvxz]),?/gi;ai._path2string=function(){return this.join(",")[aI](ax,"$1");};function ad(R,i,e){function E(){var S=Array[aQ].slice.call(arguments,0),aT=S[ar]("\u25ba"),aS=E.cache=E.cache||{},aU=E.count=E.count||[];if(aS[L](aT)){return e?e(aS[aT]):aS[aT];}aU[l]>=1000&&delete aS[aU.shift()];aU[d](aT);aS[aT]=R[aO](i,S);return e?e(aS[aT]):aS[aT];}return E;}ai.getRGB=ad(function(e){if(!e||!!((e=e+am).indexOf("-")+1)){return{r:-1,g:-1,b:-1,hex:"none",error:1};}if(e=="none"){return{r:-1,g:-1,b:-1,hex:"none"};}!(({hs:1,rg:1})[L](e.substring(0,2))||e.charAt()=="#")&&(e=aw(e));var aS,E,R,aV,aW,aT=e.match(u);if(aT){if(aT[2]){aV=B(aT[2].substring(5),16);R=B(aT[2].substring(3,5),16);E=B(aT[2].substring(1,3),16);}if(aT[3]){aV=B((aW=aT[3].charAt(3))+aW,16);R=B((aW=aT[3].charAt(2))+aW,16);E=B((aW=aT[3].charAt(1))+aW,16);}if(aT[4]){aT=aT[4][w](/\s*,\s*/);E=P(aT[0]);R=P(aT[1]);aV=P(aT[2]);}if(aT[5]){aT=aT[5][w](/\s*,\s*/);E=P(aT[0])*2.55;R=P(aT[1])*2.55;aV=P(aT[2])*2.55;}if(aT[6]){aT=aT[6][w](/\s*,\s*/);E=P(aT[0]);R=P(aT[1]);aV=P(aT[2]);return ai.hsb2rgb(E,R,aV);}if(aT[7]){aT=aT[7][w](/\s*,\s*/);E=P(aT[0])*2.55;R=P(aT[1])*2.55;aV=P(aT[2])*2.55;return ai.hsb2rgb(E,R,aV);}aT={r:E,g:R,b:aV};var i=(~~E)[at](16),S=(~~R)[at](16),aU=(~~aV)[at](16);i=i[aI](aM,"0");S=S[aI](aM,"0");aU=aU[aI](aM,"0");aT.hex="#"+i+S+aU;return aT;}return{r:-1,g:-1,b:-1,hex:"none",error:1};},ai);ai.getColor=function(i){var E=this.getColor.start=this.getColor.start||{h:0,s:1,b:i||0.75},e=this.hsb2rgb(E.h,E.s,E.b);E.h+=0.075;if(E.h>1){E.h=0;E.s-=0.2;E.s<=0&&(this.getColor.start={h:0,s:1,b:E.b});}return e.hex;};ai.getColor.reset=function(){delete this.start;};ai.parsePathString=ad(function(e){if(!e){return null;}var E={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},i=[];if(ai.is(e,"array")&&ai.is(e[0],"array")){i=ao(e);}if(!i[l]){(e+am)[aI](/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/ig,function(S,R,aU){var aT=[],aS=aR.call(R);aU[aI](/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/ig,function(aW,aV){aV&&aT[d](+aV);});while(aT[l]>=E[aS]){i[d]([R][aL](aT.splice(0,E[aS])));if(!E[aS]){break;}}});}i[at]=ai._path2string;return i;});var N=ad(function(aY){if(!aY){return{x:0,y:0,width:0,height:0};}aY=C(aY);var aV=0,aU=0,S=[],E=[],R;for(var aS=0,aX=aY[l];aS<aX;aS++){R=aY[aS];if(R[0]=="M"){aV=R[1];aU=R[2];S[d](aV);E[d](aU);}else{var aT=au(aV,aU,R[1],R[2],R[3],R[4],R[5],R[6]);S=S[aL](aT.min.x,aT.max.x);E=E[aL](aT.min.y,aT.max.y);aV=R[5];aU=R[6];}}var e=aB[aO](0,S),aW=aB[aO](0,E);return{x:e,y:aW,width:f[aO](0,S)-e,height:f[aO](0,E)-aW};}),ao=function(aT){var R=[];if(!ai.is(aT,"array")||!ai.is(aT&&aT[0],"array")){aT=ai.parsePathString(aT);}for(var E=0,S=aT[l];E<S;E++){R[E]=[];for(var e=0,aS=aT[E][l];e<aS;e++){R[E][e]=aT[E][e];}}R[at]=ai._path2string;return R;},Y=ad(function(S){if(!ai.is(S,"array")||!ai.is(S&&S[0],"array")){S=ai.parsePathString(S);}var aX=[],aZ=0,aY=0,a2=0,a1=0,R=0;if(S[0][0]=="M"){aZ=S[0][1];aY=S[0][2];a2=aZ;a1=aY;R++;aX[d](["M",aZ,aY]);}for(var aU=R,a3=S[l];aU<a3;aU++){var e=aX[aU]=[],a0=S[aU];if(a0[0]!=aR.call(a0[0])){e[0]=aR.call(a0[0]);switch(e[0]){case"a":e[1]=a0[1];e[2]=a0[2];e[3]=a0[3];e[4]=a0[4];e[5]=a0[5];e[6]=+(a0[6]-aZ).toFixed(3);e[7]=+(a0[7]-aY).toFixed(3);break;case"v":e[1]=+(a0[1]-aY).toFixed(3);break;case"m":a2=a0[1];a1=a0[2];default:for(var aT=1,aV=a0[l];aT<aV;aT++){e[aT]=+(a0[aT]-((aT%2)?aZ:aY)).toFixed(3);}}}else{e=aX[aU]=[];if(a0[0]=="m"){a2=a0[1]+aZ;a1=a0[2]+aY;}for(var aS=0,E=a0[l];aS<E;aS++){aX[aU][aS]=a0[aS];}}var aW=aX[aU][l];switch(aX[aU][0]){case"z":aZ=a2;aY=a1;break;case"h":aZ+=+aX[aU][aW-1];break;case"v":aY+=+aX[aU][aW-1];break;default:aZ+=+aX[aU][aW-2];aY+=+aX[aU][aW-1];}}aX[at]=ai._path2string;return aX;},0,ao),p=ad(function(S){if(!ai.is(S,"array")||!ai.is(S&&S[0],"array")){S=ai.parsePathString(S);}var aW=[],aY=0,aX=0,a1=0,a0=0,R=0;if(S[0][0]=="M"){aY=+S[0][1];aX=+S[0][2];a1=aY;a0=aX;R++;aW[0]=["M",aY,aX];}for(var aU=R,a2=S[l];aU<a2;aU++){var e=aW[aU]=[],aZ=S[aU];if(aZ[0]!=aG.call(aZ[0])){e[0]=aG.call(aZ[0]);switch(e[0]){case"A":e[1]=aZ[1];e[2]=aZ[2];e[3]=aZ[3];e[4]=aZ[4];e[5]=aZ[5];e[6]=+(aZ[6]+aY);e[7]=+(aZ[7]+aX);break;case"V":e[1]=+aZ[1]+aX;break;case"H":e[1]=+aZ[1]+aY;break;case"M":a1=+aZ[1]+aY;a0=+aZ[2]+aX;default:for(var aT=1,aV=aZ[l];aT<aV;aT++){e[aT]=+aZ[aT]+((aT%2)?aY:aX);}}}else{for(var aS=0,E=aZ[l];aS<E;aS++){aW[aU][aS]=aZ[aS];}}switch(e[0]){case"Z":aY=a1;aX=a0;break;case"H":aY=e[1];break;case"V":aX=e[1];break;default:aY=aW[aU][aW[aU][l]-2];aX=aW[aU][aW[aU][l]-1];}}aW[at]=ai._path2string;return aW;},null,ao),aP=function(i,R,e,E){return[i,R,e,E,e,E];},aD=function(i,R,aT,S,e,E){var aS=1/3,aU=2/3;return[aS*i+aU*aT,aS*R+aU*S,aS*e+aU*aT,aS*E+aU*S,e,E];},F=function(a2,bw,bb,a9,a3,aX,aS,a1,bv,a4){var S=W.PI,a8=S*120/180,e=S/180*(+a3||0),bf=[],bc,bs=ad(function(bx,bA,i){var bz=bx*W.cos(i)-bA*W.sin(i),by=bx*W.sin(i)+bA*W.cos(i);return{x:bz,y:by};});if(!a4){bc=bs(a2,bw,-e);a2=bc.x;bw=bc.y;bc=bs(a1,bv,-e);a1=bc.x;bv=bc.y;var E=W.cos(S/180*a3),aZ=W.sin(S/180*a3),bh=(a2-a1)/2,bg=(bw-bv)/2;bb=f(bb,W.abs(bh));a9=f(a9,W.abs(bg));var R=bb*bb,bk=a9*a9,bm=(aX==aS?-1:1)*W.sqrt(W.abs((R*bk-R*bg*bg-bk*bh*bh)/(R*bg*bg+bk*bh*bh))),a6=bm*bb*bg/a9+(a2+a1)/2,a5=bm*-a9*bh/bb+(bw+bv)/2,aW=W.asin(((bw-a5)/a9).toFixed(7)),aV=W.asin(((bv-a5)/a9).toFixed(7));aW=a2<a6?S-aW:aW;aV=a1<a6?S-aV:aV;aW<0&&(aW=S*2+aW);aV<0&&(aV=S*2+aV);if(aS&&aW>aV){aW=aW-S*2;}if(!aS&&aV>aW){aV=aV-S*2;}}else{aW=a4[0];aV=a4[1];a6=a4[2];a5=a4[3];}var a0=aV-aW;if(W.abs(a0)>a8){var a7=aV,ba=a1,aY=bv;aV=aW+a8*(aS&&aV>aW?1:-1);a1=a6+bb*W.cos(aV);bv=a5+a9*W.sin(aV);bf=F(a1,bv,bb,a9,a3,0,aS,ba,aY,[aV,a7,a6,a5]);}a0=aV-aW;var aU=W.cos(aW),bu=W.sin(aW),aT=W.cos(aV),bt=W.sin(aV),bi=W.tan(a0/4),bl=4/3*bb*bi,bj=4/3*a9*bi,br=[a2,bw],bq=[a2+bl*bu,bw-bj*aU],bp=[a1+bl*bt,bv-bj*aT],bn=[a1,bv];bq[0]=2*br[0]-bq[0];bq[1]=2*br[1]-bq[1];if(a4){return[bq,bp,bn][aL](bf);}else{bf=[bq,bp,bn][aL](bf)[ar]()[w](",");var bd=[];for(var bo=0,be=bf[l];bo<be;bo++){bd[bo]=bo%2?bs(bf[bo-1],bf[bo],e).y:bs(bf[bo],bf[bo+1],e).x;}return bd;}},H=ad(function(i,e,R,E,aV,aU,aT,aS,aW){var S=1-aW;return{x:aF(S,3)*i+aF(S,2)*3*aW*R+S*3*aW*aW*aV+aF(aW,3)*aT,y:aF(S,3)*e+aF(S,2)*3*aW*E+S*3*aW*aW*aU+aF(aW,3)*aS};}),av=ad(function(i,e,a6,a4,aS,S,aU,aT,a0){var aY=1-a0,aX=aF(aY,3)*i+aF(aY,2)*3*a0*a6+aY*3*a0*a0*aS+aF(a0,3)*aU,aV=aF(aY,3)*e+aF(aY,2)*3*a0*a4+aY*3*a0*a0*S+aF(a0,3)*aT,a2=i+2*a0*(a6-i)+a0*a0*(aS-2*a6+i),a1=e+2*a0*(a4-e)+a0*a0*(S-2*a4+e),a5=a6+2*a0*(aS-a6)+a0*a0*(aU-2*aS+a6),a3=a4+2*a0*(S-a4)+a0*a0*(aT-2*S+a4),aZ=(1-a0)*i+a0*a6,aW=(1-a0)*e+a0*a4,R=(1-a0)*aS+a0*aU,E=(1-a0)*S+a0*aT;return{x:aX,y:aV,m:{x:a2,y:a1},n:{x:a5,y:a3},start:{x:aZ,y:aW},end:{x:R,y:E}};}),au=ad(function(E,e,S,R,a2,a1,aY,aV){var a0=(a2-2*S+E)-(aY-2*a2+S),aX=2*(S-E)-2*(a2-S),aU=E-S,aT=(-aX+W.sqrt(aX*aX-4*a0*aU))/2/a0,aS=(-aX-W.sqrt(aX*aX-4*a0*aU))/2/a0,aW=[e,aV],aZ=[E,aY],i;W.abs(aT)>1000000000000&&(aT=0.5);W.abs(aS)>1000000000000&&(aS=0.5);if(aT>0&&aT<1){i=H(E,e,S,R,a2,a1,aY,aV,aT);aZ[d](i.x);aW[d](i.y);}if(aS>0&&aS<1){i=H(E,e,S,R,a2,a1,aY,aV,aS);aZ[d](i.x);aW[d](i.y);}a0=(a1-2*R+e)-(aV-2*a1+R);aX=2*(R-e)-2*(a1-R);aU=e-R;aT=(-aX+W.sqrt(aX*aX-4*a0*aU))/2/a0;aS=(-aX-W.sqrt(aX*aX-4*a0*aU))/2/a0;W.abs(aT)>1000000000000&&(aT=0.5);W.abs(aS)>1000000000000&&(aS=0.5);if(aT>0&&aT<1){i=H(E,e,S,R,a2,a1,aY,aV,aT);aZ[d](i.x);aW[d](i.y);}if(aS>0&&aS<1){i=H(E,e,S,R,a2,a1,aY,aV,aS);aZ[d](i.x);aW[d](i.y);}return{min:{x:aB[aO](0,aZ),y:aB[aO](0,aW)},max:{x:f[aO](0,aZ),y:f[aO](0,aW)}};}),C=ad(function(a2,aX){var S=p(a2),aY=aX&&p(aX),aZ={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},e={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},aT=function(a3,a4){var i,a5;if(!a3){return["C",a4.x,a4.y,a4.x,a4.y,a4.x,a4.y];}!(a3[0] in {T:1,Q:1})&&(a4.qx=a4.qy=null);switch(a3[0]){case"M":a4.X=a3[1];a4.Y=a3[2];break;case"A":a3=["C"][aL](F[aO](0,[a4.x,a4.y][aL](a3.slice(1))));break;case"S":i=a4.x+(a4.x-(a4.bx||a4.x));a5=a4.y+(a4.y-(a4.by||a4.y));a3=["C",i,a5][aL](a3.slice(1));break;case"T":a4.qx=a4.x+(a4.x-(a4.qx||a4.x));a4.qy=a4.y+(a4.y-(a4.qy||a4.y));a3=["C"][aL](aD(a4.x,a4.y,a4.qx,a4.qy,a3[1],a3[2]));break;case"Q":a4.qx=a3[1];a4.qy=a3[2];a3=["C"][aL](aD(a4.x,a4.y,a3[1],a3[2],a3[3],a3[4]));break;case"L":a3=["C"][aL](aP(a4.x,a4.y,a3[1],a3[2]));break;case"H":a3=["C"][aL](aP(a4.x,a4.y,a3[1],a4.y));break;case"V":a3=["C"][aL](aP(a4.x,a4.y,a4.x,a3[1]));break;case"Z":a3=["C"][aL](aP(a4.x,a4.y,a4.X,a4.Y));break;}return a3;},E=function(a3,a4){if(a3[a4][l]>7){a3[a4].shift();var a5=a3[a4];while(a5[l]){a3.splice(a4++,0,["C"][aL](a5.splice(0,6)));}a3.splice(a4,1);a0=f(S[l],aY&&aY[l]||0);}},R=function(a7,a6,a4,a3,a5){if(a7&&a6&&a7[a5][0]=="M"&&a6[a5][0]!="M"){a6.splice(a5,0,["M",a3.x,a3.y]);a4.bx=0;a4.by=0;a4.x=a7[a5][1];a4.y=a7[a5][2];a0=f(S[l],aY&&aY[l]||0);}};for(var aV=0,a0=f(S[l],aY&&aY[l]||0);aV<a0;aV++){S[aV]=aT(S[aV],aZ);E(S,aV);aY&&(aY[aV]=aT(aY[aV],e));aY&&E(aY,aV);R(S,aY,aZ,e,aV);R(aY,S,e,aZ,aV);var aU=S[aV],a1=aY&&aY[aV],aS=aU[l],aW=aY&&a1[l];aZ.x=aU[aS-2];aZ.y=aU[aS-1];aZ.bx=P(aU[aS-4])||aZ.x;aZ.by=P(aU[aS-3])||aZ.y;e.bx=aY&&(P(a1[aW-4])||e.x);e.by=aY&&(P(a1[aW-3])||e.y);e.x=aY&&a1[aW-2];e.y=aY&&a1[aW-1];}return aY?[S,aY]:S;},null,ao),n=ad(function(aW){var aV=[];for(var aS=0,aX=aW[l];aS<aX;aS++){var e={},aU=aW[aS].match(/^([^:]*):?([\d\.]*)/);e.color=ai.getRGB(aU[1]);if(e.color.error){return null;}e.color=e.color.hex;aU[2]&&(e.offset=aU[2]+"%");aV[d](e);}for(var aS=1,aX=aV[l]-1;aS<aX;aS++){if(!aV[aS].offset){var E=P(aV[aS-1].offset||0),R=0;for(var S=aS+1;S<aX;S++){if(aV[S].offset){R=aV[S].offset;break;}}if(!R){R=100;S=aX;}R=P(R);var aT=(R-E)/(S-aS+1);for(;aS<S;aS++){E+=aT;aV[aS].offset=E+"%";}}}return aV;}),aj=function(){var E,i,S,R,e;if(ai.is(arguments[0],"string")||ai.is(arguments[0],"object")){if(ai.is(arguments[0],"string")){E=G.getElementById(arguments[0]);}else{E=arguments[0];}if(E.tagName){if(arguments[1]==null){return{container:E,width:E.style.pixelWidth||E.offsetWidth,height:E.style.pixelHeight||E.offsetHeight};}else{return{container:E,width:arguments[1],height:arguments[2]};}}}else{if(ai.is(arguments[0],ag)&&arguments[l]>3){return{container:1,x:arguments[0],y:arguments[1],width:arguments[2],height:arguments[3]};}}},az=function(e,E){var i=this;for(var R in E){if(E[L](R)&&!(R in e)){switch(typeof E[R]){case"function":(function(S){e[R]=e===i?S:function(){return S[aO](i,arguments);};})(E[R]);break;case"object":e[R]=e[R]||{};az.call(this,e[R],E[R]);break;default:e[R]=E[R];break;}}}},af=function(e,i){e==i.top&&(i.top=e.prev);e==i.bottom&&(i.bottom=e.next);e.next&&(e.next.prev=e.prev);e.prev&&(e.prev.next=e.next);},T=function(e,i){if(i.top===e){return;}af(e,i);e.next=null;e.prev=i.top;i.top.next=e;i.top=e;},j=function(e,i){if(i.bottom===e){return;}af(e,i);e.next=i.bottom;e.prev=null;i.bottom.prev=e;i.bottom=e;},x=function(i,e,E){af(i,E);e==E.top&&(E.top=i);e.next&&(e.next.prev=i);i.next=e.next;i.prev=e;e.next=i;},ak=function(i,e,E){af(i,E);e==E.bottom&&(E.bottom=i);e.prev&&(e.prev.next=i);i.prev=e.prev;e.prev=i;i.next=e;},al=/^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/;if(ai.svg){aJ.svgns="http://www.w3.org/2000/svg";aJ.xlink="http://www.w3.org/1999/xlink";var J=function(e){return +e+(~~e===e)*0.5;},O=function(aS){for(var E=0,R=aS[l];E<R;E++){if(aR.call(aS[E][0])!="a"){for(var e=1,S=aS[E][l];e<S;e++){aS[E][e]=J(aS[E][e]);}}else{aS[E][6]=J(aS[E][6]);aS[E][7]=J(aS[E][7]);}}return aS;},aC=function(E,e){if(e){for(var i in e){if(e[L](i)){E[s](i,e[i]);}}}else{return G.createElementNS(aJ.svgns,E);}};ai[at]=function(){return"Your browser supports SVG.\nYou are running Rapha\xebl "+this.version;};var o=function(e,R){var i=aC("path");R.canvas&&R.canvas[aE](i);var E=new aq(i,R);E.type="path";V(E,{fill:"none",stroke:"#000",path:e});return E;};var b=function(R,a0,e){var aX="linear",aU=0.5,aS=0.5,a2=R.style;a0=(a0+am)[aI](al,function(a4,i,a5){aX="radial";if(i&&a5){aU=P(i);aS=P(a5);var a3=((aS>0.5)*2-1);aF(aU-0.5,2)+aF(aS-0.5,2)>0.25&&(aS=W.sqrt(0.25-aF(aU-0.5,2))*a3+0.5)&&aS!=0.5&&(aS=aS.toFixed(5)-0.00001*a3);}return am;});a0=a0[w](/\s*\-\s*/);if(aX=="linear"){var aT=a0.shift();aT=-P(aT);if(isNaN(aT)){return null;}var S=[0,0,W.cos(aT*W.PI/180),W.sin(aT*W.PI/180)],aZ=1/(f(W.abs(S[2]),W.abs(S[3]))||1);S[2]*=aZ;S[3]*=aZ;if(S[2]<0){S[0]=-S[2];S[2]=0;}if(S[3]<0){S[1]=-S[3];S[3]=0;}}var aW=n(a0);if(!aW){return null;}var E=aC(aX+"Gradient");E.id="r"+(ai._id++)[at](36);aC(E,aX=="radial"?{fx:aU,fy:aS}:{x1:S[0],y1:S[1],x2:S[2],y2:S[3]});e.defs[aE](E);for(var aV=0,a1=aW[l];aV<a1;aV++){var aY=aC("stop");aC(aY,{offset:aW[aV].offset?aW[aV].offset:!aV?"0%":"100%","stop-color":aW[aV].color||"#fff"});E[aE](aY);}aC(R,{fill:"url(#"+E.id+")",opacity:1,"fill-opacity":1});a2.fill=am;a2.opacity=1;a2.fillOpacity=1;return 1;};var I=function(i){var e=i.getBBox();aC(i.pattern,{patternTransform:ai.format("translate({0},{1})",e.x,e.y)});};var V=function(aZ,a8){var a2={"":[0],none:[0],"-":[3,1],".":[1,1],"-.":[3,1,1,1],"-..":[3,1,1,1,1,1],". ":[1,3],"- ":[4,3],"--":[8,3],"- .":[4,3,1,3],"--.":[8,3,1,3],"--..":[8,3,1,3,1,3]},a4=aZ.node,a0=aZ.attrs,aW=aZ.rotate(),aS=function(bf,be){be=a2[aR.call(be)];if(be){var bc=bf.attrs["stroke-width"]||"1",ba={round:bc,square:bc,butt:0}[bf.attrs["stroke-linecap"]||a8["stroke-linecap"]]||0,bd=[];var bb=be[l];while(bb--){bd[bb]=be[bb]*bc+((bb%2)?1:-1)*ba;}aC(a4,{"stroke-dasharray":bd[ar](",")});}};a8[L]("rotation")&&(aW=a8.rotation);var aV=(aW+am)[w](a);if(!(aV.length-1)){aV=null;}else{aV[1]=+aV[1];aV[2]=+aV[2];}P(aW)&&aZ.rotate(0,true);for(var a3 in a8){if(a8[L](a3)){if(!h[L](a3)){continue;}var a1=a8[a3];a0[a3]=a1;switch(a3){case"rotation":aZ.rotate(a1,true);break;case"href":case"title":case"target":var a6=a4.parentNode;if(aR.call(a6.tagName)!="a"){var R=aC("a");a6.insertBefore(R,a4);R[aE](a4);a6=R;}a6.setAttributeNS(aZ.paper.xlink,a3,a1);break;case"cursor":a4.style.cursor=a1;break;case"clip-rect":var i=(a1+am)[w](a);if(i[l]==4){aZ.clip&&aZ.clip.parentNode.parentNode.removeChild(aZ.clip.parentNode);var E=aC("clipPath"),a5=aC("rect");E.id="r"+(ai._id++)[at](36);aC(a5,{x:i[0],y:i[1],width:i[2],height:i[3]});E[aE](a5);aZ.paper.defs[aE](E);aC(a4,{"clip-path":"url(#"+E.id+")"});aZ.clip=a5;}if(!a1){var a7=G.getElementById(a4.getAttribute("clip-path")[aI](/(^url\(#|\)$)/g,am));a7&&a7.parentNode.removeChild(a7);aC(a4,{"clip-path":am});delete aZ.clip;}break;case"path":if(a1&&aZ.type=="path"){a0.path=O(p(a1));aC(a4,{d:a0.path});}break;case"width":a4[s](a3,a1);if(a0.fx){a3="x";a1=a0.x;}else{break;}case"x":if(a0.fx){a1=-a0.x-(a0.width||0);}case"rx":if(a3=="rx"&&aZ.type=="rect"){break;}case"cx":aV&&(a3=="x"||a3=="cx")&&(aV[1]+=a1-a0[a3]);a4[s](a3,J(a1));aZ.pattern&&I(aZ);break;case"height":a4[s](a3,a1);if(a0.fy){a3="y";a1=a0.y;}else{break;}case"y":if(a0.fy){a1=-a0.y-(a0.height||0);}case"ry":if(a3=="ry"&&aZ.type=="rect"){break;}case"cy":aV&&(a3=="y"||a3=="cy")&&(aV[2]+=a1-a0[a3]);a4[s](a3,J(a1));aZ.pattern&&I(aZ);break;case"r":if(aZ.type=="rect"){aC(a4,{rx:a1,ry:a1});}else{a4[s](a3,a1);}break;case"src":if(aZ.type=="image"){a4.setAttributeNS(aZ.paper.xlink,"href",a1);}break;case"stroke-width":a4.style.strokeWidth=a1;a4[s](a3,a1);if(a0["stroke-dasharray"]){aS(aZ,a0["stroke-dasharray"]);}break;case"stroke-dasharray":aS(aZ,a1);break;case"translation":var aT=(a1+am)[w](a);aT[0]=+aT[0]||0;aT[1]=+aT[1]||0;if(aV){aV[1]+=aT[0];aV[2]+=aT[1];}q.call(aZ,aT[0],aT[1]);break;case"scale":var aT=(a1+am)[w](a);aZ.scale(+aT[0]||1,+aT[1]||+aT[0]||1,+aT[2]||null,+aT[3]||null);break;case"fill":var S=(a1+am).match(c);if(S){var E=aC("pattern"),aY=aC("image");E.id="r"+(ai._id++)[at](36);aC(E,{x:0,y:0,patternUnits:"userSpaceOnUse",height:1,width:1});aC(aY,{x:0,y:0});aY.setAttributeNS(aZ.paper.xlink,"href",S[1]);E[aE](aY);var a9=G.createElement("img");a9.style.cssText="position:absolute;left:-9999em;top-9999em";a9.onload=function(){aC(E,{width:this.offsetWidth,height:this.offsetHeight});aC(aY,{width:this.offsetWidth,height:this.offsetHeight});G.body.removeChild(this);aJ.safari();};G.body[aE](a9);a9.src=S[1];aZ.paper.defs[aE](E);a4.style.fill="url(#"+E.id+")";aC(a4,{fill:"url(#"+E.id+")"});aZ.pattern=E;aZ.pattern&&I(aZ);break;}if(!ai.getRGB(a1).error){delete a8.gradient;delete a0.gradient;!ai.is(a0.opacity,"undefined")&&ai.is(a8.opacity,"undefined")&&aC(a4,{opacity:a0.opacity});!ai.is(a0["fill-opacity"],"undefined")&&ai.is(a8["fill-opacity"],"undefined")&&aC(a4,{"fill-opacity":a0["fill-opacity"]});}else{if((({circle:1,ellipse:1})[L](aZ.type)||(a1+am).charAt()!="r")&&b(a4,a1,aZ.paper)){a0.gradient=a1;a0.fill="none";break;}}case"stroke":a4[s](a3,ai.getRGB(a1).hex);break;case"gradient":(({circle:1,ellipse:1})[L](aZ.type)||(a1+am).charAt()!="r")&&b(a4,a1,aZ.paper);break;case"opacity":case"fill-opacity":if(a0.gradient){var e=G.getElementById(a4.getAttribute("fill")[aI](/^url\(#|\)$/g,am));if(e){var aU=e.getElementsByTagName("stop");aU[aU[l]-1][s]("stop-opacity",a1);}break;}default:a3=="font-size"&&(a1=B(a1,10)+"px");var aX=a3[aI](/(\-.)/g,function(ba){return aG.call(ba.substring(1));});a4.style[aX]=a1;a4[s](a3,a1);break;}}}z(aZ,a8);if(aV){aZ.rotate(aV.join(ah));}else{P(aW)&&aZ.rotate(aW,true);}};var g=1.2;var z=function(e,S){if(e.type!="text"||!(S[L]("text")||S[L]("font")||S[L]("font-size")||S[L]("x")||S[L]("y"))){return;}var aW=e.attrs,E=e.node,aY=E.firstChild?B(G.defaultView.getComputedStyle(E.firstChild,am).getPropertyValue("font-size"),10):10;if(S[L]("text")){aW.text=S.text;while(E.firstChild){E.removeChild(E.firstChild);}var R=(S.text+am)[w]("\n");for(var aS=0,aX=R[l];aS<aX;aS++){if(R[aS]){var aU=aC("tspan");aS&&aC(aU,{dy:aY*g,x:aW.x});aU[aE](G.createTextNode(R[aS]));E[aE](aU);}}}else{var R=E.getElementsByTagName("tspan");for(var aS=0,aX=R[l];aS<aX;aS++){aS&&aC(R[aS],{dy:aY*g,x:aW.x});}}aC(E,{y:aW.y});var aT=e.getBBox(),aV=aW.y-(aT.y+aT.height/2);aV&&isFinite(aV)&&aC(E,{y:aW.y+aV});};var aq=function(i,e){var R=0,E=0;this[0]=i;this.id=ai._oid++;this.node=i;i.raphael=this;this.paper=e;this.attrs=this.attrs||{};this.transformations=[];this._={tx:0,ty:0,rt:{deg:0,cx:0,cy:0},sx:1,sy:1};!e.bottom&&(e.bottom=this);this.prev=e.top;e.top&&(e.top.next=this);e.top=this;this.next=null;};aq[aQ].rotate=function(i,e,R){if(this.removed){return this;}if(i==null){if(this._.rt.cx){return[this._.rt.deg,this._.rt.cx,this._.rt.cy][ar](ah);}return this._.rt.deg;}var E=this.getBBox();i=(i+am)[w](a);if(i[l]-1){e=P(i[1]);R=P(i[2]);}i=P(i[0]);if(e!=null){this._.rt.deg=i;}else{this._.rt.deg+=i;}(R==null)&&(e=null);this._.rt.cx=e;this._.rt.cy=R;e=e==null?E.x+E.width/2:e;R=R==null?E.y+E.height/2:R;if(this._.rt.deg){this.transformations[0]=ai.format("rotate({0} {1} {2})",this._.rt.deg,e,R);this.clip&&aC(this.clip,{transform:ai.format("rotate({0} {1} {2})",-this._.rt.deg,e,R)});}else{this.transformations[0]=am;this.clip&&aC(this.clip,{transform:am});}aC(this.node,{transform:this.transformations[ar](ah)});return this;};aq[aQ].hide=function(){!this.removed&&(this.node.style.display="none");return this;};aq[aQ].show=function(){!this.removed&&(this.node.style.display="");return this;};aq[aQ].remove=function(){if(this.removed){return;}af(this,this.paper);this.node.parentNode.removeChild(this.node);for(var e in this){delete this[e];}this.removed=true;};aq[aQ].getBBox=function(){if(this.removed){return this;}if(this.type=="path"){return N(this.attrs.path);}if(this.node.style.display=="none"){this.show();var R=true;}var aU={};try{aU=this.node.getBBox();}catch(aS){}finally{aU=aU||{};}if(this.type=="text"){aU={x:aU.x,y:Infinity,width:0,height:0};for(var E=0,S=this.node.getNumberOfChars();E<S;E++){var aT=this.node.getExtentOfChar(E);(aT.y<aU.y)&&(aU.y=aT.y);(aT.y+aT.height-aU.y>aU.height)&&(aU.height=aT.y+aT.height-aU.y);(aT.x+aT.width-aU.x>aU.width)&&(aU.width=aT.x+aT.width-aU.x);}}R&&this.hide();return aU;};aq[aQ].attr=function(){if(this.removed){return this;}if(arguments[l]==0){var S={};for(var R in this.attrs){if(this.attrs[L](R)){S[R]=this.attrs[R];}}this._.rt.deg&&(S.rotation=this.rotate());(this._.sx!=1||this._.sy!=1)&&(S.scale=this.scale());delete S.translation;S.gradient&&S.fill=="none"&&(S.fill=S.gradient)&&delete S.gradient;return S;}if(arguments[l]==1&&ai.is(arguments[0],"string")){if(arguments[0]=="translation"){return q.call(this);}if(arguments[0]=="rotation"){return this.rotate();}if(arguments[0]=="scale"){return this.scale();}if(arguments[0]=="fill"&&this.attrs.fill=="none"&&this.attrs.gradient){return this.attrs.gradient;}return this.attrs[arguments[0]];}if(arguments[l]==1&&ai.is(arguments[0],"array")){var e={};for(var E in arguments[0]){if(arguments[0][L](E)){e[arguments[0][E]]=this.attrs[arguments[0][E]];}}return e;}if(arguments[l]==2){var aS={};aS[arguments[0]]=arguments[1];V(this,aS);}else{if(arguments[l]==1&&ai.is(arguments[0],"object")){V(this,arguments[0]);}}return this;};aq[aQ].toFront=function(){if(this.removed){return this;}this.node.parentNode[aE](this.node);var e=this.paper;e.top!=this&&T(this,e);return this;};aq[aQ].toBack=function(){if(this.removed){return this;}if(this.node.parentNode.firstChild!=this.node){this.node.parentNode.insertBefore(this.node,this.node.parentNode.firstChild);j(this,this.paper);var e=this.paper;}return this;};aq[aQ].insertAfter=function(i){if(this.removed){return this;}var e=this.paper,E=i.node;if(E.nextSibling){E.parentNode.insertBefore(this.node,E.nextSibling);}else{E.parentNode[aE](this.node);}x(this,i,this.paper);return this;};aq[aQ].insertBefore=function(e){if(this.removed){return this;}var i=e.node;i.parentNode.insertBefore(this.node,i);ak(this,e,this.paper);return this;};var K=function(i,e,aS,S){e=J(e);aS=J(aS);var R=aC("circle");i.canvas&&i.canvas[aE](R);var E=new aq(R,i);E.attrs={cx:e,cy:aS,r:S,fill:"none",stroke:"#000"};E.type="circle";aC(R,E.attrs);return E;};var ay=function(E,e,aU,i,aS,aT){e=J(e);aU=J(aU);var S=aC("rect");E.canvas&&E.canvas[aE](S);var R=new aq(S,E);R.attrs={x:e,y:aU,width:i,height:aS,r:aT||0,rx:aT||0,ry:aT||0,fill:"none",stroke:"#000"};R.type="rect";aC(S,R.attrs);return R;};var ac=function(i,e,aT,aS,S){e=J(e);aT=J(aT);var R=aC("ellipse");i.canvas&&i.canvas[aE](R);var E=new aq(R,i);E.attrs={cx:e,cy:aT,rx:aS,ry:S,fill:"none",stroke:"#000"};E.type="ellipse";aC(R,E.attrs);return E;};var m=function(E,aT,e,aU,i,aS){var S=aC("image");aC(S,{x:e,y:aU,width:i,height:aS,preserveAspectRatio:"none"});S.setAttributeNS(E.xlink,"href",aT);E.canvas&&E.canvas[aE](S);var R=new aq(S,E);R.attrs={x:e,y:aU,width:i,height:aS,src:aT};R.type="image";return R;};var Q=function(i,e,aS,S){var R=aC("text");aC(R,{x:e,y:aS,"text-anchor":"middle"});i.canvas&&i.canvas[aE](R);var E=new aq(R,i);E.attrs={x:e,y:aS,"text-anchor":"middle",text:S,font:h.font,stroke:"none",fill:"#000"};E.type="text";V(E,E.attrs);return E;};var aN=function(i,e){this.width=i||this.width;this.height=e||this.height;this.canvas[s]("width",this.width);this.canvas[s]("height",this.height);return this;};var t=function(){var R=aj[aO](null,arguments),E=R&&R.container,i=R.x,aU=R.y,S=R.width,e=R.height;if(!E){throw new Error("SVG container not found.");}aJ.canvas=aC("svg");var aT=aJ.canvas;aJ.width=S||512;aJ.height=e||342;aC(aT,{xmlns:"http://www.w3.org/2000/svg",version:1.1,width:aJ.width,height:aJ.height});if(E==1){aT.style.cssText="position:absolute;left:"+i+"px;top:"+aU+"px";G.body[aE](aT);}else{if(E.firstChild){E.insertBefore(aT,E.firstChild);}else{E[aE](aT);}}E={canvas:aT};for(var aS in aJ){if(aJ[L](aS)){E[aS]=aJ[aS];}}E.bottom=E.top=null;az.call(E,E,ai.fn);E.clear();E.raphael=ai;return E;};aJ.clear=function(){var e=this.canvas;while(e.firstChild){e.removeChild(e.firstChild);}this.bottom=this.top=null;(this.desc=aC("desc"))[aE](G.createTextNode("Created with Rapha\xebl"));e[aE](this.desc);e[aE](this.defs=aC("defs"));};aJ.remove=function(){this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas);for(var e in this){delete this[e];}};}if(ai.vml){var aA=function(a1){var aY=/[ahqtv]/ig,aT=p;(a1+am).match(aY)&&(aT=C);aY=/[clmz]/g;if(aT==p&&!(a1+am).match(aY)){var E={M:"m",L:"l",C:"c",Z:"x",m:"t",l:"r",c:"v",z:"x"},S=/([clmz]),?([^clmz]*)/gi,aS=/-?[^,\s-]+/g;var aX=(a1+am)[aI](S,function(a2,a4,i){var a3=[];i[aI](aS,function(a5){a3[d](J(a5));});return E[a4]+a3;});return aX;}var aZ=aT(a1),R,aX=[],e;for(var aV=0,a0=aZ[l];aV<a0;aV++){R=aZ[aV];e=aR.call(aZ[aV][0]);e=="z"&&(e="x");for(var aU=1,aW=R[l];aU<aW;aU++){e+=J(R[aU])+(aU!=aW-1?",":am);}aX[d](e);}return aX[ar](ah);};ai[at]=function(){return"Your browser doesn\u2019t support SVG. Falling down to VML.\nYou are running Rapha\xebl "+this.version;};var o=function(e,aS){var R=ab("group");R.style.cssText="position:absolute;left:0;top:0;width:"+aS.width+"px;height:"+aS.height+"px";R.coordsize=aS.coordsize;R.coordorigin=aS.coordorigin;var E=ab("shape"),i=E.style;i.width=aS.width+"px";i.height=aS.height+"px";E.coordsize=this.coordsize;E.coordorigin=this.coordorigin;R[aE](E);var S=new aq(E,R,aS);S.isAbsolute=true;S.type="path";S.path=[];S.Path=am;e&&V(S,{fill:"none",stroke:"#000",path:e});aS.canvas[aE](R);return S;};var V=function(aW,a1){aW.attrs=aW.attrs||{};var aZ=aW.node,a2=aW.attrs,aT=aZ.style,R,a6=aW;for(var aU in a1){if(a1[L](aU)){a2[aU]=a1[aU];}}a1.href&&(aZ.href=a1.href);a1.title&&(aZ.title=a1.title);a1.target&&(aZ.target=a1.target);a1.cursor&&(aT.cursor=a1.cursor);if(a1.path&&aW.type=="path"){a2.path=a1.path;aZ.path=aA(a2.path);}if(a1.rotation!=null){aW.rotate(a1.rotation,true);}if(a1.translation){R=(a1.translation+am)[w](a);q.call(aW,R[0],R[1]);if(aW._.rt.cx!=null){aW._.rt.cx+=+R[0];aW._.rt.cy+=+R[1];aW.setBox(aW.attrs,R[0],R[1]);}}if(a1.scale){R=(a1.scale+am)[w](a);aW.scale(+R[0]||1,+R[1]||+R[0]||1,+R[2]||null,+R[3]||null);}if("clip-rect" in a1){var e=(a1["clip-rect"]+am)[w](a);if(e[l]==4){e[2]=+e[2]+(+e[0]);e[3]=+e[3]+(+e[1]);var aV=aZ.clipRect||G.createElement("div"),a5=aV.style,aS=aZ.parentNode;a5.clip=ai.format("rect({1}px {2}px {3}px {0}px)",e);if(!aZ.clipRect){a5.position="absolute";a5.top=0;a5.left=0;a5.width=aW.paper.width+"px";a5.height=aW.paper.height+"px";aS.parentNode.insertBefore(aV,aS);aV[aE](aS);aZ.clipRect=aV;}}if(!a1["clip-rect"]){aZ.clipRect&&(aZ.clipRect.style.clip=am);}}if(aW.type=="image"&&a1.src){aZ.src=a1.src;}if(aW.type=="image"&&a1.opacity){aZ.filterOpacity=" progid:DXImageTransform.Microsoft.Alpha(opacity="+(a1.opacity*100)+")";aT.filter=(aZ.filterMatrix||am)+(aZ.filterOpacity||am);}a1.font&&(aT.font=a1.font);a1["font-family"]&&(aT.fontFamily='"'+a1["font-family"][w](",")[0][aI](/^['"]+|['"]+$/g,am)+'"');a1["font-size"]&&(aT.fontSize=a1["font-size"]);a1["font-weight"]&&(aT.fontWeight=a1["font-weight"]);a1["font-style"]&&(aT.fontStyle=a1["font-style"]);if(a1.opacity!=null||a1["stroke-width"]!=null||a1.fill!=null||a1.stroke!=null||a1["stroke-width"]!=null||a1["stroke-opacity"]!=null||a1["fill-opacity"]!=null||a1["stroke-dasharray"]!=null||a1["stroke-miterlimit"]!=null||a1["stroke-linejoin"]!=null||a1["stroke-linecap"]!=null){aZ=aW.shape||aZ;var a0=(aZ.getElementsByTagName("fill")&&aZ.getElementsByTagName("fill")[0]),a3=false;!a0&&(a3=a0=ab("fill"));if("fill-opacity" in a1||"opacity" in a1){var i=((+a2["fill-opacity"]+1||2)-1)*((+a2.opacity+1||2)-1);i<0&&(i=0);i>1&&(i=1);a0.opacity=i;}a1.fill&&(a0.on=true);if(a0.on==null||a1.fill=="none"){a0.on=false;}if(a0.on&&a1.fill){var E=a1.fill.match(c);if(E){a0.src=E[1];a0.type="tile";}else{a0.color=ai.getRGB(a1.fill).hex;a0.src=am;a0.type="solid";if(ai.getRGB(a1.fill).error&&(a6.type in {circle:1,ellipse:1}||(a1.fill+am).charAt()!="r")&&b(a6,a1.fill)){a2.fill="none";a2.gradient=a1.fill;}}}a3&&aZ[aE](a0);var S=(aZ.getElementsByTagName("stroke")&&aZ.getElementsByTagName("stroke")[0]),a4=false;!S&&(a4=S=ab("stroke"));if((a1.stroke&&a1.stroke!="none")||a1["stroke-width"]||a1["stroke-opacity"]!=null||a1["stroke-dasharray"]||a1["stroke-miterlimit"]||a1["stroke-linejoin"]||a1["stroke-linecap"]){S.on=true;}(a1.stroke=="none"||S.on==null||a1.stroke==0||a1["stroke-width"]==0)&&(S.on=false);S.on&&a1.stroke&&(S.color=ai.getRGB(a1.stroke).hex);var i=((+a2["stroke-opacity"]+1||2)-1)*((+a2.opacity+1||2)-1),aX=(P(a1["stroke-width"])||1)*0.75;i<0&&(i=0);i>1&&(i=1);a1["stroke-width"]==null&&(aX=a2["stroke-width"]);a1["stroke-width"]&&(S.weight=aX);aX&&aX<1&&(i*=aX)&&(S.weight=1);S.opacity=i;a1["stroke-linejoin"]&&(S.joinstyle=a1["stroke-linejoin"]||"miter");S.miterlimit=a1["stroke-miterlimit"]||8;a1["stroke-linecap"]&&(S.endcap=a1["stroke-linecap"]=="butt"?"flat":a1["stroke-linecap"]=="square"?"square":"round");if(a1["stroke-dasharray"]){var aY={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};S.dashstyle=aY[L](a1["stroke-dasharray"])?aY[a1["stroke-dasharray"]]:am;}a4&&aZ[aE](S);}if(a6.type=="text"){var aT=a6.paper.span.style;a2.font&&(aT.font=a2.font);a2["font-family"]&&(aT.fontFamily=a2["font-family"]);a2["font-size"]&&(aT.fontSize=a2["font-size"]);a2["font-weight"]&&(aT.fontWeight=a2["font-weight"]);a2["font-style"]&&(aT.fontStyle=a2["font-style"]);a6.node.string&&(a6.paper.span.innerHTML=(a6.node.string+am)[aI](/</g,"&#60;")[aI](/&/g,"&#38;")[aI](/\n/g,"<br>"));a6.W=a2.w=a6.paper.span.offsetWidth;a6.H=a2.h=a6.paper.span.offsetHeight;a6.X=a2.x;a6.Y=a2.y+J(a6.H/2);switch(a2["text-anchor"]){case"start":a6.node.style["v-text-align"]="left";a6.bbx=J(a6.W/2);break;case"end":a6.node.style["v-text-align"]="right";a6.bbx=-J(a6.W/2);break;default:a6.node.style["v-text-align"]="center";break;}}};var b=function(e,aU){e.attrs=e.attrs||{};var aV=e.attrs,aX=e.node.getElementsByTagName("fill"),aS="linear",aT=".5 .5";e.attrs.gradient=aU;aU=(aU+am)[aI](al,function(aZ,a0,i){aS="radial";if(a0&&i){a0=P(a0);i=P(i);aF(a0-0.5,2)+aF(i-0.5,2)>0.25&&(i=W.sqrt(0.25-aF(a0-0.5,2))*((i>0.5)*2-1)+0.5);aT=a0+ah+i;}return am;});aU=aU[w](/\s*\-\s*/);if(aS=="linear"){var E=aU.shift();E=-P(E);if(isNaN(E)){return null;}}var S=n(aU);if(!S){return null;}e=e.shape||e.node;aX=aX[0]||ab("fill");if(S[l]){aX.on=true;aX.method="none";aX.type=(aS=="radial")?"gradientradial":"gradient";aX.color=S[0].color;aX.color2=S[S[l]-1].color;var aY=[];for(var R=0,aW=S[l];R<aW;R++){S[R].offset&&aY[d](S[R].offset+ah+S[R].color);}aX.colors&&(aX.colors.value=aY[l]?aY[ar](","):"0% "+aX.color);if(aS=="radial"){aX.focus="100%";aX.focussize=aT;aX.focusposition=aT;}else{aX.angle=(270-E)%360;}}return 1;};var aq=function(S,aT,e){var aS=0,E=0,i=0,R=1;this[0]=S;this.id=ai._oid++;this.node=S;S.raphael=this;this.X=0;this.Y=0;this.attrs={};this.Group=aT;this.paper=e;this._={tx:0,ty:0,rt:{deg:0},sx:1,sy:1};!e.bottom&&(e.bottom=this);this.prev=e.top;e.top&&(e.top.next=this);e.top=this;this.next=null;};aq[aQ].rotate=function(i,e,E){if(this.removed){return this;}if(i==null){if(this._.rt.cx){return[this._.rt.deg,this._.rt.cx,this._.rt.cy][ar](ah);}return this._.rt.deg;}i=(i+am)[w](a);if(i[l]-1){e=P(i[1]);E=P(i[2]);}i=P(i[0]);if(e!=null){this._.rt.deg=i;}else{this._.rt.deg+=i;}E==null&&(e=null);this._.rt.cx=e;this._.rt.cy=E;this.setBox(this.attrs,e,E);this.Group.style.rotation=this._.rt.deg;return this;};aq[aQ].setBox=function(a4,E,e){if(this.removed){return this;}var aY=this.Group.style,S=(this.shape&&this.shape.style)||this.node.style;a4=a4||{};for(var a2 in a4){if(a4[L](a2)){this.attrs[a2]=a4[a2];}}E=E||this._.rt.cx;e=e||this._.rt.cy;var a0=this.attrs,aU,aT,aV,a3;switch(this.type){case"circle":aU=a0.cx-a0.r;aT=a0.cy-a0.r;aV=a3=a0.r*2;break;case"ellipse":aU=a0.cx-a0.rx;aT=a0.cy-a0.ry;aV=a0.rx*2;a3=a0.ry*2;break;case"rect":case"image":aU=+a0.x;aT=+a0.y;aV=a0.width||0;a3=a0.height||0;break;case"text":this.textpath.v=["m",J(a0.x),", ",J(a0.y-2),"l",J(a0.x)+1,", ",J(a0.y-2)][ar](am);aU=a0.x-J(this.W/2);aT=a0.y-this.H/2;aV=this.W;a3=this.H;break;case"path":if(!this.attrs.path){aU=0;aT=0;aV=this.paper.width;a3=this.paper.height;}else{var a1=N(this.attrs.path);aU=a1.x;aT=a1.y;aV=a1.width;a3=a1.height;}break;default:aU=0;aT=0;aV=this.paper.width;a3=this.paper.height;break;}E=(E==null)?aU+aV/2:E;e=(e==null)?aT+a3/2:e;var R=E-this.paper.width/2,aX=e-this.paper.height/2;if(this.type=="path"||this.type=="text"){(aY.left!=R+"px")&&(aY.left=R+"px");(aY.top!=aX+"px")&&(aY.top=aX+"px");this.X=this.type=="text"?aU:-R;this.Y=this.type=="text"?aT:-aX;this.W=aV;this.H=a3;(S.left!=-R+"px")&&(S.left=-R+"px");(S.top!=-aX+"px")&&(S.top=-aX+"px");}else{(aY.left!=R+"px")&&(aY.left=R+"px");(aY.top!=aX+"px")&&(aY.top=aX+"px");this.X=aU;this.Y=aT;this.W=aV;this.H=a3;(aY.width!=this.paper.width+"px")&&(aY.width=this.paper.width+"px");(aY.height!=this.paper.height+"px")&&(aY.height=this.paper.height+"px");(S.left!=aU-R+"px")&&(S.left=aU-R+"px");(S.top!=aT-aX+"px")&&(S.top=aT-aX+"px");(S.width!=aV+"px")&&(S.width=aV+"px");(S.height!=a3+"px")&&(S.height=a3+"px");var aS=(+a4.r||0)/aB(aV,a3);if(this.type=="rect"&&this.arcsize.toFixed(4)!=aS.toFixed(4)&&(aS||this.arcsize)){var aZ=ab("roundrect"),a5={},a2=0,aW=this.events&&this.events[l];aZ.arcsize=aS;aZ.raphael=this;this.Group[aE](aZ);this.Group.removeChild(this.node);this[0]=this.node=aZ;this.arcsize=aS;for(var a2 in a0){a5[a2]=a0[a2];}delete a5.scale;this.attr(a5);if(this.events){for(;a2<aW;a2++){this.events[a2].unbind=Z(this.node,this.events[a2].name,this.events[a2].f,this);}}}}};aq[aQ].hide=function(){!this.removed&&(this.Group.style.display="none");return this;};aq[aQ].show=function(){!this.removed&&(this.Group.style.display="block");return this;};aq[aQ].getBBox=function(){if(this.removed){return this;}if(this.type=="path"){return N(this.attrs.path);}return{x:this.X+(this.bbx||0),y:this.Y,width:this.W,height:this.H};};aq[aQ].remove=function(){if(this.removed){return;}af(this,this.paper);this.node.parentNode.removeChild(this.node);this.Group.parentNode.removeChild(this.Group);this.shape&&this.shape.parentNode.removeChild(this.shape);for(var e in this){delete this[e];}this.removed=true;};aq[aQ].attr=function(){if(this.removed){return this;}if(arguments[l]==0){var R={};for(var E in this.attrs){if(this.attrs[L](E)){R[E]=this.attrs[E];}}this._.rt.deg&&(R.rotation=this.rotate());(this._.sx!=1||this._.sy!=1)&&(R.scale=this.scale());delete R.translation;R.gradient&&R.fill=="none"&&(R.fill=R.gradient)&&delete R.gradient;return R;}if(arguments[l]==1&&ai.is(arguments[0],"string")){if(arguments[0]=="translation"){return q.call(this);}if(arguments[0]=="rotation"){return this.rotate();}if(arguments[0]=="scale"){return this.scale();}if(arguments[0]=="fill"&&this.attrs.fill=="none"&&this.attrs.gradient){return this.attrs.gradient;}return this.attrs[arguments[0]];}if(this.attrs&&arguments[l]==1&&ai.is(arguments[0],"array")){var e={};for(var E=0,S=arguments[0][l];E<S;E++){e[arguments[0][E]]=this.attrs[arguments[0][E]];}return e;}var aS;if(arguments[l]==2){aS={};aS[arguments[0]]=arguments[1];}arguments[l]==1&&ai.is(arguments[0],"object")&&(aS=arguments[0]);if(aS){if(aS.text&&this.type=="text"){this.node.string=aS.text;}V(this,aS);if(aS.gradient&&(({circle:1,ellipse:1})[L](this.type)||(aS.gradient+am).charAt()!="r")){b(this,aS.gradient);}(this.type!="path"||this._.rt.deg)&&this.setBox(this.attrs);}return this;};aq[aQ].toFront=function(){!this.removed&&this.Group.parentNode[aE](this.Group);this.paper.top!=this&&T(this,this.paper);return this;};aq[aQ].toBack=function(){if(this.removed){return this;}if(this.Group.parentNode.firstChild!=this.Group){this.Group.parentNode.insertBefore(this.Group,this.Group.parentNode.firstChild);j(this,this.paper);}return this;};aq[aQ].insertAfter=function(e){if(this.removed){return this;}if(e.Group.nextSibling){e.Group.parentNode.insertBefore(this.Group,e.Group.nextSibling);}else{e.Group.parentNode[aE](this.Group);}x(this,e,this.paper);return this;};aq[aQ].insertBefore=function(e){if(this.removed){return this;}e.Group.parentNode.insertBefore(this.Group,e.Group);ak(this,e,this.paper);return this;};var K=function(i,e,aU,aS){var S=ab("group"),aT=ab("oval"),E=aT.style;S.style.cssText="position:absolute;left:0;top:0;width:"+i.width+"px;height:"+i.height+"px";S.coordsize=i.coordsize;S.coordorigin=i.coordorigin;S[aE](aT);var R=new aq(aT,S,i);R.type="circle";V(R,{stroke:"#000",fill:"none"});R.attrs.cx=e;R.attrs.cy=aU;R.attrs.r=aS;R.setBox({x:e-aS,y:aU-aS,width:aS*2,height:aS*2});i.canvas[aE](S);return R;};var ay=function(i,aU,aT,aV,R,e){var S=ab("group"),E=ab("roundrect"),aW=(+e||0)/(aB(aV,R));S.style.cssText="position:absolute;left:0;top:0;width:"+i.width+"px;height:"+i.height+"px";S.coordsize=i.coordsize;S.coordorigin=i.coordorigin;S[aE](E);E.arcsize=aW;var aS=new aq(E,S,i);aS.type="rect";V(aS,{stroke:"#000"});aS.arcsize=aW;aS.setBox({x:aU,y:aT,width:aV,height:R,r:e});i.canvas[aE](S);return aS;};var ac=function(e,aV,aU,E,i){var S=ab("group"),R=ab("oval"),aT=R.style;S.style.cssText="position:absolute;left:0;top:0;width:"+e.width+"px;height:"+e.height+"px";S.coordsize=e.coordsize;S.coordorigin=e.coordorigin;S[aE](R);var aS=new aq(R,S,e);aS.type="ellipse";V(aS,{stroke:"#000"});aS.attrs.cx=aV;aS.attrs.cy=aU;aS.attrs.rx=E;aS.attrs.ry=i;aS.setBox({x:aV-E,y:aU-i,width:E*2,height:i*2});e.canvas[aE](S);return aS;};var m=function(i,e,aV,aU,aW,R){var S=ab("group"),E=ab("image"),aT=E.style;S.style.cssText="position:absolute;left:0;top:0;width:"+i.width+"px;height:"+i.height+"px";S.coordsize=i.coordsize;S.coordorigin=i.coordorigin;E.src=e;S[aE](E);var aS=new aq(E,S,i);aS.type="image";aS.attrs.src=e;aS.attrs.x=aV;aS.attrs.y=aU;aS.attrs.w=aW;aS.attrs.h=R;aS.setBox({x:aV,y:aU,width:aW,height:R});i.canvas[aE](S);return aS;};var Q=function(i,aV,aU,aW){var S=ab("group"),R=ab("shape"),aT=R.style,aX=ab("path"),e=aX.style,E=ab("textpath");S.style.cssText="position:absolute;left:0;top:0;width:"+i.width+"px;height:"+i.height+"px";S.coordsize=i.coordsize;S.coordorigin=i.coordorigin;aX.v=ai.format("m{0},{1}l{2},{1}",J(aV),J(aU),J(aV)+1);aX.textpathok=true;aT.width=i.width;aT.height=i.height;E.string=aW+am;E.on=true;R[aE](E);R[aE](aX);S[aE](R);var aS=new aq(E,S,i);aS.shape=R;aS.textpath=aX;aS.type="text";aS.attrs.text=aW;aS.attrs.x=aV;aS.attrs.y=aU;aS.attrs.w=1;aS.attrs.h=1;V(aS,{font:h.font,stroke:"none",fill:"#000"});aS.setBox();i.canvas[aE](S);return aS;};var aN=function(E,e){var i=this.canvas.style;E==+E&&(E+="px");e==+e&&(e+="px");i.width=E;i.height=e;i.clip="rect(0 "+E+" "+e+" 0)";return this;};G.createStyleSheet().addRule(".rvml","behavior:url(#default#VML)");try{!G.namespaces.rvml&&G.namespaces.add("rvml","urn:schemas-microsoft-com:vml");var ab=function(e){return G.createElement("<rvml:"+e+' class="rvml">');};}catch(aa){var ab=function(e){return G.createElement("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">');};}var t=function(){var R=aj[aO](null,arguments),i=R.container,aW=R.height,aX,E=R.width,aV=R.x,aU=R.y;if(!i){throw new Error("VML container not found.");}var aS={},aT=aS.canvas=G.createElement("div"),S=aT.style;E=E||512;aW=aW||342;E==+E&&(E+="px");aW==+aW&&(aW+="px");aS.width=1000;aS.height=1000;aS.coordsize="1000 1000";aS.coordorigin="0 0";aS.span=G.createElement("span");aS.span.style.cssText="position:absolute;left:-9999px;top:-9999px;padding:0;margin:0;line-height:1;display:inline;";aT[aE](aS.span);S.cssText=ai.format("width:{0};height:{1};position:absolute;clip:rect(0 {0} {1} 0);overflow:hidden",E,aW);if(i==1){G.body[aE](aT);S.left=aV+"px";S.top=aU+"px";i={style:{width:E,height:aW}};}else{i.style.width=E;i.style.height=aW;if(i.firstChild){i.insertBefore(aT,i.firstChild);}else{i[aE](aT);}}for(var e in aJ){if(aJ[L](e)){aS[e]=aJ[e];}}az.call(aS,aS,ai.fn);aS.top=aS.bottom=null;aS.raphael=ai;return aS;};aJ.clear=function(){this.canvas.innerHTML=am;this.bottom=this.top=null;};aJ.remove=function(){this.canvas.parentNode.removeChild(this.canvas);for(var e in this){delete this[e];}};}if((/^Apple|^Google/).test(navigator.vendor)&&!(navigator.userAgent.indexOf("Version/4.0")+1)){aJ.safari=function(){var e=this.rect(-99,-99,this.width+99,this.height+99);setTimeout(function(){e.remove();});};}else{aJ.safari=function(){};}var Z=(function(){if(G.addEventListener){return function(S,E,i,e){var R=function(aS){return i.call(e,aS);};S.addEventListener(E,R,false);return function(){S.removeEventListener(E,R,false);return true;};};}else{if(G.attachEvent){return function(aS,R,E,i){var S=function(aT){return E.call(i,aT||an.event);};aS.attachEvent("on"+R,S);var e=function(){aS.detachEvent("on"+R,S);return true;};return e;};}}})();for(var X=A[l];X--;){(function(e){aq[aQ][e]=function(i){if(ai.is(i,"function")){this.events=this.events||[];this.events.push({name:e,f:i,unbind:Z(this.shape||this.node,e,i,this)});}return this;};aq[aQ]["un"+e]=function(R){var E=this.events,i=E[l];while(i--){if(E[i].name==e&&E[i].f==R){E[i].unbind();E.splice(i,1);!E.length&&delete this.events;return this;}}return this;};})(A[X]);}aq[aQ].hover=function(i,e){return this.mouseover(i).mouseout(e);};aq[aQ].unhover=function(i,e){return this.unmouseover(i).unmouseout(e);};aJ.circle=function(e,E,i){return K(this,e||0,E||0,i||0);};aJ.rect=function(e,S,i,E,R){return ay(this,e||0,S||0,i||0,E||0,R||0);};aJ.ellipse=function(e,R,E,i){return ac(this,e||0,R||0,E||0,i||0);};aJ.path=function(e){e&&!ai.is(e,"string")&&!ai.is(e[0],"array")&&(e+=am);return o(ai.format[aO](ai,arguments),this);};aJ.image=function(R,e,S,i,E){return m(this,R||"about:blank",e||0,S||0,i||0,E||0);};aJ.text=function(e,E,i){return Q(this,e||0,E||0,i||am);};aJ.set=function(e){arguments[l]>1&&(e=Array[aQ].splice.call(arguments,0,arguments[l]));return new M(e);};aJ.setSize=aN;function r(){return this.x+ah+this.y;}aq[aQ].scale=function(a2,a1,R,E){if(a2==null&&a1==null){return{x:this._.sx,y:this._.sy,toString:r};}a1=a1||a2;!+a1&&(a1=a2);var a6,a4,a5,a3,bi=this.attrs;if(a2!=0){var aZ=this.getBBox(),aW=aZ.x+aZ.width/2,aS=aZ.y+aZ.height/2,bh=a2/this._.sx,bg=a1/this._.sy;R=(+R||R==0)?R:aW;E=(+E||E==0)?E:aS;var aY=~~(a2/W.abs(a2)),aV=~~(a1/W.abs(a1)),a9=this.node.style,bk=R+(aW-R)*bh,bj=E+(aS-E)*bg;switch(this.type){case"rect":case"image":var aX=bi.width*aY*bh,a8=bi.height*aV*bg,a0=bi.r*aB(bh,bg),aU=bk-aX/2,S=bj-a8/2;this.attr({height:a8,r:a0,width:aX,x:aU,y:S});break;case"circle":case"ellipse":this.attr({rx:bi.rx*aY*bh,ry:bi.ry*aV*bg,r:bi.r*aB(aY*bh,aV*bg),cx:bk,cy:bj});break;case"path":var bc=Y(bi.path),bd=true;for(var bf=0,a7=bc[l];bf<a7;bf++){var ba=bc[bf],be,aT=aG.call(ba[0]);if(aT=="M"&&bd){continue;}else{bd=false;}if(aT=="A"){ba[bc[bf][l]-2]*=bh;ba[bc[bf][l]-1]*=bg;ba[1]*=aY*bh;ba[2]*=aV*bg;ba[5]=+(aY+aV?!!+ba[5]:!+ba[5]);}else{if(aT=="H"){for(be=1,jj=ba[l];be<jj;be++){ba[be]*=bh;}}else{if(aT=="V"){for(be=1,jj=ba[l];be<jj;be++){ba[be]*=bg;}}else{for(be=1,jj=ba[l];be<jj;be++){ba[be]*=(be%2)?bh:bg;}}}}}var e=N(bc),a6=bk-e.x-e.width/2,a4=bj-e.y-e.height/2;bc[0][1]+=a6;bc[0][2]+=a4;this.attr({path:bc});break;}if(this.type in {text:1,image:1}&&(aY!=1||aV!=1)){if(this.transformations){this.transformations[2]="scale("[aL](aY,",",aV,")");this.node[s]("transform",this.transformations[ar](ah));a6=(aY==-1)?-bi.x-(aX||0):bi.x;a4=(aV==-1)?-bi.y-(a8||0):bi.y;this.attr({x:a6,y:a4});bi.fx=aY-1;bi.fy=aV-1;}else{this.node.filterMatrix=" progid:DXImageTransform.Microsoft.Matrix(M11="[aL](aY,", M12=0, M21=0, M22=",aV,", Dx=0, Dy=0, sizingmethod='auto expand', filtertype='bilinear')");a9.filter=(this.node.filterMatrix||am)+(this.node.filterOpacity||am);}}else{if(this.transformations){this.transformations[2]=am;this.node[s]("transform",this.transformations[ar](ah));bi.fx=0;bi.fy=0;}else{this.node.filterMatrix=am;a9.filter=(this.node.filterMatrix||am)+(this.node.filterOpacity||am);}}bi.scale=[a2,a1,R,E][ar](ah);this._.sx=a2;this._.sy=a1;}return this;};aq[aQ].clone=function(){return this.paper[this.type]().attr(this.attr());};ai.easing_formulas={linear:function(e){return e;},"<":function(e){return aF(e,3);},">":function(e){return aF(e-1,3)+1;},"<>":function(e){e=e*2;if(e<1){return aF(e,3)/2;}e-=2;return(aF(e,3)+2)/2;},backIn:function(i){var e=1.70158;return i*i*((e+1)*i-e);},backOut:function(i){i=i-1;var e=1.70158;return i*i*((e+1)*i+e)+1;},elastic:function(E){if(E==0||E==1){return E;}var i=0.3,e=i/4;return aF(2,-10*E)*W.sin((E-e)*(2*W.PI)/i)+1;},bounce:function(R){var i=7.5625,E=2.75,e;if(R<(1/E)){e=i*R*R;}else{if(R<(2/E)){R-=(1.5/E);e=i*R*R+0.75;}else{if(R<(2.5/E)){R-=(2.25/E);e=i*R*R+0.9375;}else{R-=(2.625/E);e=i*R*R+0.984375;}}}return e;}};var D={length:0},aK=function(){var aV=+new Date;for(var a6 in D){if(a6!="length"&&D[L](a6)){var bb=D[a6];if(bb.stop){delete D[a6];D[l]--;continue;}var aT=aV-bb.start,a4=bb.ms,a3=bb.easing,a7=bb.from,a0=bb.diff,R=bb.to,aZ=bb.t,a2=bb.prev||0,aU=bb.el,S=bb.callback,a1={},E;if(aT<a4){var aS=ai.easing_formulas[a3]?ai.easing_formulas[a3](aT/a4):aT/a4;for(var a5 in a7){if(a7[L](a5)){switch(U[a5]){case"number":E=+a7[a5]+aS*a4*a0[a5];break;case"colour":E="rgb("+[y(J(a7[a5].r+aS*a4*a0[a5].r)),y(J(a7[a5].g+aS*a4*a0[a5].g)),y(J(a7[a5].b+aS*a4*a0[a5].b))][ar](",")+")";break;case"path":E=[];for(var a9=0,aY=a7[a5][l];a9<aY;a9++){E[a9]=[a7[a5][a9][0]];for(var a8=1,ba=a7[a5][a9][l];a8<ba;a8++){E[a9][a8]=+a7[a5][a9][a8]+aS*a4*a0[a5][a9][a8];}E[a9]=E[a9][ar](ah);}E=E[ar](ah);break;case"csv":switch(a5){case"translation":var aX=a0[a5][0]*(aT-a2),aW=a0[a5][1]*(aT-a2);aZ.x+=aX;aZ.y+=aW;E=aX+ah+aW;break;case"rotation":E=+a7[a5][0]+aS*a4*a0[a5][0];a7[a5][1]&&(E+=","+a7[a5][1]+","+a7[a5][2]);break;case"scale":E=[+a7[a5][0]+aS*a4*a0[a5][0],+a7[a5][1]+aS*a4*a0[a5][1],(2 in R[a5]?R[a5][2]:am),(3 in R[a5]?R[a5][3]:am)][ar](ah);break;case"clip-rect":E=[];var a9=4;while(a9--){E[a9]=+a7[a5][a9]+aS*a4*a0[a5][a9];}break;}break;}a1[a5]=E;}}aU.attr(a1);aU._run&&aU._run.call(aU);}else{(aZ.x||aZ.y)&&aU.translate(-aZ.x,-aZ.y);R.scale&&(R.scale=R.scale+am);aU.attr(R);delete D[a6];D[l]--;aU.in_animation=null;ai.is(S,"function")&&S.call(aU);}bb.prev=aT;}}ai.svg&&aJ.safari();D[l]&&setTimeout(aK);},y=function(e){return e>255?255:(e<0?0:e);},q=function(e,E){if(e==null){return{x:this._.tx,y:this._.ty,toString:r};}this._.tx+=+e;this._.ty+=+E;switch(this.type){case"circle":case"ellipse":this.attr({cx:+e+this.attrs.cx,cy:+E+this.attrs.cy});break;case"rect":case"image":case"text":this.attr({x:+e+this.attrs.x,y:+E+this.attrs.y});break;case"path":var i=Y(this.attrs.path);i[0][1]+=+e;i[0][2]+=+E;this.attr({path:i});break;}return this;};aq[aQ].animateWith=function(i,E,e,S,R){D[i.id]&&(E.start=D[i.id].start);return this.animate(E,e,S,R);};aq[aQ].onAnimation=function(e){this._run=e||null;return this;};aq[aQ].animate=function(R,e,aX,a3){if(ai.is(aX,"function")||!aX){a3=aX||null;}var aY={},aZ={},a0={};for(var aW in R){if(R[L](aW)){if(U[L](aW)){aY[aW]=this.attr(aW);(aY[aW]==null)&&(aY[aW]=h[aW]);aZ[aW]=R[aW];switch(U[aW]){case"number":a0[aW]=(aZ[aW]-aY[aW])/e;break;case"colour":aY[aW]=ai.getRGB(aY[aW]);var aU=ai.getRGB(aZ[aW]);a0[aW]={r:(aU.r-aY[aW].r)/e,g:(aU.g-aY[aW].g)/e,b:(aU.b-aY[aW].b)/e};break;case"path":var E=C(aY[aW],aZ[aW]);aY[aW]=E[0];aZ[aW]=E[1];a0[aW]=[];for(var aT=0,a2=aY[aW][l];aT<a2;aT++){a0[aW][aT]=[0];for(var S=1,aV=aY[aW][aT][l];S<aV;S++){a0[aW][aT][S]=(aZ[aW][aT][S]-aY[aW][aT][S])/e;}}break;case"csv":var a1=(R[aW]+am)[w](a),aS=(aY[aW]+am)[w](a);switch(aW){case"translation":aY[aW]=[0,0];a0[aW]=[a1[0]/e,a1[1]/e];break;case"rotation":aY[aW]=(aS[1]==a1[1]&&aS[2]==a1[2])?aS:[0,a1[1],a1[2]];a0[aW]=[(a1[0]-aY[aW][0])/e,0,0];break;case"scale":R[aW]=a1;aY[aW]=(aY[aW]+am)[w](a);a0[aW]=[(a1[0]-aY[aW][0])/e,(a1[1]-aY[aW][1])/e,0,0];break;case"clip-rect":aY[aW]=(aY[aW]+am)[w](a);a0[aW]=[];var aT=4;while(aT--){a0[aW][aT]=(a1[aT]-aY[aW][aT])/e;}break;}aZ[aW]=a1;}}}}this.stop();this.in_animation=1;D[this.id]={start:R.start||+new Date,ms:e,easing:aX,from:aY,diff:a0,to:aZ,el:this,callback:a3,t:{x:0,y:0}};++D[l]==1&&aK();return this;};aq[aQ].stop=function(){D[this.id]&&D[l]--;delete D[this.id];return this;};aq[aQ].translate=function(e,i){return this.attr({translation:e+" "+i});};aq[aQ][at]=function(){return"Rapha\xebl\u2019s object";};ai.ae=D;var M=function(e){this.items=[];this[l]=0;if(e){for(var E=0,R=e[l];E<R;E++){if(e[E]&&(e[E].constructor==aq||e[E].constructor==M)){this[this.items[l]]=this.items[this.items[l]]=e[E];this[l]++;}}}};M[aQ][d]=function(){var S,e;for(var E=0,R=arguments[l];E<R;E++){S=arguments[E];if(S&&(S.constructor==aq||S.constructor==M)){e=this.items[l];this[e]=this.items[e]=S;this[l]++;}}return this;};M[aQ].pop=function(){delete this[this[l]--];return this.items.pop();};for(var v in aq[aQ]){if(aq[aQ][L](v)){M[aQ][v]=(function(e){return function(){for(var E=0,R=this.items[l];E<R;E++){this.items[E][e][aO](this.items[E],arguments);}return this;};})(v);}}M[aQ].attr=function(E,aT){if(E&&ai.is(E,"array")&&ai.is(E[0],"object")){for(var e=0,aS=E[l];e<aS;e++){this.items[e].attr(E[e]);}}else{for(var R=0,S=this.items[l];R<S;R++){this.items[R].attr[aO](this.items[R],arguments);}}return this;};M[aQ].animate=function(aS,E,aV,aU){(ai.is(aV,"function")||!aV)&&(aU=aV||null);var e=this.items[l],R=e,aT=this,S;aU&&(S=function(){!--e&&aU.call(aT);});this.items[--R].animate(aS,E,aV||S,S);while(R--){this.items[R].animateWith(this.items[e-1],aS,E,aV||S,S);}return this;};M[aQ].insertAfter=function(E){var e=this.items[l];while(e--){this.items[e].insertAfter(E);}return this;};M[aQ].getBBox=function(){var e=[],aT=[],E=[],S=[];for(var R=this.items[l];R--;){var aS=this.items[R].getBBox();e[d](aS.x);aT[d](aS.y);E[d](aS.x+aS.width);S[d](aS.y+aS.height);}e=aB[aO](0,e);aT=aB[aO](0,aT);return{x:e,y:aT,width:f[aO](0,E)-e,height:f[aO](0,S)-aT};};ai.registerFont=function(i){if(!i.face){return i;}this.fonts=this.fonts||{};var R={w:i.w,face:{},glyphs:{}},E=i.face["font-family"];for(var aT in i.face){if(i.face[L](aT)){R.face[aT]=i.face[aT];}}if(this.fonts[E]){this.fonts[E][d](R);}else{this.fonts[E]=[R];}if(!i.svg){R.face["units-per-em"]=B(i.face["units-per-em"],10);for(var S in i.glyphs){if(i.glyphs[L](S)){var aS=i.glyphs[S];R.glyphs[S]={w:aS.w,k:{},d:aS.d&&"M"+aS.d[aI](/[mlcxtrv]/g,function(aU){return{l:"L",c:"C",x:"z",t:"m",r:"l",v:"c"}[aU]||"M";})+"z"};if(aS.k){for(var e in aS.k){if(aS[L](e)){R.glyphs[S].k[e]=aS.k[e];}}}}}}return i;};aJ.getFont=function(aV,aW,E,S){S=S||"normal";E=E||"normal";aW=+aW||{normal:400,bold:700,lighter:300,bolder:800}[aW]||400;var aS=ai.fonts[aV];if(!aS){var R=new RegExp("(^|\\s)"+aV[aI](/[^\w\d\s+!~.:_-]/g,am)+"(\\s|$)","i");for(var e in ai.fonts){if(ai.fonts[L](e)){if(R.test(e)){aS=ai.fonts[e];break;}}}}var aT;if(aS){for(var aU=0,aX=aS[l];aU<aX;aU++){aT=aS[aU];if(aT.face["font-weight"]==aW&&(aT.face["font-style"]==E||!aT.face["font-style"])&&aT.face["font-stretch"]==S){break;}}}return aT;};aJ.print=function(S,R,e,aU,aV,a4){a4=a4||"middle";var a0=this.set(),a3=(e+am)[w](am),a1=0,aX=am,a5;ai.is(aU,"string")&&(aU=this.getFont(aU));if(aU){a5=(aV||16)/aU.face["units-per-em"];var E=aU.face.bbox.split(a),aT=+E[0],aW=+E[1]+(a4=="baseline"?E[3]-E[1]+(+aU.face.descent):(E[3]-E[1])/2);for(var aZ=0,aS=a3[l];aZ<aS;aZ++){var aY=aZ&&aU.glyphs[a3[aZ-1]]||{},a2=aU.glyphs[a3[aZ]];a1+=aZ?(aY.w||aU.w)+(aY.k&&aY.k[a3[aZ]]||0):0;a2&&a2.d&&a0[d](this.path(a2.d).attr({fill:"#000",stroke:"none",translation:[a1,0]}));}a0.scale(a5,a5,aT,aW).translate(S-aT,R-aW);}return a0;};ai.format=function(E){var i=ai.is(arguments[1],"array")?[0][aL](arguments[1]):arguments,e=/\{(\d+)\}/g;E&&ai.is(E,"string")&&i[l]-1&&(E=E[aI](e,function(S,R){return i[++R]==null?am:i[R];}));return E||am;};ai.ninja=function(){var E=an.Raphael,i;if(k.was){an.Raphael=k.is;}else{try{delete an.Raphael;}catch(R){an.Raphael=i;}}return E;};ai.el=aq[aQ];return ai;})();/*
+ * g.Raphael 0.4 - Charting library, based on Raphaël
+ *
+ * Copyright (c) 2009 Dmitry Baranovskiy (http://g.raphaeljs.com)
+ * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
+ */
+(function(){Raphael.fn.g=Raphael.fn.g||{};Raphael.fn.g.markers={disc:"disc",o:"disc",flower:"flower",f:"flower",diamond:"diamond",d:"diamond",square:"square",s:"square",triangle:"triangle",t:"triangle",star:"star","*":"star",cross:"cross",x:"cross",plus:"plus","+":"plus",arrow:"arrow","->":"arrow"};Raphael.fn.g.shim={stroke:"none",fill:"#000","fill-opacity":0};Raphael.fn.g.txtattr={font:"12px Arial, sans-serif"};Raphael.fn.g.colors=[];var b=[0.6,0.2,0.05,0.1333,0.75,0];for(var a=0;a<10;a++){if(a<b.length){Raphael.fn.g.colors.push("hsb("+b[a]+", .75, .75)");}else{Raphael.fn.g.colors.push("hsb("+b[a-b.length]+", 1, .5)");}}Raphael.fn.g.text=function(c,f,e){return this.text(c,f,e).attr(this.g.txtattr);};Raphael.fn.g.labelise=function(c,f,e){if(c){return(c+"").replace(/(##+(?:\.#+)?)|(%%+(?:\.%+)?)/g,function(g,i,h){if(i){return(+f).toFixed(i.replace(/^#+\.?/g,"").length);}if(h){return(f*100/e).toFixed(h.replace(/^%+\.?/g,"").length)+"%";}});}else{return(+f).toFixed(0);}};Raphael.fn.g.finger=function(j,i,e,k,f,g,h){if((f&&!k)||(!f&&!e)){return h?"":this.path();}g={square:"square",sharp:"sharp",soft:"soft"}[g]||"round";var m;k=Math.round(k);e=Math.round(e);j=Math.round(j);i=Math.round(i);switch(g){case"round":if(!f){var c=Math.floor(k/2);if(e<c){c=e;m=["M",j+0.5,i+0.5-Math.floor(k/2),"l",0,0,"a",c,Math.floor(k/2),0,0,1,0,k,"l",0,0,"z"];}else{m=["M",j+0.5,i+0.5-c,"l",e-c,0,"a",c,c,0,1,1,0,k,"l",c-e,0,"z"];}}else{var c=Math.floor(e/2);if(k<c){c=k;m=["M",j-Math.floor(e/2),i,"l",0,0,"a",Math.floor(e/2),c,0,0,1,e,0,"l",0,0,"z"];}else{m=["M",j-c,i,"l",0,c-k,"a",c,c,0,1,1,e,0,"l",0,k-c,"z"];}}break;case"sharp":if(!f){var l=Math.floor(k/2);m=["M",j,i+l,"l",0,-k,Math.max(e-l,0),0,Math.min(l,e),l,-Math.min(l,e),l+(l*2<k),"z"];}else{var l=Math.floor(e/2);m=["M",j+l,i,"l",-e,0,0,-Math.max(k-l,0),l,-Math.min(l,k),l,Math.min(l,k),l,"z"];}break;case"square":if(!f){m=["M",j,i+Math.floor(k/2),"l",0,-k,e,0,0,k,"z"];}else{m=["M",j+Math.floor(e/2),i,"l",1-e,0,0,-k,e-1,0,"z"];}break;case"soft":var c;if(!f){c=Math.min(e,Math.round(k/5));m=["M",j+0.5,i+0.5-Math.floor(k/2),"l",e-c,0,"a",c,c,0,0,1,c,c,"l",0,k-c*2,"a",c,c,0,0,1,-c,c,"l",c-e,0,"z"];}else{c=Math.min(Math.round(e/5),k);m=["M",j-Math.floor(e/2),i,"l",0,c-k,"a",c,c,0,0,1,c,-c,"l",e-2*c,0,"a",c,c,0,0,1,c,c,"l",0,k-c,"z"];}}if(h){return m.join(",");}else{return this.path(m);}};Raphael.fn.g.disc=function(c,f,e){return this.circle(c,f,e);};Raphael.fn.g.line=function(c,f,e){return this.rect(c-e,f-e/5,2*e,2*e/5);};Raphael.fn.g.square=function(c,f,e){e=e*0.7;return this.rect(c-e,f-e,2*e,2*e);};Raphael.fn.g.triangle=function(c,f,e){e*=1.75;return this.path("M".concat(c,",",f,"m0-",e*0.58,"l",e*0.5,",",e*0.87,"-",e,",0z"));};Raphael.fn.g.diamond=function(c,f,e){return this.path(["M",c,f-e,"l",e,e,-e,e,-e,-e,e,-e,"z"]);};Raphael.fn.g.flower=function(g,f,c,e){c=c*1.25;var l=c,k=l*0.5;e=+e<3||!e?5:e;var m=["M",g,f+k,"Q"],j;for(var h=1;h<e*2+1;h++){j=h%2?l:k;m=m.concat([+(g+j*Math.sin(h*Math.PI/e)).toFixed(3),+(f+j*Math.cos(h*Math.PI/e)).toFixed(3)]);}m.push("z");return this.path(m.join(","));};Raphael.fn.g.star=function(c,k,j,e){e=e||j*0.5;var h=["M",c,k+e,"L"],g;for(var f=1;f<10;f++){g=f%2?j:e;h=h.concat([(c+g*Math.sin(f*Math.PI*0.2)).toFixed(3),(k+g*Math.cos(f*Math.PI*0.2)).toFixed(3)]);}h.push("z");return this.path(h.join(","));};Raphael.fn.g.cross=function(c,f,e){e=e/2.5;return this.path("M".concat(c-e,",",f,"l",[-e,-e,e,-e,e,e,e,-e,e,e,-e,e,e,e,-e,e,-e,-e,-e,e,-e,-e,"z"]));};Raphael.fn.g.plus=function(c,f,e){e=e/2;return this.path("M".concat(c-e/2,",",f-e/2,"l",[0,-e,e,0,0,e,e,0,0,e,-e,0,0,e,-e,0,0,-e,-e,0,0,-e,"z"]));};Raphael.fn.g.arrow=function(c,f,e){return this.path("M".concat(c-e*0.7,",",f-e*0.4,"l",[e*0.6,0,0,-e*0.4,e,e*0.8,-e,e*0.8,0,-e*0.4,-e*0.6,0],"z"));};Raphael.fn.g.tag=function(c,k,j,i,g){i=i||0;g=g==null?5:g;j=j==null?"$9.99":j;var f=0.5522*g,e=this.set(),h=3;e.push(this.path().attr({fill:"#000",stroke:"none"}));e.push(this.text(c,k,j).attr(this.g.txtattr).attr({fill:"#fff"}));e.update=function(){this.rotate(0,c,k);var m=this[1].getBBox();if(m.height>=g*2){this[0].attr({path:["M",c,k+g,"a",g,g,0,1,1,0,-g*2,g,g,0,1,1,0,g*2,"m",0,-g*2-h,"a",g+h,g+h,0,1,0,0,(g+h)*2,"L",c+g+h,k+m.height/2+h,"l",m.width+2*h,0,0,-m.height-2*h,-m.width-2*h,0,"L",c,k-g-h].join(",")});}else{var l=Math.sqrt(Math.pow(g+h,2)-Math.pow(m.height/2+h,2));this[0].attr({path:["M",c,k+g,"c",-f,0,-g,f-g,-g,-g,0,-f,g-f,-g,g,-g,f,0,g,g-f,g,g,0,f,f-g,g,-g,g,"M",c+l,k-m.height/2-h,"a",g+h,g+h,0,1,0,0,m.height+2*h,"l",g+h-l+m.width+2*h,0,0,-m.height-2*h,"L",c+l,k-m.height/2-h].join(",")});}this[1].attr({x:c+g+h+m.width/2,y:k});i=(360-i)%360;this.rotate(i,c,k);i>90&&i<270&&this[1].attr({x:c-g-h-m.width/2,y:k,rotation:[180+i,c,k]});return this;};e.update();return e;};Raphael.fn.g.popupit=function(j,i,k,e,q){e=e==null?2:e;q=q||5;j=Math.round(j)+0.5;i=Math.round(i)+0.5;var g=k.getBBox(),l=Math.round(g.width/2),f=Math.round(g.height/2),o=[0,l+q*2,0,-l-q*2],m=[-f*2-q*3,-f-q,0,-f-q],c=["M",j-o[e],i-m[e],"l",-q,(e==2)*-q,-Math.max(l-q,0),0,"a",q,q,0,0,1,-q,-q,"l",0,-Math.max(f-q,0),(e==3)*-q,-q,(e==3)*q,-q,0,-Math.max(f-q,0),"a",q,q,0,0,1,q,-q,"l",Math.max(l-q,0),0,q,!e*-q,q,!e*q,Math.max(l-q,0),0,"a",q,q,0,0,1,q,q,"l",0,Math.max(f-q,0),(e==1)*q,q,(e==1)*-q,q,0,Math.max(f-q,0),"a",q,q,0,0,1,-q,q,"l",-Math.max(l-q,0),0,"z"].join(","),n=[{x:j,y:i+q*2+f},{x:j-q*2-l,y:i},{x:j,y:i-q*2-f},{x:j+q*2+l,y:i}][e];k.translate(n.x-l-g.x,n.y-f-g.y);return this.path(c).attr({fill:"#000",stroke:"none"}).insertBefore(k.node?k:k[0]);};Raphael.fn.g.popup=function(c,j,i,e,g){e=e==null?2:e;g=g||5;i=i||"$9.99";var f=this.set(),h=3;f.push(this.path().attr({fill:"#000",stroke:"none"}));f.push(this.text(c,j,i).attr(this.g.txtattr).attr({fill:"#fff"}));f.update=function(m,l,n){m=m||c;l=l||j;var q=this[1].getBBox(),s=q.width/2,o=q.height/2,v=[0,s+g*2,0,-s-g*2],t=[-o*2-g*3,-o-g,0,-o-g],k=["M",m-v[e],l-t[e],"l",-g,(e==2)*-g,-Math.max(s-g,0),0,"a",g,g,0,0,1,-g,-g,"l",0,-Math.max(o-g,0),(e==3)*-g,-g,(e==3)*g,-g,0,-Math.max(o-g,0),"a",g,g,0,0,1,g,-g,"l",Math.max(s-g,0),0,g,!e*-g,g,!e*g,Math.max(s-g,0),0,"a",g,g,0,0,1,g,g,"l",0,Math.max(o-g,0),(e==1)*g,g,(e==1)*-g,g,0,Math.max(o-g,0),"a",g,g,0,0,1,-g,g,"l",-Math.max(s-g,0),0,"z"].join(","),u=[{x:m,y:l+g*2+o},{x:m-g*2-s,y:l},{x:m,y:l-g*2-o},{x:m+g*2+s,y:l}][e];if(n){this[0].animate({path:k},500,">");this[1].animate(u,500,">");}else{this[0].attr({path:k});this[1].attr(u);}return this;};return f.update(c,j);};Raphael.fn.g.flag=function(c,i,h,g){g=g||0;h=h||"$9.99";var e=this.set(),f=3;e.push(this.path().attr({fill:"#000",stroke:"none"}));e.push(this.text(c,i,h).attr(this.g.txtattr).attr({fill:"#fff"}));e.update=function(j,m){this.rotate(0,j,m);var l=this[1].getBBox(),k=l.height/2;this[0].attr({path:["M",j,m,"l",k+f,-k-f,l.width+2*f,0,0,l.height+2*f,-l.width-2*f,0,"z"].join(",")});this[1].attr({x:j+k+f+l.width/2,y:m});g=360-g;this.rotate(g,j,m);g>90&&g<270&&this[1].attr({x:j-r-f-l.width/2,y:m,rotation:[180+g,j,m]});return this;};return e.update(c,i);};Raphael.fn.g.label=function(c,g,f){var e=this.set();e.push(this.rect(c,g,10,10).attr({stroke:"none",fill:"#000"}));e.push(this.text(c,g,f).attr(this.g.txtattr).attr({fill:"#fff"}));e.update=function(){var i=this[1].getBBox(),h=Math.min(i.width+10,i.height+10)/2;this[0].attr({x:i.x-h/2,y:i.y-h/2,width:i.width+h,height:i.height+h,r:h});};e.update();return e;};Raphael.fn.g.labelit=function(f){var e=f.getBBox(),c=Math.min(20,e.width+10,e.height+10)/2;return this.rect(e.x-c/2,e.y-c/2,e.width+c,e.height+c,c).attr({stroke:"none",fill:"#000"}).insertBefore(f[0]);};Raphael.fn.g.drop=function(c,i,h,f,g){f=f||30;g=g||0;var e=this.set();e.push(this.path(["M",c,i,"l",f,0,"A",f*0.4,f*0.4,0,1,0,c+f*0.7,i-f*0.7,"z"]).attr({fill:"#000",stroke:"none",rotation:[22.5-g,c,i]}));g=(g+90)*Math.PI/180;e.push(this.text(c+f*Math.sin(g),i+f*Math.cos(g),h).attr(this.g.txtattr).attr({"font-size":f*12/30,fill:"#fff"}));e.drop=e[0];e.text=e[1];return e;};Raphael.fn.g.blob=function(e,k,j,i,g){i=(+i+1?i:45)+90;g=g||12;var c=Math.PI/180,h=g*12/12;var f=this.set();f.push(this.path().attr({fill:"#000",stroke:"none"}));f.push(this.text(e+g*Math.sin((i)*c),k+g*Math.cos((i)*c)-h/2,j).attr(this.g.txtattr).attr({"font-size":h,fill:"#fff"}));f.update=function(q,p,v){q=q||e;p=p||k;var y=this[1].getBBox(),B=Math.max(y.width+h,g*25/12),x=Math.max(y.height+h,g*25/12),m=q+g*Math.sin((i-22.5)*c),z=p+g*Math.cos((i-22.5)*c),o=q+g*Math.sin((i+22.5)*c),A=p+g*Math.cos((i+22.5)*c),D=(o-m)/2,C=(A-z)/2,n=B/2,l=x/2,u=-Math.sqrt(Math.abs(n*n*l*l-n*n*C*C-l*l*D*D)/(n*n*C*C+l*l*D*D)),t=u*n*C/l+(o+m)/2,s=u*-l*D/n+(A+z)/2;if(v){this.animate({x:t,y:s,path:["M",e,k,"L",o,A,"A",n,l,0,1,1,m,z,"z"].join(",")},500,">");}else{this.attr({x:t,y:s,path:["M",e,k,"L",o,A,"A",n,l,0,1,1,m,z,"z"].join(",")});}return this;};f.update(e,k);return f;};Raphael.fn.g.colorValue=function(g,f,e,c){return"hsb("+[Math.min((1-g/f)*0.4,1),e||0.75,c||0.75]+")";};Raphael.fn.g.snapEnds=function(l,m,k){var h=l,n=m;if(h==n){return{from:h,to:n,power:0};}function o(f){return Math.abs(f-0.5)<0.25?Math.floor(f)+0.5:Math.round(f);}var j=(n-h)/k,c=Math.floor(j),g=c,e=0;if(c){while(g){e--;g=Math.floor(j*Math.pow(10,e))/Math.pow(10,e);}e++;}else{while(!c){e=e||1;c=Math.floor(j*Math.pow(10,e))/Math.pow(10,e);e++;}e&&e--;}var n=o(m*Math.pow(10,e))/Math.pow(10,e);if(n<m){n=o((m+0.5)*Math.pow(10,e))/Math.pow(10,e);}var h=o((l-(e>0?0:0.5))*Math.pow(10,e))/Math.pow(10,e);return{from:h,to:n,power:e};};Raphael.fn.g.axis=function(s,q,m,E,h,H,k,J,l,c){c=c==null?2:c;l=l||"t";H=H||10;var D=l=="|"||l==" "?["M",s+0.5,q,"l",0,0.001]:k==1||k==3?["M",s+0.5,q,"l",0,-m]:["M",s,q+0.5,"l",m,0],v=this.g.snapEnds(E,h,H),I=v.from,z=v.to,G=v.power,F=0,A=this.set();d=(z-I)/H;var p=I,o=G>0?G:0;u=m/H;if(+k==1||+k==3){var e=q,w=(k-1?1:-1)*(c+3+!!(k-1));while(e>=q-m){l!="-"&&l!=" "&&(D=D.concat(["M",s-(l=="+"||l=="|"?c:!(k-1)*c*2),e+0.5,"l",c*2+1,0]));A.push(this.text(s+w,e,(J&&J[F++])||(Math.round(p)==p?p:+p.toFixed(o))).attr(this.g.txtattr).attr({"text-anchor":k-1?"start":"end"}));p+=d;e-=u;}if(Math.round(e+u-(q-m))){l!="-"&&l!=" "&&(D=D.concat(["M",s-(l=="+"||l=="|"?c:!(k-1)*c*2),q-m+0.5,"l",c*2+1,0]));A.push(this.text(s+w,q-m,(J&&J[F])||(Math.round(p)==p?p:+p.toFixed(o))).attr(this.g.txtattr).attr({"text-anchor":k-1?"start":"end"}));}}else{var g=s,p=I,o=G>0?G:0,w=(k?-1:1)*(c+9+!k),u=m/H,B=0,C=0;while(g<=s+m){l!="-"&&l!=" "&&(D=D.concat(["M",g+0.5,q-(l=="+"?c:!!k*c*2),"l",0,c*2+1]));A.push(B=this.text(g,q+w,(J&&J[F++])||(Math.round(p)==p?p:+p.toFixed(o))).attr(this.g.txtattr));var n=B.getBBox();if(C>=n.x-5){A.pop(A.length-1).remove();}else{C=n.x+n.width;}p+=d;g+=u;}if(Math.round(g-u-s-m)){l!="-"&&l!=" "&&(D=D.concat(["M",s+m+0.5,q-(l=="+"?c:!!k*c*2),"l",0,c*2+1]));A.push(this.text(s+m,q+w,(J&&J[F])||(Math.round(p)==p?p:+p.toFixed(o))).attr(this.g.txtattr));}}var K=this.path(D);K.text=A;K.all=this.set([K,A]);K.remove=function(){this.text.remove();this.constructor.prototype.remove.call(this);};return K;};Raphael.el.lighter=function(e){e=e||2;var c=[this.attrs.fill,this.attrs.stroke];this.fs=this.fs||[c[0],c[1]];c[0]=Raphael.rgb2hsb(Raphael.getRGB(c[0]).hex);c[1]=Raphael.rgb2hsb(Raphael.getRGB(c[1]).hex);c[0].b=Math.min(c[0].b*e,1);c[0].s=c[0].s/e;c[1].b=Math.min(c[1].b*e,1);c[1].s=c[1].s/e;this.attr({fill:"hsb("+[c[0].h,c[0].s,c[0].b]+")",stroke:"hsb("+[c[1].h,c[1].s,c[1].b]+")"});};Raphael.el.darker=function(e){e=e||2;var c=[this.attrs.fill,this.attrs.stroke];this.fs=this.fs||[c[0],c[1]];c[0]=Raphael.rgb2hsb(Raphael.getRGB(c[0]).hex);c[1]=Raphael.rgb2hsb(Raphael.getRGB(c[1]).hex);c[0].s=Math.min(c[0].s*e,1);c[0].b=c[0].b/e;c[1].s=Math.min(c[1].s*e,1);c[1].b=c[1].b/e;this.attr({fill:"hsb("+[c[0].h,c[0].s,c[0].b]+")",stroke:"hsb("+[c[1].h,c[1].s,c[1].b]+")"});};Raphael.el.original=function(){if(this.fs){this.attr({fill:this.fs[0],stroke:this.fs[1]});delete this.fs;}};})();
37 test/spain.js
@@ -0,0 +1,37 @@
+var hexVals = ["#CF3D1E","#F15623","#F68B1F","#FFC60B","#DFCE21",
+ "#BCD631","#95C93D","#48B85C","#00833D","#00B48D",
+ "#60C4B1","#27C4F4","#478DCB","#3E67B1","#4251A3",
+ "#59449B","#6A246D","#6E3F7C","#8A4873","#C05A89",
+ "#EF58A0","#EB0080"];
+
+var colors = _.map(hexVals, function(val){ return chroma.hex(val); });
+var sorted = _.sortBy(colors, function(color){ return color.hsl()[0]; });
+var output = _.map(sorted, function(color){ return color.hex() });
+
+$(document).ready(function(){
+ function build(width, height, element, data) {
+ console.log("data", data);
+
+ var formatChart = function(){
+ this.attr("class", "chart")
+ .style("position", "relative")
+ .style("width", width + "px")
+ .style("height", height + "px");
+ }
+
+ var chart = d3.select(element).append("div").call(formatChart);
+
+ chart.selectAll("div").data(data)
+ .enter()
+ .append("div")
+ .attr("class", "row")
+ .style("background-color", function(d){ console.log(d); return d; })
+ .style("width", "300px")
+ .text(function(d){ console.log(d); return d; });
+
+ $(element).show();
+ }
+
+ build(960, 600, "#barchart", output);
+});
+
Please sign in to comment.
Something went wrong with that request. Please try again.