asciinurse 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.idea/.name +1 -0
  4. data/.idea/.rakeTasks +7 -0
  5. data/.idea/asciinurse.iml +35 -0
  6. data/.idea/compiler.xml +22 -0
  7. data/.idea/copyright/profiles_settings.xml +3 -0
  8. data/.idea/misc.xml +14 -0
  9. data/.idea/modules.xml +8 -0
  10. data/.idea/uiDesigner.xml +124 -0
  11. data/.idea/vcs.xml +6 -0
  12. data/Gemfile +4 -0
  13. data/LICENSE.txt +21 -0
  14. data/README.adoc +127 -0
  15. data/Rakefile +2 -0
  16. data/asciinurse.gemspec +26 -0
  17. data/config/asciinurse.yml +22 -0
  18. data/examples/charts/browsers-googlecharts.json +21 -0
  19. data/examples/charts/browsers-highcharts.json +64 -0
  20. data/examples/charts/browsers.csv +7 -0
  21. data/examples/charts/googlecharts.adoc +83 -0
  22. data/examples/charts/googlecharts.html +652 -0
  23. data/examples/charts/googlecharts.pdf +0 -0
  24. data/examples/charts/highcharts.adoc +83 -0
  25. data/examples/charts/highcharts.html +1126 -0
  26. data/examples/charts/highcharts.pdf +0 -0
  27. data/examples/charts/indicators.csv +13 -0
  28. data/examples/convert.rb +10 -0
  29. data/i18n/en_US.yml +12 -0
  30. data/i18n/pt_BR.yml +12 -0
  31. data/lib/asciinurse.rb +76 -0
  32. data/lib/asciinurse/extensions/charts/chart_data.rb +57 -0
  33. data/lib/asciinurse/extensions/charts/extension.rb +124 -0
  34. data/lib/asciinurse/version.rb +3 -0
  35. data/resources/googlecharts/converter/googlecharts-convert.js +25 -0
  36. data/resources/googlecharts/converter/template.html +24 -0
  37. data/resources/googlecharts/javascripts/global.js +8 -0
  38. data/resources/googlecharts/templates/chart.html.erb +6 -0
  39. data/resources/googlecharts/templates/charts/bar.json.erb +22 -0
  40. data/resources/googlecharts/templates/charts/column.json.erb +22 -0
  41. data/resources/googlecharts/templates/charts/donut.json.erb +14 -0
  42. data/resources/googlecharts/templates/charts/line.json.erb +13 -0
  43. data/resources/googlecharts/templates/charts/pie.json.erb +13 -0
  44. data/resources/highcharts/converter/broken-axis.js +6 -0
  45. data/resources/highcharts/converter/data.js +26 -0
  46. data/resources/highcharts/converter/drilldown.js +17 -0
  47. data/resources/highcharts/converter/funnel.js +13 -0
  48. data/resources/highcharts/converter/heatmap.js +23 -0
  49. data/resources/highcharts/converter/highcharts-3d.js +46 -0
  50. data/resources/highcharts/converter/highcharts-convert.js +620 -0
  51. data/resources/highcharts/converter/highcharts-more.js +54 -0
  52. data/resources/highcharts/converter/highcharts.js +325 -0
  53. data/resources/highcharts/converter/highmaps.js +353 -0
  54. data/resources/highcharts/converter/jquery.1.9.1.min.js +5 -0
  55. data/resources/highcharts/converter/map.js +56 -0
  56. data/resources/highcharts/converter/no-data-to-display.js +12 -0
  57. data/resources/highcharts/converter/solid-gauge.js +14 -0
  58. data/resources/highcharts/converter/treemap.js +30 -0
  59. data/resources/highcharts/javascripts/global.js +6 -0
  60. data/resources/highcharts/javascripts/highcharts.min.js +325 -0
  61. data/resources/highcharts/javascripts/jquery.min.js +4 -0
  62. data/resources/highcharts/templates/chart.html.erb +6 -0
  63. data/resources/highcharts/templates/charts/generic.json.erb +15 -0
  64. data/resources/highcharts/templates/charts/pie.json.erb +45 -0
  65. metadata +163 -0
@@ -0,0 +1,13 @@
1
+ {
2
+ type: google.charts.Line,
3
+ data: google.visualization.arrayToDataTable(<%= @csv.to_json %>),
4
+ options: {
5
+ chart: {
6
+ title: <%= @title.to_json %>
7
+ }
8
+ },
9
+ style: {
10
+ width: <%= @width.to_json %>,
11
+ height: <%= @height.to_json %>
12
+ }
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ type: google.visualization.PieChart,
3
+ data: google.visualization.arrayToDataTable(<%= @csv.to_json %>),
4
+ options: {
5
+ chart: {
6
+ title: <%= @title.to_json %>
7
+ }
8
+ },
9
+ style: {
10
+ width: <%= @width.to_json %>,
11
+ height: <%= @height.to_json %>
12
+ }
13
+ }
@@ -0,0 +1,6 @@
1
+ (function(h){function r(){return Array.prototype.slice.call(arguments,1)}var s=h.pick,o=h.wrap,t=h.extend,p=HighchartsAdapter.fireEvent,n=h.Axis,u=h.Series;t(n.prototype,{isInBreak:function(f,d){var a=f.repeat||Infinity,c=f.from,b=f.to-f.from,a=d>=c?(d-c)%a:a-(c-d)%a;return f.inclusive?a<=b:a<b&&a!==0},isInAnyBreak:function(f,d){var a=this.options.breaks,c=a&&a.length,b,e,q;if(c){for(;c--;)this.isInBreak(a[c],f)&&(b=!0,e||(e=s(a[c].showPoints,this.isXAxis?!1:!0)));q=b&&d?b&&!e:b}return q}});o(n.prototype,
2
+ "setTickPositions",function(f){f.apply(this,Array.prototype.slice.call(arguments,1));if(this.options.breaks){var d=this.tickPositions,a=this.tickPositions.info,c=[],b;if(!(a&&a.totalRange>=this.closestPointRange)){for(b=0;b<d.length;b++)this.isInAnyBreak(d[b])||c.push(d[b]);this.tickPositions=c;this.tickPositions.info=a}}});o(n.prototype,"init",function(f,d,a){if(a.breaks&&a.breaks.length)a.ordinal=!1;f.call(this,d,a);if(this.options.breaks){var c=this;c.doPostTranslate=!0;this.val2lin=function(b){var e=
3
+ b,a,d;for(d=0;d<c.breakArray.length;d++)if(a=c.breakArray[d],a.to<=b)e-=a.len;else if(a.from>=b)break;else if(c.isInBreak(a,b)){e-=b-a.from;break}return e};this.lin2val=function(b){var e,a;for(a=0;a<c.breakArray.length;a++)if(e=c.breakArray[a],e.from>=b)break;else e.to<b?b+=e.len:c.isInBreak(e,b)&&(b+=e.len);return b};this.setExtremes=function(b,c,a,d,f){for(;this.isInAnyBreak(b);)b-=this.closestPointRange;for(;this.isInAnyBreak(c);)c-=this.closestPointRange;n.prototype.setExtremes.call(this,b,c,
4
+ a,d,f)};this.setAxisTranslation=function(b){n.prototype.setAxisTranslation.call(this,b);var a=c.options.breaks,b=[],d=[],f=0,j,g,k=c.userMin||c.min,l=c.userMax||c.max,i,h;for(h in a)g=a[h],j=g.repeat||Infinity,c.isInBreak(g,k)&&(k+=g.to%j-k%j),c.isInBreak(g,l)&&(l-=l%j-g.from%j);for(h in a){g=a[h];i=g.from;for(j=g.repeat||Infinity;i-j>k;)i-=j;for(;i<k;)i+=j;for(;i<l;i+=j)b.push({value:i,move:"in"}),b.push({value:i+(g.to-g.from),move:"out",size:g.breakSize})}b.sort(function(a,b){return a.value===b.value?
5
+ (a.move==="in"?0:1)-(b.move==="in"?0:1):a.value-b.value});a=0;i=k;for(h in b){g=b[h];a+=g.move==="in"?1:-1;if(a===1&&g.move==="in")i=g.value;a===0&&(d.push({from:i,to:g.value,len:g.value-i-(g.size||0)}),f+=g.value-i-(g.size||0))}c.breakArray=d;p(c,"afterBreaks");c.transA*=(l-c.min)/(l-k-f);c.min=k;c.max=l}}});o(u.prototype,"generatePoints",function(f){f.apply(this,r(arguments));var d=this.xAxis,a=this.yAxis,c=this.points,b,e=c.length,h=this.options.connectNulls,m;if(d&&a&&(d.options.breaks||a.options.breaks))for(;e--;)if(b=
6
+ c[e],m=b.y===null&&h===!1,!m&&(d.isInAnyBreak(b.x,!0)||a.isInAnyBreak(b.y,!0)))c.splice(e,1),this.data[e]&&this.data[e].destroyElements()});o(h.seriesTypes.column.prototype,"drawPoints",function(f){f.apply(this);var f=this.points,d=this.yAxis,a=d.breakArray||[],c,b,e,h,m;for(e=0;e<f.length;e++){c=f[e];m=c.stackY||c.y;for(h=0;h<a.length;h++)if(b=a[h],m<b.from)break;else m>b.to?p(d,"pointBreak",{point:c,brk:b}):p(d,"pointInBreak",{point:c,brk:b})}})})(Highcharts);
@@ -0,0 +1,26 @@
1
+ /*
2
+ Highcharts JS v4.1.7 (2015-06-26)
3
+ Data module
4
+
5
+ (c) 2012-2014 Torstein Honsi
6
+
7
+ License: www.highcharts.com/license
8
+ */
9
+ (function(g){var k=g.each,t=g.pick,r=HighchartsAdapter.inArray,u=g.splat,j,p=function(b,a){this.init(b,a)};g.extend(p.prototype,{init:function(b,a){this.options=b;this.chartOptions=a;this.columns=b.columns||this.rowsToColumns(b.rows)||[];this.firstRowAsNames=t(b.firstRowAsNames,!0);this.decimalRegex=b.decimalPoint&&RegExp("^([0-9]+)"+b.decimalPoint+"([0-9]+)$");this.rawColumns=[];this.columns.length?this.dataFound():(this.parseCSV(),this.parseTable(),this.parseGoogleSpreadsheet())},getColumnDistribution:function(){var b=
10
+ this.chartOptions,a=this.options,e=[],f=function(b){return(g.seriesTypes[b||"line"].prototype.pointArrayMap||[0]).length},d=b&&b.chart&&b.chart.type,c=[],h=[],n=0,i;k(b&&b.series||[],function(b){c.push(f(b.type||d))});k(a&&a.seriesMapping||[],function(b){e.push(b.x||0)});e.length===0&&e.push(0);k(a&&a.seriesMapping||[],function(a){var e=new j,o,q=c[n]||f(d),m=g.seriesTypes[((b&&b.series||[])[n]||{}).type||d||"line"].prototype.pointArrayMap||["y"];e.addColumnReader(a.x,"x");for(o in a)a.hasOwnProperty(o)&&
11
+ o!=="x"&&e.addColumnReader(a[o],o);for(i=0;i<q;i++)e.hasReader(m[i])||e.addColumnReader(void 0,m[i]);h.push(e);n++});a=g.seriesTypes[d||"line"].prototype.pointArrayMap;a===void 0&&(a=["y"]);this.valueCount={global:f(d),xColumns:e,individual:c,seriesBuilders:h,globalPointArrayMap:a}},dataFound:function(){if(this.options.switchRowsAndColumns)this.columns=this.rowsToColumns(this.columns);this.getColumnDistribution();this.parseTypes();this.parsed()!==!1&&this.complete()},parseCSV:function(){var b=this,
12
+ a=this.options,e=a.csv,f=this.columns,d=a.startRow||0,c=a.endRow||Number.MAX_VALUE,h=a.startColumn||0,n=a.endColumn||Number.MAX_VALUE,i,g,s=0;e&&(g=e.replace(/\r\n/g,"\n").replace(/\r/g,"\n").split(a.lineDelimiter||"\n"),i=a.itemDelimiter||(e.indexOf("\t")!==-1?"\t":","),k(g,function(a,e){var g=b.trim(a),v=g.indexOf("#")===0;e>=d&&e<=c&&!v&&g!==""&&(g=a.split(i),k(g,function(b,a){a>=h&&a<=n&&(f[a-h]||(f[a-h]=[]),f[a-h][s]=b)}),s+=1)}),this.dataFound())},parseTable:function(){var b=this.options,a=
13
+ b.table,e=this.columns,f=b.startRow||0,d=b.endRow||Number.MAX_VALUE,c=b.startColumn||0,h=b.endColumn||Number.MAX_VALUE;a&&(typeof a==="string"&&(a=document.getElementById(a)),k(a.getElementsByTagName("tr"),function(b,a){a>=f&&a<=d&&k(b.children,function(b,d){if((b.tagName==="TD"||b.tagName==="TH")&&d>=c&&d<=h)e[d-c]||(e[d-c]=[]),e[d-c][a-f]=b.innerHTML})}),this.dataFound())},parseGoogleSpreadsheet:function(){var b=this,a=this.options,e=a.googleSpreadsheetKey,f=this.columns,d=a.startRow||0,c=a.endRow||
14
+ Number.MAX_VALUE,h=a.startColumn||0,n=a.endColumn||Number.MAX_VALUE,i,g;e&&jQuery.ajax({dataType:"json",url:"https://spreadsheets.google.com/feeds/cells/"+e+"/"+(a.googleSpreadsheetWorksheet||"od6")+"/public/values?alt=json-in-script&callback=?",error:a.error,success:function(a){var a=a.feed.entry,e,k=a.length,m=0,j=0,l;for(l=0;l<k;l++)e=a[l],m=Math.max(m,e.gs$cell.col),j=Math.max(j,e.gs$cell.row);for(l=0;l<m;l++)if(l>=h&&l<=n)f[l-h]=[],f[l-h].length=Math.min(j,c-d);for(l=0;l<k;l++)if(e=a[l],i=e.gs$cell.row-
15
+ 1,g=e.gs$cell.col-1,g>=h&&g<=n&&i>=d&&i<=c)f[g-h][i-d]=e.content.$t;b.dataFound()}})},trim:function(b,a){typeof b==="string"&&(b=b.replace(/^\s+|\s+$/g,""),a&&/^[0-9\s]+$/.test(b)&&(b=b.replace(/\s/g,"")),this.decimalRegex&&(b=b.replace(this.decimalRegex,"$1.$2")));return b},parseTypes:function(){for(var b=this.columns,a=b.length;a--;)this.parseColumn(b[a],a)},parseColumn:function(b,a){var e=this.rawColumns,f=this.columns,d=b.length,c,h,g,i,k=this.firstRowAsNames,j=r(a,this.valueCount.xColumns)!==
16
+ -1,o=[],q=this.chartOptions,m,p=(this.options.columnTypes||[])[a],q=j&&(q&&q.xAxis&&u(q.xAxis)[0].type==="category"||p==="string");for(e[a]||(e[a]=[]);d--;)if(c=o[d]||b[d],g=this.trim(c),i=this.trim(c,!0),h=parseFloat(i),e[a][d]===void 0&&(e[a][d]=g),q||d===0&&k)b[d]=g;else if(+i===h)b[d]=h,h>31536E6&&p!=="float"?b.isDatetime=!0:b.isNumeric=!0,b[d+1]!==void 0&&(m=h>b[d+1]);else if(h=this.parseDate(c),j&&typeof h==="number"&&!isNaN(h)&&p!=="float"){if(o[d]=c,b[d]=h,b.isDatetime=!0,b[d+1]!==void 0){c=
17
+ h>b[d+1];if(c!==m&&m!==void 0)this.alternativeFormat?(this.dateFormat=this.alternativeFormat,d=b.length,this.alternativeFormat=this.dateFormats[this.dateFormat].alternative):b.unsorted=!0;m=c}}else if(b[d]=g===""?null:g,d!==0&&(b.isDatetime||b.isNumeric))b.mixed=!0;j&&b.mixed&&(f[a]=e[a]);if(j&&m&&this.options.sort)for(a=0;a<f.length;a++)f[a].reverse(),k&&f[a].unshift(f[a].pop())},dateFormats:{"YYYY-mm-dd":{regex:/^([0-9]{4})[\-\/\.]([0-9]{2})[\-\/\.]([0-9]{2})$/,parser:function(b){return Date.UTC(+b[1],
18
+ b[2]-1,+b[3])}},"dd/mm/YYYY":{regex:/^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{4})$/,parser:function(b){return Date.UTC(+b[3],b[2]-1,+b[1])},alternative:"mm/dd/YYYY"},"mm/dd/YYYY":{regex:/^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{4})$/,parser:function(b){return Date.UTC(+b[3],b[1]-1,+b[2])}},"dd/mm/YY":{regex:/^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{2})$/,parser:function(b){return Date.UTC(+b[3]+2E3,b[2]-1,+b[1])},alternative:"mm/dd/YY"},"mm/dd/YY":{regex:/^([0-9]{1,2})[\-\/\.]([0-9]{1,2})[\-\/\.]([0-9]{2})$/,
19
+ parser:function(b){return Date.UTC(+b[3]+2E3,b[1]-1,+b[2])}}},parseDate:function(b){var a=this.options.parseDate,e,f,d=this.options.dateFormat||this.dateFormat,c;if(a)e=a(b);else if(typeof b==="string"){if(d)a=this.dateFormats[d],(c=b.match(a.regex))&&(e=a.parser(c));else for(f in this.dateFormats)if(a=this.dateFormats[f],c=b.match(a.regex)){this.dateFormat=f;this.alternativeFormat=a.alternative;e=a.parser(c);break}c||(c=Date.parse(b),typeof c==="object"&&c!==null&&c.getTime?e=c.getTime()-c.getTimezoneOffset()*
20
+ 6E4:typeof c==="number"&&!isNaN(c)&&(e=c-(new Date(c)).getTimezoneOffset()*6E4))}return e},rowsToColumns:function(b){var a,e,f,d,c;if(b){c=[];e=b.length;for(a=0;a<e;a++){d=b[a].length;for(f=0;f<d;f++)c[f]||(c[f]=[]),c[f][a]=b[a][f]}}return c},parsed:function(){if(this.options.parsed)return this.options.parsed.call(this,this.columns)},getFreeIndexes:function(b,a){var e,f,d=[],c=[],h;for(f=0;f<b;f+=1)d.push(!0);for(e=0;e<a.length;e+=1){h=a[e].getReferencedColumnIndexes();for(f=0;f<h.length;f+=1)d[h[f]]=
21
+ !1}for(f=0;f<d.length;f+=1)d[f]&&c.push(f);return c},complete:function(){var b=this.columns,a,e=this.options,f,d,c,h,g=[],i;if(e.complete||e.afterComplete){for(c=0;c<b.length;c++)if(this.firstRowAsNames)b[c].name=b[c].shift();f=[];d=this.getFreeIndexes(b.length,this.valueCount.seriesBuilders);for(c=0;c<this.valueCount.seriesBuilders.length;c++)i=this.valueCount.seriesBuilders[c],i.populateColumns(d)&&g.push(i);for(;d.length>0;){i=new j;i.addColumnReader(0,"x");c=r(0,d);c!==-1&&d.splice(c,1);for(c=
22
+ 0;c<this.valueCount.global;c++)i.addColumnReader(void 0,this.valueCount.globalPointArrayMap[c]);i.populateColumns(d)&&g.push(i)}g.length>0&&g[0].readers.length>0&&(i=b[g[0].readers[0].columnIndex],i!==void 0&&(i.isDatetime?a="datetime":i.isNumeric||(a="category")));if(a==="category")for(c=0;c<g.length;c++){i=g[c];for(d=0;d<i.readers.length;d++)if(i.readers[d].configName==="x")i.readers[d].configName="name"}for(c=0;c<g.length;c++){i=g[c];d=[];for(h=0;h<b[0].length;h++)d[h]=i.read(b,h);f[c]={data:d};
23
+ if(i.name)f[c].name=i.name;if(a==="category")f[c].turboThreshold=0}b={series:f};if(a)b.xAxis={type:a};e.complete&&e.complete(b);e.afterComplete&&e.afterComplete(b)}}});g.Data=p;g.data=function(b,a){return new p(b,a)};g.wrap(g.Chart.prototype,"init",function(b,a,e){var f=this;a&&a.data?g.data(g.extend(a.data,{afterComplete:function(d){var c,h;if(a.hasOwnProperty("series"))if(typeof a.series==="object")for(c=Math.max(a.series.length,d.series.length);c--;)h=a.series[c]||{},a.series[c]=g.merge(h,d.series[c]);
24
+ else delete a.series;a=g.merge(d,a);b.call(f,a,e)}}),a):b.call(f,a,e)});j=function(){this.readers=[];this.pointIsArray=!0};j.prototype.populateColumns=function(b){var a=!0;k(this.readers,function(a){if(a.columnIndex===void 0)a.columnIndex=b.shift()});k(this.readers,function(b){b.columnIndex===void 0&&(a=!1)});return a};j.prototype.read=function(b,a){var e=this.pointIsArray,f=e?[]:{},d;k(this.readers,function(c){var d=b[c.columnIndex][a];e?f.push(d):f[c.configName]=d});if(this.name===void 0&&this.readers.length>=
25
+ 2&&(d=this.getReferencedColumnIndexes(),d.length>=2))d.shift(),d.sort(),this.name=b[d.shift()].name;return f};j.prototype.addColumnReader=function(b,a){this.readers.push({columnIndex:b,configName:a});if(!(a==="x"||a==="y"||a===void 0))this.pointIsArray=!1};j.prototype.getReferencedColumnIndexes=function(){var b,a=[],e;for(b=0;b<this.readers.length;b+=1)e=this.readers[b],e.columnIndex!==void 0&&a.push(e.columnIndex);return a};j.prototype.hasReader=function(b){var a,e;for(a=0;a<this.readers.length;a+=
26
+ 1)if(e=this.readers[a],e.configName===b)return!0}})(Highcharts);
@@ -0,0 +1,17 @@
1
+ (function(f){function A(b,a,c){var d;!a.rgba.length||!b.rgba.length?b=a.raw||"none":(b=b.rgba,a=a.rgba,d=a[3]!==1||b[3]!==1,b=(d?"rgba(":"rgb(")+Math.round(a[0]+(b[0]-a[0])*(1-c))+","+Math.round(a[1]+(b[1]-a[1])*(1-c))+","+Math.round(a[2]+(b[2]-a[2])*(1-c))+(d?","+(a[3]+(b[3]-a[3])*(1-c)):"")+")");return b}var t=function(){},q=f.getOptions(),h=f.each,l=f.extend,B=f.format,u=f.pick,r=f.wrap,m=f.Chart,p=f.seriesTypes,v=p.pie,n=p.column,w=f.Tick,x=HighchartsAdapter.fireEvent,y=HighchartsAdapter.inArray,
2
+ z=1;h(["fill","stroke"],function(b){HighchartsAdapter.addAnimSetter(b,function(a){a.elem.attr(b,A(f.Color(a.start),f.Color(a.end),a.pos))})});l(q.lang,{drillUpText:"◁ Back to {series.name}"});q.drilldown={activeAxisLabelStyle:{cursor:"pointer",color:"#0d233a",fontWeight:"bold",textDecoration:"underline"},activeDataLabelStyle:{cursor:"pointer",color:"#0d233a",fontWeight:"bold",textDecoration:"underline"},animation:{duration:500},drillUpButton:{position:{align:"right",x:-10,y:10}}};f.SVGRenderer.prototype.Element.prototype.fadeIn=
3
+ function(b){this.attr({opacity:0.1,visibility:"inherit"}).animate({opacity:u(this.newOpacity,1)},b||{duration:250})};m.prototype.addSeriesAsDrilldown=function(b,a){this.addSingleSeriesAsDrilldown(b,a);this.applyDrilldown()};m.prototype.addSingleSeriesAsDrilldown=function(b,a){var c=b.series,d=c.xAxis,g=c.yAxis,e;e=b.color||c.color;var i,f=[],j=[],k,o;if(!this.drilldownLevels)this.drilldownLevels=[];k=c.options._levelNumber||0;(o=this.drilldownLevels[this.drilldownLevels.length-1])&&o.levelNumber!==
4
+ k&&(o=void 0);a=l({color:e,_ddSeriesId:z++},a);i=y(b,c.points);h(c.chart.series,function(a){if(a.xAxis===d&&!a.isDrilling)a.options._ddSeriesId=a.options._ddSeriesId||z++,a.options._colorIndex=a.userOptions._colorIndex,a.options._levelNumber=a.options._levelNumber||k,o?(f=o.levelSeries,j=o.levelSeriesOptions):(f.push(a),j.push(a.options))});e={levelNumber:k,seriesOptions:c.options,levelSeriesOptions:j,levelSeries:f,shapeArgs:b.shapeArgs,bBox:b.graphic?b.graphic.getBBox():{},color:e,lowerSeriesOptions:a,
5
+ pointOptions:c.options.data[i],pointIndex:i,oldExtremes:{xMin:d&&d.userMin,xMax:d&&d.userMax,yMin:g&&g.userMin,yMax:g&&g.userMax}};this.drilldownLevels.push(e);e=e.lowerSeries=this.addSeries(a,!1);e.options._levelNumber=k+1;if(d)d.oldPos=d.pos,d.userMin=d.userMax=null,g.userMin=g.userMax=null;if(c.type===e.type)e.animate=e.animateDrilldown||t,e.options.animation=!0};m.prototype.applyDrilldown=function(){var b=this.drilldownLevels,a;if(b&&b.length>0)a=b[b.length-1].levelNumber,h(this.drilldownLevels,
6
+ function(b){b.levelNumber===a&&h(b.levelSeries,function(b){b.options&&b.options._levelNumber===a&&b.remove(!1)})});this.redraw();this.showDrillUpButton()};m.prototype.getDrilldownBackText=function(){var b=this.drilldownLevels;if(b&&b.length>0)return b=b[b.length-1],b.series=b.seriesOptions,B(this.options.lang.drillUpText,b)};m.prototype.showDrillUpButton=function(){var b=this,a=this.getDrilldownBackText(),c=b.options.drilldown.drillUpButton,d,g;this.drillUpButton?this.drillUpButton.attr({text:a}).align():
7
+ (g=(d=c.theme)&&d.states,this.drillUpButton=this.renderer.button(a,null,null,function(){b.drillUp()},d,g&&g.hover,g&&g.select).attr({align:c.position.align,zIndex:9}).add().align(c.position,!1,c.relativeTo||"plotBox"))};m.prototype.drillUp=function(){for(var b=this,a=b.drilldownLevels,c=a[a.length-1].levelNumber,d=a.length,g=b.series,e,i,f,j,k=function(a){var c;h(g,function(b){b.options._ddSeriesId===a._ddSeriesId&&(c=b)});c=c||b.addSeries(a,!1);if(c.type===f.type&&c.animateDrillupTo)c.animate=c.animateDrillupTo;
8
+ a===i.seriesOptions&&(j=c)};d--;)if(i=a[d],i.levelNumber===c){a.pop();f=i.lowerSeries;if(!f.chart)for(e=g.length;e--;)if(g[e].options.id===i.lowerSeriesOptions.id&&g[e].options._levelNumber===c+1){f=g[e];break}f.xData=[];h(i.levelSeriesOptions,k);x(b,"drillup",{seriesOptions:i.seriesOptions});if(j.type===f.type)j.drilldownLevel=i,j.options.animation=b.options.drilldown.animation,f.animateDrillupFrom&&f.chart&&f.animateDrillupFrom(i);j.options._levelNumber=c;f.remove(!1);if(j.xAxis)e=i.oldExtremes,
9
+ j.xAxis.setExtremes(e.xMin,e.xMax,!1),j.yAxis.setExtremes(e.yMin,e.yMax,!1)}this.redraw();this.drilldownLevels.length===0?this.drillUpButton=this.drillUpButton.destroy():this.drillUpButton.attr({text:this.getDrilldownBackText()}).align();this.ddDupes.length=[]};n.prototype.supportsDrilldown=!0;n.prototype.animateDrillupTo=function(b){if(!b){var a=this,c=a.drilldownLevel;h(this.points,function(a){a.graphic&&a.graphic.hide();a.dataLabel&&a.dataLabel.hide();a.connector&&a.connector.hide()});setTimeout(function(){a.points&&
10
+ h(a.points,function(a,b){var e=b===(c&&c.pointIndex)?"show":"fadeIn",f=e==="show"?!0:void 0;if(a.graphic)a.graphic[e](f);if(a.dataLabel)a.dataLabel[e](f);if(a.connector)a.connector[e](f)})},Math.max(this.chart.options.drilldown.animation.duration-50,0));this.animate=t}};n.prototype.animateDrilldown=function(b){var a=this,c=this.chart.drilldownLevels,d,g=this.chart.options.drilldown.animation,e=this.xAxis;if(!b)h(c,function(b){if(a.options._ddSeriesId===b.lowerSeriesOptions._ddSeriesId)d=b.shapeArgs,
11
+ d.fill=b.color}),d.x+=u(e.oldPos,e.pos)-e.pos,h(this.points,function(a){a.graphic&&a.graphic.attr(d).animate(l(a.shapeArgs,{fill:a.color}),g);a.dataLabel&&a.dataLabel.fadeIn(g)}),this.animate=null};n.prototype.animateDrillupFrom=function(b){var a=this.chart.options.drilldown.animation,c=this.group,d=this;h(d.trackerGroups,function(a){if(d[a])d[a].on("mouseover")});delete this.group;h(this.points,function(d){var e=d.graphic,i=function(){e.destroy();c&&(c=c.destroy())};e&&(delete d.graphic,a?e.animate(l(b.shapeArgs,
12
+ {fill:b.color}),f.merge(a,{complete:i})):(e.attr(b.shapeArgs),i()))})};v&&l(v.prototype,{supportsDrilldown:!0,animateDrillupTo:n.prototype.animateDrillupTo,animateDrillupFrom:n.prototype.animateDrillupFrom,animateDrilldown:function(b){var a=this.chart.drilldownLevels[this.chart.drilldownLevels.length-1],c=this.chart.options.drilldown.animation,d=a.shapeArgs,g=d.start,e=(d.end-g)/this.points.length;if(!b)h(this.points,function(b,h){b.graphic.attr(f.merge(d,{start:g+h*e,end:g+(h+1)*e,fill:a.color}))[c?
13
+ "animate":"attr"](l(b.shapeArgs,{fill:b.color}),c)}),this.animate=null}});f.Point.prototype.doDrilldown=function(b,a){var c=this.series.chart,d=c.options.drilldown,f=(d.series||[]).length,e;if(!c.ddDupes)c.ddDupes=[];for(;f--&&!e;)d.series[f].id===this.drilldown&&y(this.drilldown,c.ddDupes)===-1&&(e=d.series[f],c.ddDupes.push(this.drilldown));x(c,"drilldown",{point:this,seriesOptions:e,category:a,points:a!==void 0&&this.series.xAxis.ddPoints[a].slice(0)});e&&(b?c.addSingleSeriesAsDrilldown(this,e):
14
+ c.addSeriesAsDrilldown(this,e))};f.Axis.prototype.drilldownCategory=function(b){var a,c,d=this.ddPoints[b];for(a in d)(c=d[a])&&c.series&&c.series.visible&&c.doDrilldown&&c.doDrilldown(!0,b);this.chart.applyDrilldown()};f.Axis.prototype.getDDPoints=function(b,a){var c=this.ddPoints;if(!c)this.ddPoints=c={};c[b]||(c[b]=[]);if(c[b].levelNumber!==a)c[b].length=0;return c[b]};w.prototype.drillable=function(){var b=this.pos,a=this.label,c=this.axis,d=c.ddPoints&&c.ddPoints[b];if(a&&d&&d.length){if(!a.basicStyles)a.basicStyles=
15
+ f.merge(a.styles);a.addClass("highcharts-drilldown-axis-label").css(c.chart.options.drilldown.activeAxisLabelStyle).on("click",function(){c.drilldownCategory(b)})}else if(a&&a.basicStyles)a.styles={},a.css(a.basicStyles),a.on("click",null)};r(w.prototype,"addLabel",function(b){b.call(this);this.drillable()});r(f.Point.prototype,"init",function(b,a,c,d){var g=b.call(this,a,c,d),b=(c=a.xAxis)&&c.ticks[d],c=c&&c.getDDPoints(d,a.options._levelNumber);if(g.drilldown&&(f.addEvent(g,"click",function(){a.xAxis&&
16
+ a.chart.options.drilldown.allowPointDrilldown===!1?a.xAxis.drilldownCategory(d):g.doDrilldown()}),c))c.push(g),c.levelNumber=a.options._levelNumber;b&&b.drillable();return g});r(f.Series.prototype,"drawDataLabels",function(b){var a=this.chart.options.drilldown.activeDataLabelStyle;b.call(this);h(this.points,function(b){b.drilldown&&b.dataLabel&&b.dataLabel.attr({"class":"highcharts-drilldown-data-label"}).css(a)})});var s,q=function(b){b.call(this);h(this.points,function(a){a.drilldown&&a.graphic&&
17
+ a.graphic.attr({"class":"highcharts-drilldown-point"}).css({cursor:"pointer"})})};for(s in p)p[s].prototype.supportsDrilldown&&r(p[s].prototype,"drawTracker",q)})(Highcharts);
@@ -0,0 +1,13 @@
1
+ /*
2
+
3
+ Highcharts funnel module
4
+
5
+ (c) 2010-2014 Torstein Honsi
6
+
7
+ License: www.highcharts.com/license
8
+ */
9
+ (function(c){var q=c.getOptions(),w=q.plotOptions,r=c.seriesTypes,G=c.merge,F=function(){},C=c.each,x=c.pick;w.funnel=G(w.pie,{animation:!1,center:["50%","50%"],width:"90%",neckWidth:"30%",height:"100%",neckHeight:"25%",reversed:!1,dataLabels:{connectorWidth:1,connectorColor:"#606060"},size:!0,states:{select:{color:"#C0C0C0",borderColor:"#000000",shadow:!1}}});r.funnel=c.extendClass(r.pie,{type:"funnel",animate:F,translate:function(){var a=function(b,a){return/%$/.test(b)?a*parseInt(b,10)/100:parseInt(b,
10
+ 10)},D=0,f=this.chart,d=this.options,c=d.reversed,n=d.ignoreHiddenPoint,g=f.plotWidth,h=f.plotHeight,q=0,f=d.center,i=a(f[0],g),r=a(f[1],h),w=a(d.width,g),k,s,e=a(d.height,h),t=a(d.neckWidth,g),u=a(d.neckHeight,h),y=e-u,a=this.data,z,A,x=d.dataLabels.position==="left"?1:0,B,l,E,p,j,v,m;this.getWidthAt=s=function(b){return b>e-u||e===u?t:t+(w-t)*((e-u-b)/(e-u))};this.getX=function(b,a){return i+(a?-1:1)*(s(c?h-b:b)/2+d.dataLabels.distance)};this.center=[i,r,e];this.centerX=i;C(a,function(b){if(!n||
11
+ b.visible!==!1)D+=b.y});C(a,function(b){m=null;A=D?b.y/D:0;l=r-e/2+q*e;j=l+A*e;k=s(l);B=i-k/2;E=B+k;k=s(j);p=i-k/2;v=p+k;l>y?(B=p=i-t/2,E=v=i+t/2):j>y&&(m=j,k=s(y),p=i-k/2,v=p+k,j=y);c&&(l=e-l,j=e-j,m=m?e-m:null);z=["M",B,l,"L",E,l,v,j];m&&z.push(v,m,p,m);z.push(p,j,"Z");b.shapeType="path";b.shapeArgs={d:z};b.percentage=A*100;b.plotX=i;b.plotY=(l+(m||j))/2;b.tooltipPos=[i,b.plotY];b.slice=F;b.half=x;if(!n||b.visible!==!1)q+=A})},drawPoints:function(){var a=this,c=a.options,f=a.chart.renderer;C(a.data,
12
+ function(d){var o=d.options,n=d.graphic,g=d.shapeArgs;n?n.animate(g):d.graphic=f.path(g).attr({fill:d.color,stroke:x(o.borderColor,c.borderColor),"stroke-width":x(o.borderWidth,c.borderWidth)}).add(a.group)})},sortByAngle:function(a){a.sort(function(a,c){return a.plotY-c.plotY})},drawDataLabels:function(){var a=this.data,c=this.options.dataLabels.distance,f,d,o,n=a.length,g,h;for(this.center[2]-=2*c;n--;)o=a[n],d=(f=o.half)?1:-1,h=o.plotY,g=this.getX(h,f),o.labelPos=[0,h,g+(c-5)*d,h,g+c*d,h,f?"right":
13
+ "left",0];r.pie.prototype.drawDataLabels.call(this)}});q.plotOptions.pyramid=c.merge(q.plotOptions.funnel,{neckWidth:"0%",neckHeight:"0%",reversed:!0});c.seriesTypes.pyramid=c.extendClass(c.seriesTypes.funnel,{type:"pyramid"})})(Highcharts);
@@ -0,0 +1,23 @@
1
+ /*
2
+ Highcharts JS v4.1.7 (2015-06-26)
3
+
4
+ (c) 2011-2014 Torstein Honsi
5
+
6
+ License: www.highcharts.com/license
7
+ */
8
+ (function(h){var n=h.Axis,r=h.Chart,k=h.Color,x=h.Legend,t=h.LegendSymbolMixin,u=h.Series,v=h.getOptions(),i=h.each,s=h.extend,y=h.extendClass,l=h.merge,m=h.pick,p=h.seriesTypes,w=h.wrap,o=function(){},q=h.ColorAxis=function(){this.isColorAxis=!0;this.init.apply(this,arguments)};s(q.prototype,n.prototype);s(q.prototype,{defaultColorAxisOptions:{lineWidth:0,gridLineWidth:1,tickPixelInterval:72,startOnTick:!0,endOnTick:!0,offset:0,marker:{animation:{duration:50},color:"gray",width:0.01},labels:{overflow:"justify"},
9
+ minColor:"#EFEFFF",maxColor:"#003875",tickLength:5},init:function(a,b){var d=a.options.legend.layout!=="vertical",c;c=l(this.defaultColorAxisOptions,{side:d?2:1,reversed:!d},b,{isX:d,opposite:!d,showEmpty:!1,title:null,isColor:!0});n.prototype.init.call(this,a,c);b.dataClasses&&this.initDataClasses(b);this.initStops(b);this.isXAxis=!0;this.horiz=d;this.zoomEnabled=!1},tweenColors:function(a,b,d){var c;!b.rgba.length||!a.rgba.length?a=b.raw||"none":(a=a.rgba,b=b.rgba,c=b[3]!==1||a[3]!==1,a=(c?"rgba(":
10
+ "rgb(")+Math.round(b[0]+(a[0]-b[0])*(1-d))+","+Math.round(b[1]+(a[1]-b[1])*(1-d))+","+Math.round(b[2]+(a[2]-b[2])*(1-d))+(c?","+(b[3]+(a[3]-b[3])*(1-d)):"")+")");return a},initDataClasses:function(a){var b=this,d=this.chart,c,e=0,f=this.options,g=a.dataClasses.length;this.dataClasses=c=[];this.legendItems=[];i(a.dataClasses,function(a,h){var i,a=l(a);c.push(a);if(!a.color)f.dataClassColor==="category"?(i=d.options.colors,a.color=i[e++],e===i.length&&(e=0)):a.color=b.tweenColors(k(f.minColor),k(f.maxColor),
11
+ g<2?0.5:h/(g-1))})},initStops:function(a){this.stops=a.stops||[[0,this.options.minColor],[1,this.options.maxColor]];i(this.stops,function(a){a.color=k(a[1])})},setOptions:function(a){n.prototype.setOptions.call(this,a);this.options.crosshair=this.options.marker;this.coll="colorAxis"},setAxisSize:function(){var a=this.legendSymbol,b=this.chart,d,c,e;if(a)this.left=d=a.attr("x"),this.top=c=a.attr("y"),this.width=e=a.attr("width"),this.height=a=a.attr("height"),this.right=b.chartWidth-d-e,this.bottom=
12
+ b.chartHeight-c-a,this.len=this.horiz?e:a,this.pos=this.horiz?d:c},toColor:function(a,b){var d,c=this.stops,e,f=this.dataClasses,g,j;if(f)for(j=f.length;j--;){if(g=f[j],e=g.from,c=g.to,(e===void 0||a>=e)&&(c===void 0||a<=c)){d=g.color;if(b)b.dataClass=j;break}}else{this.isLog&&(a=this.val2lin(a));d=1-(this.max-a)/(this.max-this.min||1);for(j=c.length;j--;)if(d>c[j][0])break;e=c[j]||c[j+1];c=c[j+1]||e;d=1-(c[0]-d)/(c[0]-e[0]||1);d=this.tweenColors(e.color,c.color,d)}return d},getOffset:function(){var a=
13
+ this.legendGroup,b=this.chart.axisOffset[this.side];if(a){n.prototype.getOffset.call(this);if(!this.axisGroup.parentGroup)this.axisGroup.add(a),this.gridGroup.add(a),this.labelGroup.add(a),this.added=!0,this.labelLeft=0,this.labelRight=this.width;this.chart.axisOffset[this.side]=b}},setLegendColor:function(){var a,b=this.options;a=this.reversed;a=this.horiz?[+a,0,+!a,0]:[0,+!a,0,+a];this.legendColor={linearGradient:{x1:a[0],y1:a[1],x2:a[2],y2:a[3]},stops:b.stops||[[0,b.minColor],[1,b.maxColor]]}},
14
+ drawLegendSymbol:function(a,b){var d=a.padding,c=a.options,e=this.horiz,f=m(c.symbolWidth,e?200:12),g=m(c.symbolHeight,e?12:200),j=m(c.labelPadding,e?16:30),c=m(c.itemDistance,10);this.setLegendColor();b.legendSymbol=this.chart.renderer.rect(0,a.baseline-11,f,g).attr({zIndex:1}).add(b.legendGroup);b.legendSymbol.getBBox();this.legendItemWidth=f+d+(e?c:j);this.legendItemHeight=g+d+(e?j:0)},setState:o,visible:!0,setVisible:o,getSeriesExtremes:function(){var a;if(this.series.length)a=this.series[0],
15
+ this.dataMin=a.valueMin,this.dataMax=a.valueMax},drawCrosshair:function(a,b){var d=b&&b.plotX,c=b&&b.plotY,e,f=this.pos,g=this.len;if(b)e=this.toPixels(b[b.series.colorKey]),e<f?e=f-2:e>f+g&&(e=f+g+2),b.plotX=e,b.plotY=this.len-e,n.prototype.drawCrosshair.call(this,a,b),b.plotX=d,b.plotY=c,this.cross&&this.cross.attr({fill:this.crosshair.color}).add(this.legendGroup)},getPlotLinePath:function(a,b,d,c,e){return typeof e==="number"?this.horiz?["M",e-4,this.top-6,"L",e+4,this.top-6,e,this.top,"Z"]:["M",
16
+ this.left,e,"L",this.left-6,e+6,this.left-6,e-6,"Z"]:n.prototype.getPlotLinePath.call(this,a,b,d,c)},update:function(a,b){var d=this.chart,c=d.legend;i(this.series,function(a){a.isDirtyData=!0});if(a.dataClasses)i(c.allItems,function(a){a.isDataClass&&a.legendGroup.destroy()}),d.isDirtyLegend=!0;d.options[this.coll]=l(this.userOptions,a);n.prototype.update.call(this,a,b);this.legendItem&&(this.setLegendColor(),c.colorizeItem(this,!0))},getDataClassLegendSymbols:function(){var a=this,b=this.chart,
17
+ d=this.legendItems,c=b.options.legend,e=c.valueDecimals,f=c.valueSuffix||"",g;d.length||i(this.dataClasses,function(c,n){var k=!0,l=c.from,m=c.to;g="";l===void 0?g="< ":m===void 0&&(g="> ");l!==void 0&&(g+=h.numberFormat(l,e)+f);l!==void 0&&m!==void 0&&(g+=" - ");m!==void 0&&(g+=h.numberFormat(m,e)+f);d.push(s({chart:b,name:g,options:{},drawLegendSymbol:t.drawRectangle,visible:!0,setState:o,isDataClass:!0,setVisible:function(){k=this.visible=!k;i(a.series,function(a){i(a.points,function(a){a.dataClass===
18
+ n&&a.setVisible(k)})});b.legend.colorizeItem(this,k)}},c))});return d},name:""});i(["fill","stroke"],function(a){HighchartsAdapter.addAnimSetter(a,function(b){b.elem.attr(a,q.prototype.tweenColors(k(b.start),k(b.end),b.pos))})});w(r.prototype,"getAxes",function(a){var b=this.options.colorAxis;a.call(this);this.colorAxis=[];b&&new q(this,b)});w(x.prototype,"getAllItems",function(a){var b=[],d=this.chart.colorAxis[0];d&&(d.options.dataClasses?b=b.concat(d.getDataClassLegendSymbols()):b.push(d),i(d.series,
19
+ function(a){a.options.showInLegend=!1}));return b.concat(a.call(this))});r={pointAttrToOptions:{stroke:"borderColor","stroke-width":"borderWidth",fill:"color",dashstyle:"dashStyle"},pointArrayMap:["value"],axisTypes:["xAxis","yAxis","colorAxis"],optionalAxis:"colorAxis",trackerGroups:["group","markerGroup","dataLabelsGroup"],getSymbol:o,parallelArrays:["x","y","value"],colorKey:"value",translateColors:function(){var a=this,b=this.options.nullColor,d=this.colorAxis,c=this.colorKey;i(this.data,function(e){var f=
20
+ e[c];if(f=f===null?b:d&&f!==void 0?d.toColor(f,e):e.color||a.color)e.color=f})}};v.plotOptions.heatmap=l(v.plotOptions.scatter,{animation:!1,borderWidth:0,nullColor:"#F8F8F8",dataLabels:{formatter:function(){return this.point.value},inside:!0,verticalAlign:"middle",crop:!1,overflow:!1,padding:0},marker:null,pointRange:null,tooltip:{pointFormat:"{point.x}, {point.y}: {point.value}<br/>"},states:{normal:{animation:!0},hover:{halo:!1,brightness:0.2}}});p.heatmap=y(p.scatter,l(r,{type:"heatmap",pointArrayMap:["y",
21
+ "value"],hasPointSpecificOptions:!0,supportsDrilldown:!0,getExtremesFromAll:!0,directTouch:!0,init:function(){var a;p.scatter.prototype.init.apply(this,arguments);a=this.options;this.pointRange=a.pointRange=m(a.pointRange,a.colsize||1);this.yAxis.axisPointRange=a.rowsize||1},translate:function(){var a=this.options,b=this.xAxis,d=this.yAxis;this.generatePoints();i(this.points,function(c){var e=(a.colsize||1)/2,f=(a.rowsize||1)/2,g=Math.round(b.len-b.translate(c.x-e,0,1,0,1)),e=Math.round(b.len-b.translate(c.x+
22
+ e,0,1,0,1)),h=Math.round(d.translate(c.y-f,0,1,0,1)),f=Math.round(d.translate(c.y+f,0,1,0,1));c.plotX=c.clientX=(g+e)/2;c.plotY=(h+f)/2;c.shapeType="rect";c.shapeArgs={x:Math.min(g,e),y:Math.min(h,f),width:Math.abs(e-g),height:Math.abs(f-h)}});this.translateColors();this.chart.hasRendered&&i(this.points,function(a){a.shapeArgs.fill=a.options.color||a.color})},drawPoints:p.column.prototype.drawPoints,animate:o,getBox:o,drawLegendSymbol:t.drawRectangle,getExtremes:function(){u.prototype.getExtremes.call(this,
23
+ this.valueData);this.valueMin=this.dataMin;this.valueMax=this.dataMax;u.prototype.getExtremes.call(this)}}))})(Highcharts);
@@ -0,0 +1,46 @@
1
+ /*
2
+ Highcharts JS v4.1.7 (2015-06-26)
3
+
4
+ (c) 2009-2013 Torstein Hønsi
5
+
6
+ License: www.highcharts.com/license
7
+ */
8
+ (function(d){function n(c,a,b){var e,f,g=a.options.chart.options3d,i=!1;b?(i=a.inverted,b=a.plotWidth/2,a=a.plotHeight/2,e=g.depth/2,f=y(g.depth,1)*y(g.viewDistance,0)):(b=a.plotLeft+a.plotWidth/2,a=a.plotTop+a.plotHeight/2,e=g.depth/2,f=y(g.depth,1)*y(g.viewDistance,0));var j=[],h=b,k=a,v=e,p=f,b=x*(i?g.beta:-g.beta),g=x*(i?-g.alpha:g.alpha),q=l(b),s=m(b),t=l(g),u=m(g),w,B,r,n,o,z;d.each(c,function(a){w=(i?a.y:a.x)-h;B=(i?a.x:a.y)-k;r=(a.z||0)-v;n=s*w-q*r;o=-q*t*w-s*t*r+u*B;z=q*u*w+s*u*r+t*B;p>0&&
9
+ p<Number.POSITIVE_INFINITY&&(n*=p/(z+v+p),o*=p/(z+v+p));n+=h;o+=k;z+=v;j.push({x:i?o:n,y:i?n:o,z:z})});return j}function o(c){return c!==void 0&&c!==null}function E(c){var a=0,b,e;for(b=0;b<c.length;b++)e=(b+1)%c.length,a+=c[b].x*c[e].y-c[e].x*c[b].y;return a/2}function C(c){var a=0,b;for(b=0;b<c.length;b++)a+=c[b].z;return c.length?a/c.length:0}function r(c,a,b,e,f,g,d,j){var h=[];return g>f&&g-f>q/2+1.0E-4?(h=h.concat(r(c,a,b,e,f,f+q/2,d,j)),h=h.concat(r(c,a,b,e,f+q/2,g,d,j))):g<f&&f-g>q/2+1.0E-4?
10
+ (h=h.concat(r(c,a,b,e,f,f-q/2,d,j)),h=h.concat(r(c,a,b,e,f-q/2,g,d,j))):(h=g-f,["C",c+b*m(f)-b*A*h*l(f)+d,a+e*l(f)+e*A*h*m(f)+j,c+b*m(g)+b*A*h*l(g)+d,a+e*l(g)-e*A*h*m(g)+j,c+b*m(g)+d,a+e*l(g)+j])}function F(c){if(this.chart.is3d()){var a=this.chart.options.plotOptions.column.grouping;if(a!==void 0&&!a&&this.group.zIndex!==void 0&&!this.zIndexSet)this.group.attr({zIndex:this.group.zIndex*10}),this.zIndexSet=!0;var b=this.options,e=this.options.states;this.borderWidth=b.borderWidth=o(b.edgeWidth)?b.edgeWidth:
11
+ 1;d.each(this.data,function(a){if(a.y!==null)a=a.pointAttr,this.borderColor=d.pick(b.edgeColor,a[""].fill),a[""].stroke=this.borderColor,a.hover.stroke=d.pick(e.hover.edgeColor,this.borderColor),a.select.stroke=d.pick(e.select.edgeColor,this.borderColor)})}c.apply(this,[].slice.call(arguments,1))}var q=Math.PI,x=q/180,l=Math.sin,m=Math.cos,y=d.pick,G=Math.round;d.perspective=n;var A=4*(Math.sqrt(2)-1)/3/(q/2);d.SVGRenderer.prototype.toLinePath=function(c,a){var b=[];d.each(c,function(a){b.push("L",
12
+ a.x,a.y)});c.length&&(b[0]="M",a&&b.push("Z"));return b};d.SVGRenderer.prototype.cuboid=function(c){var a=this.g(),c=this.cuboidPath(c);a.front=this.path(c[0]).attr({zIndex:c[3],"stroke-linejoin":"round"}).add(a);a.top=this.path(c[1]).attr({zIndex:c[4],"stroke-linejoin":"round"}).add(a);a.side=this.path(c[2]).attr({zIndex:c[5],"stroke-linejoin":"round"}).add(a);a.fillSetter=function(a){var c=d.Color(a).brighten(0.1).get(),f=d.Color(a).brighten(-0.1).get();this.front.attr({fill:a});this.top.attr({fill:c});
13
+ this.side.attr({fill:f});this.color=a;return this};a.opacitySetter=function(a){this.front.attr({opacity:a});this.top.attr({opacity:a});this.side.attr({opacity:a});return this};a.attr=function(a){a.shapeArgs||o(a.x)?(a=this.renderer.cuboidPath(a.shapeArgs||a),this.front.attr({d:a[0],zIndex:a[3]}),this.top.attr({d:a[1],zIndex:a[4]}),this.side.attr({d:a[2],zIndex:a[5]})):d.SVGElement.prototype.attr.call(this,a);return this};a.animate=function(a,c,f){o(a.x)&&o(a.y)?(a=this.renderer.cuboidPath(a),this.front.attr({zIndex:a[3]}).animate({d:a[0]},
14
+ c,f),this.top.attr({zIndex:a[4]}).animate({d:a[1]},c,f),this.side.attr({zIndex:a[5]}).animate({d:a[2]},c,f)):a.opacity?(this.front.animate(a,c,f),this.top.animate(a,c,f),this.side.animate(a,c,f)):d.SVGElement.prototype.animate.call(this,a,c,f);return this};a.destroy=function(){this.front.destroy();this.top.destroy();this.side.destroy();return null};a.attr({zIndex:-c[3]});return a};d.SVGRenderer.prototype.cuboidPath=function(c){var a=c.x,b=c.y,e=c.z,f=c.height,g=c.width,i=c.depth,j=d.map,h=[{x:a,y:b,
15
+ z:e},{x:a+g,y:b,z:e},{x:a+g,y:b+f,z:e},{x:a,y:b+f,z:e},{x:a,y:b+f,z:e+i},{x:a+g,y:b+f,z:e+i},{x:a+g,y:b,z:e+i},{x:a,y:b,z:e+i}],h=n(h,d.charts[this.chartIndex],c.insidePlotArea),b=function(a,b){a=j(a,function(a){return h[a]});b=j(b,function(a){return h[a]});return E(a)<0?a:E(b)<0?b:[]},c=b([3,2,1,0],[7,6,5,4]),a=b([1,6,7,0],[4,5,2,3]),b=b([1,2,5,6],[0,7,4,3]);return[this.toLinePath(c,!0),this.toLinePath(a,!0),this.toLinePath(b,!0),C(c),C(a),C(b)]};d.SVGRenderer.prototype.arc3d=function(c){c.alpha*=
16
+ x;c.beta*=x;var a=this.g(),b=this.arc3dPath(c),e=a.renderer,f=b.zTop*100;a.shapeArgs=c;a.top=e.path(b.top).setRadialReference(c.center).attr({zIndex:b.zTop}).add(a);a.side1=e.path(b.side2).attr({zIndex:b.zSide1});a.side2=e.path(b.side1).attr({zIndex:b.zSide2});a.inn=e.path(b.inn).attr({zIndex:b.zInn});a.out=e.path(b.out).attr({zIndex:b.zOut});a.fillSetter=function(a){this.color=a;var b=d.Color(a).brighten(-0.1).get();this.side1.attr({fill:b});this.side2.attr({fill:b});this.inn.attr({fill:b});this.out.attr({fill:b});
17
+ this.top.attr({fill:a});return this};a.translateXSetter=function(a){this.out.attr({translateX:a});this.inn.attr({translateX:a});this.side1.attr({translateX:a});this.side2.attr({translateX:a});this.top.attr({translateX:a})};a.translateYSetter=function(a){this.out.attr({translateY:a});this.inn.attr({translateY:a});this.side1.attr({translateY:a});this.side2.attr({translateY:a});this.top.attr({translateY:a})};a.animate=function(a,b,c){o(a.end)||o(a.start)?(this._shapeArgs=this.shapeArgs,d.SVGElement.prototype.animate.call(this,
18
+ {_args:a},{duration:b,step:function(){var a=arguments[1],b=a.elem,c=b._shapeArgs,e=a.end,a=a.pos,c=d.merge(c,{x:c.x+(e.x-c.x)*a,y:c.y+(e.y-c.y)*a,r:c.r+(e.r-c.r)*a,innerR:c.innerR+(e.innerR-c.innerR)*a,start:c.start+(e.start-c.start)*a,end:c.end+(e.end-c.end)*a}),e=b.renderer.arc3dPath(c);b.shapeArgs=c;b.top.attr({d:e.top,zIndex:e.zTop});b.inn.attr({d:e.inn,zIndex:e.zInn});b.out.attr({d:e.out,zIndex:e.zOut});b.side1.attr({d:e.side1,zIndex:e.zSide1});b.side2.attr({d:e.side2,zIndex:e.zSide2})}},c)):
19
+ d.SVGElement.prototype.animate.call(this,a,b,c);return this};a.destroy=function(){this.top.destroy();this.out.destroy();this.inn.destroy();this.side1.destroy();this.side2.destroy();d.SVGElement.prototype.destroy.call(this)};a.hide=function(){this.top.hide();this.out.hide();this.inn.hide();this.side1.hide();this.side2.hide()};a.show=function(){this.top.show();this.out.show();this.inn.show();this.side1.show();this.side2.show()};a.zIndex=f;a.attr({zIndex:f});return a};d.SVGRenderer.prototype.arc3dPath=
20
+ function(c){var a=c.x,b=c.y,e=c.start,d=c.end-1.0E-5,g=c.r,i=c.innerR,j=c.depth,h=c.alpha,k=c.beta,v=m(e),p=l(e),c=m(d),n=l(d),s=g*m(k),t=g*m(h),u=i*m(k);i*=m(h);var w=j*l(k),o=j*l(h),j=["M",a+s*v,b+t*p],j=j.concat(r(a,b,s,t,e,d,0,0)),j=j.concat(["L",a+u*c,b+i*n]),j=j.concat(r(a,b,u,i,d,e,0,0)),j=j.concat(["Z"]),k=k>0?q/2:0,h=h>0?0:q/2,k=e>-k?e:d>-k?-k:e,x=d<q-h?d:e<q-h?q-h:d,h=["M",a+s*m(k),b+t*l(k)],h=h.concat(r(a,b,s,t,k,x,0,0)),h=h.concat(["L",a+s*m(x)+w,b+t*l(x)+o]),h=h.concat(r(a,b,s,t,x,k,
21
+ w,o)),h=h.concat(["Z"]),k=["M",a+u*v,b+i*p],k=k.concat(r(a,b,u,i,e,d,0,0)),k=k.concat(["L",a+u*m(d)+w,b+i*l(d)+o]),k=k.concat(r(a,b,u,i,d,e,w,o)),k=k.concat(["Z"]),v=["M",a+s*v,b+t*p,"L",a+s*v+w,b+t*p+o,"L",a+u*v+w,b+i*p+o,"L",a+u*v,b+i*p,"Z"],a=["M",a+s*c,b+t*n,"L",a+s*c+w,b+t*n+o,"L",a+u*c+w,b+i*n+o,"L",a+u*c,b+i*n,"Z"],b=l((e+d)/2),e=l(e),d=l(d);return{top:j,zTop:g,out:h,zOut:Math.max(b,e,d)*g,inn:k,zInn:Math.max(b,e,d)*g,side1:v,zSide1:e*g*0.99,side2:a,zSide2:d*g*0.99}};d.Chart.prototype.is3d=
22
+ function(){return this.options.chart.options3d&&this.options.chart.options3d.enabled};d.wrap(d.Chart.prototype,"isInsidePlot",function(c){return this.is3d()?!0:c.apply(this,[].slice.call(arguments,1))});d.getOptions().chart.options3d={enabled:!1,alpha:0,beta:0,depth:100,viewDistance:25,frame:{bottom:{size:1,color:"rgba(255,255,255,0)"},side:{size:1,color:"rgba(255,255,255,0)"},back:{size:1,color:"rgba(255,255,255,0)"}}};d.wrap(d.Chart.prototype,"init",function(c){var a=[].slice.call(arguments,1),
23
+ b;if(a[0].chart.options3d&&a[0].chart.options3d.enabled)b=a[0].plotOptions||{},b=b.pie||{},b.borderColor=d.pick(b.borderColor,void 0);c.apply(this,a)});d.wrap(d.Chart.prototype,"setChartSize",function(c){c.apply(this,[].slice.call(arguments,1));if(this.is3d()){var a=this.inverted,b=this.clipBox,d=this.margin;b[a?"y":"x"]=-(d[3]||0);b[a?"x":"y"]=-(d[0]||0);b[a?"height":"width"]=this.chartWidth+(d[3]||0)+(d[1]||0);b[a?"width":"height"]=this.chartHeight+(d[0]||0)+(d[2]||0)}});d.wrap(d.Chart.prototype,
24
+ "redraw",function(c){if(this.is3d())this.isDirtyBox=!0;c.apply(this,[].slice.call(arguments,1))});d.wrap(d.Chart.prototype,"renderSeries",function(c){var a=this.series.length;if(this.is3d())for(;a--;)c=this.series[a],c.translate(),c.render();else c.call(this)});d.Chart.prototype.retrieveStacks=function(c){var a=this.series,b={},e,f=1;d.each(this.series,function(d){e=c?d.options.stack||0:a.length-1-d.index;b[e]?b[e].series.push(d):(b[e]={series:[d],position:f},f++)});b.totalStacks=f+1;return b};d.wrap(d.Axis.prototype,
25
+ "init",function(c){var a=arguments;if(a[1].is3d())a[2].tickWidth=d.pick(a[2].tickWidth,0),a[2].gridLineWidth=d.pick(a[2].gridLineWidth,1);c.apply(this,[].slice.call(arguments,1))});d.wrap(d.Axis.prototype,"render",function(c){c.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var a=this.chart,b=a.renderer,d=a.options.chart.options3d,f=d.frame,g=f.bottom,i=f.back,f=f.side,j=d.depth,h=this.height,k=this.width,l=this.left,p=this.top;if(!this.isZAxis)this.horiz?(i={x:l,y:p+(a.xAxis[0].opposite?
26
+ -g.size:h),z:0,width:k,height:g.size,depth:j,insidePlotArea:!1},this.bottomFrame?this.bottomFrame.animate(i):this.bottomFrame=b.cuboid(i).attr({fill:g.color,zIndex:a.yAxis[0].reversed&&d.alpha>0?4:-1}).css({stroke:g.color}).add()):(d={x:l+(a.yAxis[0].opposite?0:-f.size),y:p+(a.xAxis[0].opposite?-g.size:0),z:j,width:k+f.size,height:h+g.size,depth:i.size,insidePlotArea:!1},this.backFrame?this.backFrame.animate(d):this.backFrame=b.cuboid(d).attr({fill:i.color,zIndex:-3}).css({stroke:i.color}).add(),
27
+ a={x:l+(a.yAxis[0].opposite?k:-f.size),y:p+(a.xAxis[0].opposite?-g.size:0),z:0,width:f.size,height:h+g.size,depth:j,insidePlotArea:!1},this.sideFrame?this.sideFrame.animate(a):this.sideFrame=b.cuboid(a).attr({fill:f.color,zIndex:-2}).css({stroke:f.color}).add())}});d.wrap(d.Axis.prototype,"getPlotLinePath",function(c){var a=c.apply(this,[].slice.call(arguments,1));if(!this.chart.is3d())return a;if(a===null)return a;var b=this.chart.options.chart.options3d,b=this.isZAxis?this.chart.plotWidth:b.depth,
28
+ d=this.opposite;this.horiz&&(d=!d);a=[this.swapZ({x:a[1],y:a[2],z:d?b:0}),this.swapZ({x:a[1],y:a[2],z:b}),this.swapZ({x:a[4],y:a[5],z:b}),this.swapZ({x:a[4],y:a[5],z:d?0:b})];a=n(a,this.chart,!1);return a=this.chart.renderer.toLinePath(a,!1)});d.wrap(d.Axis.prototype,"getLinePath",function(){return[]});d.wrap(d.Axis.prototype,"getPlotBandPath",function(c){if(this.chart.is3d()){var a=arguments,b=a[1],a=this.getPlotLinePath(a[2]);(b=this.getPlotLinePath(b))&&a?b.push("L",a[10],a[11],"L",a[7],a[8],"L",
29
+ a[4],a[5],"L",a[1],a[2]):b=null;return b}else return c.apply(this,[].slice.call(arguments,1))});d.wrap(d.Tick.prototype,"getMarkPath",function(c){var a=c.apply(this,[].slice.call(arguments,1));if(!this.axis.chart.is3d())return a;a=[this.axis.swapZ({x:a[1],y:a[2],z:0}),this.axis.swapZ({x:a[4],y:a[5],z:0})];a=n(a,this.axis.chart,!1);return a=["M",a[0].x,a[0].y,"L",a[1].x,a[1].y]});d.wrap(d.Tick.prototype,"getLabelPosition",function(c){var a=c.apply(this,[].slice.call(arguments,1));if(!this.axis.chart.is3d())return a;
30
+ var b=n([this.axis.swapZ({x:a.x,y:a.y,z:0})],this.axis.chart,!1)[0];b.x-=!this.axis.horiz&&this.axis.opposite?this.axis.transA:0;b.old=a;return b});d.wrap(d.Tick.prototype,"handleOverflow",function(c,a){if(this.axis.chart.is3d())a=a.old;return c.call(this,a)});d.wrap(d.Axis.prototype,"getTitlePosition",function(c){var a=c.apply(this,[].slice.call(arguments,1));return!this.chart.is3d()?a:a=n([this.swapZ({x:a.x,y:a.y,z:0})],this.chart,!1)[0]});d.wrap(d.Axis.prototype,"drawCrosshair",function(c){var a=
31
+ arguments;this.chart.is3d()&&a[2]&&(a[2]={plotX:a[2].plotXold||a[2].plotX,plotY:a[2].plotYold||a[2].plotY});c.apply(this,[].slice.call(a,1))});d.Axis.prototype.swapZ=function(c,a){if(this.isZAxis){var b=a?0:this.chart.plotLeft,d=this.chart;return{x:b+(d.yAxis[0].opposite?c.z:d.xAxis[0].width-c.z),y:c.y,z:c.x-b}}else return c};var D=d.ZAxis=function(){this.isZAxis=!0;this.init.apply(this,arguments)};d.extend(D.prototype,d.Axis.prototype);d.extend(D.prototype,{setOptions:function(c){c=d.merge({offset:0,
32
+ lineWidth:0},c);d.Axis.prototype.setOptions.call(this,c);this.coll="zAxis"},setAxisSize:function(){d.Axis.prototype.setAxisSize.call(this);this.width=this.len=this.chart.options.chart.options3d.depth;this.right=this.chart.chartWidth-this.width-this.left},getSeriesExtremes:function(){var c=this,a=c.chart;c.hasVisibleSeries=!1;c.dataMin=c.dataMax=c.ignoreMinPadding=c.ignoreMaxPadding=null;c.buildStacks&&c.buildStacks();d.each(c.series,function(b){if(b.visible||!a.options.chart.ignoreHiddenSeries)if(c.hasVisibleSeries=
33
+ !0,b=b.zData,b.length)c.dataMin=Math.min(y(c.dataMin,b[0]),Math.min.apply(null,b)),c.dataMax=Math.max(y(c.dataMax,b[0]),Math.max.apply(null,b))})}});d.wrap(d.Chart.prototype,"getAxes",function(c){var a=this,b=this.options,b=b.zAxis=d.splat(b.zAxis||{});c.call(this);if(a.is3d())this.zAxis=[],d.each(b,function(b,c){b.index=c;b.isX=!0;(new D(a,b)).setScale()})});d.wrap(d.seriesTypes.column.prototype,"translate",function(c){c.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var a=this.chart,
34
+ b=this.options,e=b.depth||25,f=(b.stacking?b.stack||0:this._i)*(e+(b.groupZPadding||1));b.grouping!==!1&&(f=0);f+=b.groupZPadding||1;d.each(this.data,function(b){if(b.y!==null){var c=b.shapeArgs,d=b.tooltipPos;b.shapeType="cuboid";c.z=f;c.depth=e;c.insidePlotArea=!0;d=n([{x:d[0],y:d[1],z:f}],a,!1)[0];b.tooltipPos=[d.x,d.y]}});this.z=f}});d.wrap(d.seriesTypes.column.prototype,"animate",function(c){if(this.chart.is3d()){var a=arguments[1],b=this.yAxis,e=this,f=this.yAxis.reversed;if(d.svg)a?d.each(e.data,
35
+ function(a){if(a.y!==null&&(a.height=a.shapeArgs.height,a.shapey=a.shapeArgs.y,a.shapeArgs.height=1,!f))a.shapeArgs.y=a.stackY?a.plotY+b.translate(a.stackY):a.plotY+(a.negative?-a.height:a.height)}):(d.each(e.data,function(a){if(a.y!==null)a.shapeArgs.height=a.height,a.shapeArgs.y=a.shapey,a.graphic&&a.graphic.animate(a.shapeArgs,e.options.animation)}),this.drawDataLabels(),e.animate=null)}else c.apply(this,[].slice.call(arguments,1))});d.wrap(d.seriesTypes.column.prototype,"init",function(c){c.apply(this,
36
+ [].slice.call(arguments,1));if(this.chart.is3d()){var a=this.options,b=a.grouping,d=a.stacking,f=0;if(b===void 0||b){b=this.chart.retrieveStacks(d);d=a.stack||0;for(f=0;f<b[d].series.length;f++)if(b[d].series[f]===this)break;f=b.totalStacks*10-10*(b.totalStacks-b[d].position)-f}a.zIndex=f}});d.wrap(d.Series.prototype,"alignDataLabel",function(c){if(this.chart.is3d()&&(this.type==="column"||this.type==="columnrange")){var a=arguments[4],b={x:a.x,y:a.y,z:this.z},b=n([b],this.chart,!0)[0];a.x=b.x;a.y=
37
+ b.y}c.apply(this,[].slice.call(arguments,1))});d.seriesTypes.columnrange&&d.wrap(d.seriesTypes.columnrange.prototype,"drawPoints",F);d.wrap(d.seriesTypes.column.prototype,"drawPoints",F);d.wrap(d.seriesTypes.pie.prototype,"translate",function(c){c.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var a=this,b=a.chart,e=a.options,f=e.depth||0,g=b.options.chart.options3d,i={x:b.plotWidth/2,y:b.plotHeight/2,z:g.depth},j=g.alpha,h=g.beta,k=e.stacking?(e.stack||0)*f:a._i*f;k+=f/2;e.grouping!==
38
+ !1&&(k=0);d.each(a.data,function(b){var c=b.shapeArgs;b.shapeType="arc3d";c.z=k;c.depth=f*0.75;c.origin=i;c.alpha=j;c.beta=h;c.center=a.center;c=(c.end+c.start)/2;b.slicedTranslation={translateX:G(m(c)*e.slicedOffset*m(j*x)),translateY:G(l(c)*e.slicedOffset*m(j*x))}})}});d.wrap(d.seriesTypes.pie.prototype.pointClass.prototype,"haloPath",function(c){var a=arguments;return this.series.chart.is3d()?[]:c.call(this,a[1])});d.wrap(d.seriesTypes.pie.prototype,"drawPoints",function(c){var a=this.group,b=
39
+ this.options,e=b.states;if(this.chart.is3d())this.borderWidth=b.borderWidth=b.edgeWidth||1,this.borderColor=b.edgeColor=d.pick(b.edgeColor,b.borderColor,void 0),e.hover.borderColor=d.pick(e.hover.edgeColor,this.borderColor),e.hover.borderWidth=d.pick(e.hover.edgeWidth,this.borderWidth),e.select.borderColor=d.pick(e.select.edgeColor,this.borderColor),e.select.borderWidth=d.pick(e.select.edgeWidth,this.borderWidth),d.each(this.data,function(a){var b=a.pointAttr;b[""].stroke=a.series.borderColor||a.color;
40
+ b[""]["stroke-width"]=a.series.borderWidth;b.hover.stroke=e.hover.borderColor;b.hover["stroke-width"]=e.hover.borderWidth;b.select.stroke=e.select.borderColor;b.select["stroke-width"]=e.select.borderWidth});c.apply(this,[].slice.call(arguments,1));this.chart.is3d()&&d.each(this.points,function(b){var c=b.graphic;c.out.add(a);c.inn.add(a);c.side1.add(a);c.side2.add(a);c[b.y?"show":"hide"]()})});d.wrap(d.seriesTypes.pie.prototype,"drawDataLabels",function(c){if(this.chart.is3d()){var a=this;d.each(a.data,
41
+ function(b){var c=b.shapeArgs,d=c.r,g=c.depth,i=(c.alpha||a.chart.options.chart.options3d.alpha)*x,c=(c.start+c.end)/2,b=b.labelPos;b[1]+=-d*(1-m(i))*l(c)+(l(c)>0?l(i)*g:0);b[3]+=-d*(1-m(i))*l(c)+(l(c)>0?l(i)*g:0);b[5]+=-d*(1-m(i))*l(c)+(l(c)>0?l(i)*g:0)})}c.apply(this,[].slice.call(arguments,1))});d.wrap(d.seriesTypes.pie.prototype,"addPoint",function(c){c.apply(this,[].slice.call(arguments,1));this.chart.is3d()&&this.update(this.userOptions,!0)});d.wrap(d.seriesTypes.pie.prototype,"animate",function(c){if(this.chart.is3d()){var a=
42
+ arguments[1],b=this.options.animation,e=this.center,f=this.group,g=this.markerGroup;if(d.svg)if(b===!0&&(b={}),a){if(f.oldtranslateX=f.translateX,f.oldtranslateY=f.translateY,a={translateX:e[0],translateY:e[1],scaleX:0.001,scaleY:0.001},f.attr(a),g)g.attrSetters=f.attrSetters,g.attr(a)}else a={translateX:f.oldtranslateX,translateY:f.oldtranslateY,scaleX:1,scaleY:1},f.animate(a,b),g&&g.animate(a,b),this.animate=null}else c.apply(this,[].slice.call(arguments,1))});d.wrap(d.seriesTypes.scatter.prototype,
43
+ "translate",function(c){c.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var a=this.chart,b=d.pick(this.zAxis,a.options.zAxis[0]),e=[],f,g;for(g=0;g<this.data.length;g++)f=this.data[g],f.isInside=f.isInside?f.z>=b.min&&f.z<=b.max:!1,e.push({x:f.plotX,y:f.plotY,z:b.translate(f.z)});a=n(e,a,!0);for(g=0;g<this.data.length;g++)f=this.data[g],b=a[g],f.plotXold=f.plotX,f.plotYold=f.plotY,f.plotX=b.x,f.plotY=b.y,f.plotZ=b.z}});d.wrap(d.seriesTypes.scatter.prototype,"init",function(c,a,b){if(a.is3d())this.axisTypes=
44
+ ["xAxis","yAxis","zAxis"],this.pointArrayMap=["x","y","z"],this.parallelArrays=["x","y","z"];c=c.apply(this,[a,b]);if(this.chart.is3d())this.tooltipOptions.pointFormat=this.userOptions.tooltip?this.userOptions.tooltip.pointFormat||"x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>z: <b>{point.z}</b><br/>":"x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>z: <b>{point.z}</b><br/>";return c});if(d.VMLRenderer)d.setOptions({animate:!1}),d.VMLRenderer.prototype.cuboid=d.SVGRenderer.prototype.cuboid,d.VMLRenderer.prototype.cuboidPath=
45
+ d.SVGRenderer.prototype.cuboidPath,d.VMLRenderer.prototype.toLinePath=d.SVGRenderer.prototype.toLinePath,d.VMLRenderer.prototype.createElement3D=d.SVGRenderer.prototype.createElement3D,d.VMLRenderer.prototype.arc3d=function(c){c=d.SVGRenderer.prototype.arc3d.call(this,c);c.css({zIndex:c.zIndex});return c},d.VMLRenderer.prototype.arc3dPath=d.SVGRenderer.prototype.arc3dPath,d.wrap(d.Axis.prototype,"render",function(c){c.apply(this,[].slice.call(arguments,1));this.sideFrame&&(this.sideFrame.css({zIndex:0}),
46
+ this.sideFrame.front.attr({fill:this.sideFrame.color}));this.bottomFrame&&(this.bottomFrame.css({zIndex:1}),this.bottomFrame.front.attr({fill:this.bottomFrame.color}));this.backFrame&&(this.backFrame.css({zIndex:0}),this.backFrame.front.attr({fill:this.backFrame.color}))})})(Highcharts);
@@ -0,0 +1,620 @@
1
+ /**
2
+ * @license Highcharts JS v3.0.1 (2012-11-02)
3
+ *
4
+ * (c) 20013-2014
5
+ *
6
+ * Author: Gert Vaartjes
7
+ *
8
+ * License: www.highcharts.com/license
9
+ *
10
+ * version: 2.0.1
11
+ */
12
+
13
+ /*jslint white: true */
14
+ /*global window, require, phantom, console, $, document, Image, Highcharts, clearTimeout, clearInterval, options, cb, globalOptions, dataOptions, customCode */
15
+
16
+
17
+ (function () {
18
+ "use strict";
19
+
20
+ var config = {
21
+ /* define locations of mandatory javascript files.
22
+ * Depending on purchased license change the HIGHCHARTS property to
23
+ * highcharts.js or highstock.js
24
+ */
25
+
26
+ files: {
27
+ highcharts: {
28
+ JQUERY: 'jquery.1.9.1.min.js',
29
+ HIGHCHARTS: 'highcharts.js',
30
+ HIGHCHARTS_MORE: 'highcharts-more.js',
31
+ HIGHCHARTS_DATA: 'data.js',
32
+ HIGHCHARTS_DRILLDOWN: 'drilldown.js',
33
+ HIGHCHARTS_FUNNEL: 'funnel.js',
34
+ HIGHCHARTS_HEATMAP: 'heatmap.js',
35
+ HIGHCHARTS_TREEMAP: 'treemap.js',
36
+ HIGHCHARTS_3D: 'highcharts-3d.js',
37
+ HIGHCHARTS_NODATA: 'no-data-to-display.js',
38
+ // Uncomment below if you have both Highcharts and Highmaps license
39
+ // HIGHCHARTS_MAP: 'map.js',
40
+ HIGHCHARTS_SOLID_GAUGE: 'solid-gauge.js',
41
+ BROKEN_AXIS: 'broken-axis.js'
42
+ },
43
+ highstock: {
44
+ JQUERY: 'jquery.1.9.1.min.js',
45
+ HIGHCHARTS: 'highcharts.js',
46
+ HIGHCHARTS_MORE: 'highcharts-more.js',
47
+ HIGHCHARTS_DATA: 'data.js',
48
+ HIGHCHARTS_DRILLDOWN: 'drilldown.js',
49
+ HIGHCHARTS_FUNNEL: 'funnel.js',
50
+ HIGHCHARTS_HEATMAP: 'heatmap.js',
51
+ HIGHCHARTS_TREEMAP: 'treemap.js',
52
+ HIGHCHARTS_3D: 'highcharts-3d.js',
53
+ HIGHCHARTS_NODATA: 'no-data-to-display.js',
54
+ // Uncomment below if you have both Highstock and Highmaps license
55
+ // HIGHCHARTS_MAP: 'map.js',
56
+ HIGHCHARTS_SOLID_GAUGE: 'solid-gauge.js',
57
+ BROKEN_AXIS: 'broken-axis.js'
58
+ },
59
+ highmaps: {
60
+ JQUERY: 'jquery.1.9.1.min.js',
61
+ HIGHCHARTS: 'highmaps.js',
62
+ HIGHCHARTS_DATA: 'data.js',
63
+ HIGHCHARTS_DRILLDOWN: 'drilldown.js',
64
+ HIGHCHARTS_HEATMAP: 'heatmap.js',
65
+ HIGHCHARTS_NODATA: 'no-data-to-display.js'
66
+ }
67
+ },
68
+ TIMEOUT: 5000 /* 5 seconds timout for loading images */
69
+ },
70
+ mapCLArguments,
71
+ render,
72
+ startServer = false,
73
+ args,
74
+ pick,
75
+ SVG_DOCTYPE = '<?xml version=\"1.0" standalone=\"no\"?><!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">',
76
+ dpiCorrection = 1.4,
77
+ system = require('system'),
78
+ fs = require('fs'),
79
+ serverMode = false;
80
+
81
+ pick = function () {
82
+ var args = arguments, i, arg, length = args.length;
83
+ for (i = 0; i < length; i += 1) {
84
+ arg = args[i];
85
+ if (arg !== undefined && arg !== null && arg !== 'null' && arg != '0') {
86
+ return arg;
87
+ }
88
+ }
89
+ };
90
+
91
+ mapCLArguments = function () {
92
+ var map = {},
93
+ i,
94
+ key;
95
+
96
+ if (system.args.length < 1) {
97
+ console.log('Commandline Usage: highcharts-convert.js -infile URL -outfile filename -scale 2.5 -width 300 -constr Chart -callback callback.js');
98
+ console.log(', or run PhantomJS as server: highcharts-convert.js -host 127.0.0.1 -port 1234');
99
+ }
100
+
101
+ for (i = 0; i < system.args.length; i += 1) {
102
+ if (system.args[i].charAt(0) === '-') {
103
+ key = system.args[i].substr(1, i.length);
104
+ if (key === 'infile' || key === 'callback' || key === 'dataoptions' || key === 'globaloptions' || key === 'customcode') {
105
+ // get string from file
106
+ try {
107
+ map[key] = fs.read(system.args[i + 1]).replace(/^\s+/, '');
108
+ } catch (e) {
109
+ console.log('Error: cannot find file, ' + system.args[i + 1]);
110
+ phantom.exit();
111
+ }
112
+ } else {
113
+ map[key] = system.args[i + 1];
114
+ }
115
+ }
116
+ }
117
+ return map;
118
+ };
119
+
120
+ render = function (params, exitCallback) {
121
+
122
+ var page = require('webpage').create(),
123
+ messages = {},
124
+ scaleAndClipPage,
125
+ loadChart,
126
+ createChart,
127
+ input,
128
+ constr,
129
+ callback,
130
+ width,
131
+ output,
132
+ outType,
133
+ timer,
134
+ renderSVG,
135
+ convert,
136
+ exit,
137
+ interval,
138
+ counter,
139
+ imagesLoaded = false;
140
+
141
+ messages.optionsParsed = 'Highcharts.options.parsed';
142
+ messages.callbackParsed = 'Highcharts.cb.parsed';
143
+
144
+ window.optionsParsed = false;
145
+ window.callbackParsed = false;
146
+
147
+ page.onConsoleMessage = function (msg) {
148
+ console.log(msg);
149
+
150
+ /*
151
+ * Ugly hack, but only way to get messages out of the 'page.evaluate()'
152
+ * sandbox. If any, please contribute with improvements on this!
153
+ */
154
+
155
+ /* to check options or callback are properly parsed */
156
+ if (msg === messages.optionsParsed) {
157
+ window.optionsParsed = true;
158
+ }
159
+
160
+ if (msg === messages.callbackParsed) {
161
+ window.callbackParsed = true;
162
+ }
163
+ };
164
+
165
+ page.onAlert = function (msg) {
166
+ console.log(msg);
167
+ };
168
+
169
+ /* scale and clip the page */
170
+ scaleAndClipPage = function (svg) {
171
+ /* param: svg: The scg configuration object
172
+ */
173
+
174
+ var zoom = 1,
175
+ pageWidth = pick(params.width, svg.width),
176
+ clipwidth,
177
+ clipheight;
178
+
179
+ if (parseInt(pageWidth, 10) == pageWidth) {
180
+ zoom = pageWidth / svg.width;
181
+ }
182
+
183
+ /* set this line when scale factor has a higher precedence
184
+ scale has precedence : page.zoomFactor = params.scale ? zoom * params.scale : zoom;*/
185
+
186
+ /* params.width has a higher precedence over scaling, to not break backover compatibility */
187
+ page.zoomFactor = params.scale && params.width == undefined ? zoom * params.scale : zoom;
188
+
189
+ clipwidth = svg.width * page.zoomFactor;
190
+ clipheight = svg.height * page.zoomFactor;
191
+
192
+ /* define the clip-rectangle */
193
+ /* ignored for PDF, see https://github.com/ariya/phantomjs/issues/10465 */
194
+ page.clipRect = {
195
+ top: 0,
196
+ left: 0,
197
+ width: clipwidth,
198
+ height: clipheight
199
+ };
200
+
201
+ /* for pdf we need a bit more paperspace in some cases for example (w:600,h:400), I don't know why.*/
202
+ if (outType === 'pdf') {
203
+ // changed to a multiplication with 1.333 to correct systems dpi setting
204
+ clipwidth = clipwidth * dpiCorrection;
205
+ clipheight = clipheight * dpiCorrection;
206
+ // redefine the viewport
207
+ page.viewportSize = { width: clipwidth, height: clipheight};
208
+ // make the paper a bit larger than the viewport
209
+ page.paperSize = { width: clipwidth + 2 , height: clipheight + 2 };
210
+ }
211
+ };
212
+
213
+ exit = function (result) {
214
+ if (serverMode) {
215
+ //Calling page.close(), may stop the increasing heap allocation
216
+ page.close();
217
+ }
218
+ exitCallback(result);
219
+ };
220
+
221
+ convert = function (svg) {
222
+ var base64;
223
+ scaleAndClipPage(svg);
224
+ if (outType === 'pdf' || output !== undefined || !serverMode) {
225
+ if (output === undefined) {
226
+ // in case of pdf files
227
+ output = config.tmpDir + '/chart.' + outType;
228
+ }
229
+ page.render(output);
230
+ exit(output);
231
+ } else {
232
+ base64 = page.renderBase64(outType);
233
+ exit(base64);
234
+ }
235
+ };
236
+
237
+ function decrementImgCounter() {
238
+ counter -= 1;
239
+ if (counter < 1) {
240
+ imagesLoaded = true;
241
+ }
242
+ }
243
+
244
+ function loadImages(imgUrls) {
245
+ var i, img;
246
+ counter = imgUrls.length;
247
+ for (i = 0; i < imgUrls.length; i += 1) {
248
+ img = new Image();
249
+ /* onload decrements the counter, also when error (perhaps 404), don't wait for this image to be loaded */
250
+ img.onload = img.onerror = decrementImgCounter;
251
+ /* force loading of images by setting the src attr.*/
252
+ img.src = imgUrls[i];
253
+ }
254
+ }
255
+
256
+ renderSVG = function (svg) {
257
+ var svgFile;
258
+ // From this point we have 'loaded' or 'created' a SVG
259
+
260
+ // Do we have to load images?
261
+ if (svg.imgUrls.length > 0) {
262
+ loadImages(svg.imgUrls);
263
+ } else {
264
+ // no images present, no loading, no waiting
265
+ imagesLoaded = true;
266
+ }
267
+
268
+ try {
269
+ if (outType.toLowerCase() === 'svg') {
270
+ // output svg
271
+ svg = svg.html.replace(/<svg /, '<svg xmlns:xlink="http://www.w3.org/1999/xlink" ').replace(/ href=/g, ' xlink:href=').replace(/<\/svg>.*?$/, '</svg>');
272
+ // add xml doc type
273
+ svg = SVG_DOCTYPE + svg;
274
+
275
+ if (output !== undefined) {
276
+ // write the file
277
+ svgFile = fs.open(output, "w");
278
+ svgFile.write(svg);
279
+ svgFile.close();
280
+ exit(output);
281
+ } else {
282
+ // return the svg as a string
283
+ exit(svg);
284
+ }
285
+
286
+ } else {
287
+ // output binary images or pdf
288
+ if (!imagesLoaded) {
289
+ // render with interval, waiting for all images loaded
290
+ interval = window.setInterval(function () {
291
+ if (imagesLoaded) {
292
+ clearTimeout(timer);
293
+ clearInterval(interval);
294
+ convert(svg);
295
+ }
296
+ }, 50);
297
+
298
+ // we have a 5 second timeframe..
299
+ timer = window.setTimeout(function () {
300
+ clearInterval(interval);
301
+ exitCallback('ERROR: While rendering, there\'s is a timeout reached');
302
+ }, config.TIMEOUT);
303
+ } else {
304
+ // images are loaded, render rightaway
305
+ convert(svg);
306
+ }
307
+ }
308
+ } catch (e) {
309
+ console.log('ERROR: While rendering, ' + e);
310
+ }
311
+ };
312
+
313
+ loadChart = function (input, outputType) {
314
+ var nodeIter, nodes, elem, opacity, svgElem, imgs, imgUrls, imgIndex;
315
+
316
+ document.body.style.margin = '0px';
317
+ document.body.innerHTML = input;
318
+
319
+ if (outputType === 'jpeg') {
320
+ document.body.style.backgroundColor = 'white';
321
+ }
322
+
323
+ nodes = document.querySelectorAll('*[stroke-opacity]');
324
+
325
+ for (nodeIter = 0; nodeIter < nodes.length; nodeIter += 1) {
326
+ elem = nodes[nodeIter];
327
+ opacity = elem.getAttribute('stroke-opacity');
328
+ elem.removeAttribute('stroke-opacity');
329
+ elem.setAttribute('opacity', opacity);
330
+ }
331
+
332
+ svgElem = document.getElementsByTagName('svg')[0];
333
+
334
+ imgs = document.getElementsByTagName('image');
335
+ imgUrls = [];
336
+
337
+ for (imgIndex = 0; imgIndex < imgs.length; imgIndex = imgIndex + 1) {
338
+ imgUrls.push(imgs[imgIndex].href.baseVal);
339
+ }
340
+
341
+ return {
342
+ html: document.body.innerHTML,
343
+ width: svgElem.getAttribute("width"),
344
+ height: svgElem.getAttribute("height"),
345
+ imgUrls: imgUrls
346
+ };
347
+ };
348
+
349
+ createChart = function (constr, input, globalOptionsArg, dataOptionsArg, customCodeArg, outputType, callback, messages) {
350
+
351
+ var $container, chart, nodes, nodeIter, elem, opacity, imgIndex, imgs, imgUrls;
352
+
353
+ // dynamic script insertion
354
+ function loadScript(varStr, codeStr) {
355
+ var $script = $('<script>').attr('type', 'text/javascript');
356
+ $script.html('var ' + varStr + ' = ' + codeStr);
357
+ document.getElementsByTagName("head")[0].appendChild($script[0]);
358
+ if (window[varStr] !== undefined) {
359
+ console.log('Highcharts.' + varStr + '.parsed');
360
+ }
361
+ }
362
+
363
+ function parseData(completeHandler, chartOptions, dataConfig) {
364
+ try {
365
+ dataConfig.complete = completeHandler;
366
+ Highcharts.data(dataConfig, chartOptions);
367
+ } catch (error) {
368
+ completeHandler(undefined);
369
+ }
370
+ }
371
+
372
+ if (input !== 'undefined') {
373
+ loadScript('options', input);
374
+ }
375
+
376
+ if (callback !== 'undefined') {
377
+ loadScript('cb', callback);
378
+ }
379
+
380
+ if (globalOptionsArg !== 'undefined') {
381
+ loadScript('globalOptions', globalOptionsArg);
382
+ }
383
+
384
+ if (dataOptionsArg !== 'undefined') {
385
+ loadScript('dataOptions', dataOptionsArg);
386
+ }
387
+
388
+ if (customCodeArg !== 'undefined') {
389
+ loadScript('customCode', customCodeArg);
390
+ }
391
+
392
+ $(document.body).css('margin', '0px');
393
+
394
+ if (outputType === 'jpeg') {
395
+ $(document.body).css('backgroundColor', 'white');
396
+ }
397
+
398
+ $container = $('<div>').appendTo(document.body);
399
+ $container.attr('id', 'container');
400
+
401
+ // disable animations
402
+ Highcharts.SVGRenderer.prototype.Element.prototype.animate = Highcharts.SVGRenderer.prototype.Element.prototype.attr;
403
+ Highcharts.setOptions({
404
+ plotOptions: {
405
+ series: {
406
+ animation: false
407
+ }
408
+ }
409
+ });
410
+
411
+ if (!options.chart) {
412
+ options.chart = {};
413
+ }
414
+
415
+ options.chart.renderTo = $container[0];
416
+
417
+ // check if witdh is set. Order of precedence:
418
+ // args.width, options.chart.width and 600px
419
+
420
+ // OLD. options.chart.width = width || options.chart.width || 600;
421
+ // Notice we don't use commandline parameter width here. Commandline parameter width is used for scaling.
422
+
423
+ options.chart.width = (options.exporting && options.exporting.sourceWidth) || options.chart.width || 600;
424
+ options.chart.height = (options.exporting && options.exporting.sourceHeight) || options.chart.height || 400;
425
+
426
+ // Load globalOptions
427
+ if (globalOptions) {
428
+ Highcharts.setOptions(globalOptions);
429
+ }
430
+
431
+ // Load data
432
+ if (dataOptions) {
433
+ parseData(function completeHandler(opts) {
434
+ // Merge series configs
435
+ if (options.series) {
436
+ Highcharts.each(options.series, function (series, i) {
437
+ options.series[i] = Highcharts.merge(series, opts.series[i]);
438
+ });
439
+ }
440
+
441
+ var mergedOptions = Highcharts.merge(opts, options);
442
+
443
+ // Run customCode
444
+ if (customCode) {
445
+ customCode(mergedOptions);
446
+ }
447
+
448
+ chart = new Highcharts[constr](mergedOptions, cb);
449
+
450
+ }, options, dataOptions);
451
+ } else {
452
+ chart = new Highcharts[constr](options, cb);
453
+ }
454
+
455
+ /* remove stroke-opacity paths, used by mouse-trackers, they turn up as
456
+ * as fully opaque in the PDF
457
+ */
458
+ nodes = document.querySelectorAll('*[stroke-opacity]');
459
+
460
+ for (nodeIter = 0; nodeIter < nodes.length; nodeIter += 1) {
461
+ elem = nodes[nodeIter];
462
+ opacity = elem.getAttribute('stroke-opacity');
463
+ elem.removeAttribute('stroke-opacity');
464
+ elem.setAttribute('opacity', opacity);
465
+ }
466
+
467
+ imgs = document.getElementsByTagName('image');
468
+ imgUrls = [];
469
+
470
+ for (imgIndex = 0; imgIndex < imgs.length; imgIndex = imgIndex + 1) {
471
+ imgUrls.push(imgs[imgIndex].href.baseVal);
472
+ }
473
+
474
+ return {
475
+ html: $('div.highcharts-container')[0].innerHTML,
476
+ width: chart.chartWidth,
477
+ height: chart.chartHeight,
478
+ imgUrls: imgUrls
479
+ };
480
+ };
481
+
482
+ if (params.length < 1) {
483
+ exit("Error: Insufficient parameters");
484
+ } else {
485
+ input = params.infile;
486
+ output = params.outfile;
487
+
488
+ if (output !== undefined) {
489
+ outType = pick(output.split('.').pop(),'png');
490
+ } else {
491
+ outType = pick(params.type,'png');
492
+ }
493
+
494
+ constr = pick(params.constr, 'Chart');
495
+ callback = params.callback;
496
+ width = params.width;
497
+
498
+ if (input === undefined || input.length === 0) {
499
+ exit('Error: Insuficient or wrong parameters for rendering');
500
+ }
501
+
502
+ page.open('about:blank', function (status) {
503
+ var svg,
504
+ globalOptions = params.globaloptions,
505
+ dataOptions = params.dataoptions,
506
+ customCode = 'function customCode(options) {\n' + params.customcode + '}\n',
507
+ jsFile,
508
+ jsFiles;
509
+
510
+ /* Decide if we have to generate a svg first before rendering */
511
+ if (input.substring(0, 4).toLowerCase() === "<svg" || input.substring(0, 5).toLowerCase() === "<?xml"
512
+ || input.substring(0, 9).toLowerCase() === "<!doctype") {
513
+ //render page directly from svg file
514
+ svg = page.evaluate(loadChart, input, outType);
515
+ page.viewportSize = { width: svg.width, height: svg.height };
516
+ renderSVG(svg);
517
+ } else {
518
+ /**
519
+ * We have a js file, let's render serverside from Highcharts options and grab the svg from it
520
+ */
521
+
522
+ // load our javascript dependencies based on the constructor
523
+ if (constr === 'Map') {
524
+ jsFiles = config.files.highmaps;
525
+ } else if (constr === 'StockChart')
526
+ jsFiles = config.files.highstock;
527
+ else {
528
+ jsFiles = config.files.highcharts;
529
+ }
530
+
531
+ // load necessary libraries
532
+ for (jsFile in jsFiles) {
533
+ if (jsFiles.hasOwnProperty(jsFile)) {
534
+ page.injectJs(jsFiles[jsFile]);
535
+ }
536
+ }
537
+
538
+ // load chart in page and return svg height and width
539
+ svg = page.evaluate(createChart, constr, input, globalOptions, dataOptions, customCode, outType, callback, messages);
540
+
541
+ if (!window.optionsParsed) {
542
+ exit('ERROR: the options variable was not available or couldn\'t be parsed, does the infile contain an syntax error? Input used:' + input);
543
+ }
544
+
545
+ if (callback !== undefined && !window.callbackParsed) {
546
+ exit('ERROR: the callback variable was not available, does the callback contain an syntax error? Callback used: ' + callback);
547
+ }
548
+ renderSVG(svg);
549
+ }
550
+ });
551
+ }
552
+ };
553
+
554
+ startServer = function (host, port) {
555
+ var server = require('webserver').create();
556
+
557
+ server.listen(host + ':' + port,
558
+ function (request, response) {
559
+ var jsonStr = request.postRaw || request.post,
560
+ params,
561
+ msg;
562
+ try {
563
+ params = JSON.parse(jsonStr);
564
+ if (params.status) {
565
+ // for server health validation
566
+ response.statusCode = 200;
567
+ response.write('OK');
568
+ response.close();
569
+ } else {
570
+ render(params, function (result) {
571
+ response.statusCode = 200;
572
+ response.write(result);
573
+ response.close();
574
+ });
575
+ }
576
+ } catch (e) {
577
+ msg = "Failed rendering: \n" + e;
578
+ response.statusCode = 500;
579
+ response.setHeader('Content-Type', 'text/plain');
580
+ response.setHeader('Content-Length', msg.length);
581
+ response.write(msg);
582
+ response.close();
583
+ }
584
+ }); // end server.listen
585
+
586
+ // switch to serverMode
587
+ serverMode = true;
588
+
589
+ console.log("OK, PhantomJS is ready.");
590
+ };
591
+
592
+ args = mapCLArguments();
593
+
594
+ // set tmpDir, for output temporary files.
595
+ if (args.tmpdir === undefined) {
596
+ config.tmpDir = fs.workingDirectory + '/tmp';
597
+ } else {
598
+ config.tmpDir = args.tmpdir;
599
+ }
600
+
601
+ // exists tmpDir and is it writable?
602
+ if (!fs.exists(config.tmpDir)) {
603
+ try{
604
+ fs.makeDirectory(config.tmpDir);
605
+ } catch (e) {
606
+ console.log('ERROR: Cannot create temp directory for ' + config.tmpDir);
607
+ }
608
+ }
609
+
610
+
611
+ if (args.host !== undefined && args.port !== undefined) {
612
+ startServer(args.host, args.port);
613
+ } else {
614
+ // presume commandline usage
615
+ render(args, function (msg) {
616
+ console.log(msg);
617
+ phantom.exit();
618
+ });
619
+ }
620
+ }());