highcharts_exporting 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 82a618e494bd58c2f5c5cd498a95f1d103afbe8b
4
+ data.tar.gz: d39f240e9b7a0b6e5aa0ed6bfb8b24bdaa66297c
5
+ SHA512:
6
+ metadata.gz: d7fb199e1244e0018b3c7192137fca3c7492671508e14bd88a271d687287737bd9326b5f6b8bdf6ca79eccf9aa7198a3ad8192214995e7ee2339a9c0579414d9
7
+ data.tar.gz: 44f63fcba78f1cc7c5e960dd965152b422603d0fb1f8d89f8fa7f5e91f10a36fa9d348ac54ac88a4ea771cea0c307cd20a5afa494f2466316f773813caaba032
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 bastengao
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'HighchartsExporting'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
@@ -0,0 +1,85 @@
1
+ require 'fileutils'
2
+ require 'tempfile'
3
+ require 'phantomjs'
4
+
5
+ # references:
6
+ # http://www.highcharts.com/docs/export-module/export-module-overview
7
+ # https://github.com/highslide-software/highcharts.com/tree/master/exporting-server/phantomjs
8
+ module HighchartsExporting
9
+ module Exporter
10
+ def export
11
+ tmp_dir = Rails.root.join('tmp/highcharts').to_s
12
+ FileUtils.mkdir_p tmp_dir
13
+
14
+ @infile_tmp_file = nil
15
+ if params[:options]
16
+ @infile_tmp_file = Tempfile.new(['options', '.json'], tmp_dir)
17
+ temp_write(@infile_tmp_file, params[:options])
18
+ elsif params[:svg]
19
+ @infile_tmp_file = Tempfile.new(['options', '.svg'], tmp_dir)
20
+ temp_write(@infile_tmp_file, params[:svg])
21
+ end
22
+
23
+
24
+ infile_path = @infile_tmp_file.path
25
+ type = params[:type] || 'image/png'
26
+ extension = MIME::Types[type].first.extensions.first
27
+
28
+ @output_tmp_file = Tempfile.new(['output', ".#{extension}"], tmp_dir)
29
+ output_path = @output_tmp_file.path
30
+
31
+ @callback_tmp_file = nil
32
+ callback_path = if params[:callback]
33
+ @callback_tmp_file = Tempfile.new(['callbacks', '.js'], tmp_dir)
34
+ temp_write(@callback_tmp_file, params[:callback])
35
+ @callback_tmp_file.path
36
+ else
37
+ nil
38
+ end
39
+
40
+ filename = params[:filename] || 'Chart'
41
+ scale = params[:scale] || 2
42
+ width = params[:width]
43
+ constr = params[:constr] || 'Chart'
44
+
45
+ convert_args = convert_args({
46
+ infile: infile_path,
47
+ outfile: output_path,
48
+ scale: scale,
49
+ width: width,
50
+ constr: constr,
51
+ callback: callback_path
52
+ })
53
+
54
+ result = ::Phantomjs.run(*convert_args)
55
+ puts result if VERBOSE
56
+
57
+ # TODO: clean @output_tmp_file
58
+ @infile_tmp_file.delete
59
+ @callback_tmp_file.delete if @callback_tmp_file
60
+
61
+ if /Error/ =~ result
62
+ render text: result, status: 500
63
+ else
64
+ send_file output_path, filename: "#{filename}.#{extension}", type: type
65
+ end
66
+ end
67
+
68
+ protected
69
+ def convert_args(args)
70
+ convert_args = args.reject { |k, v| v.blank? }.to_a.map { |pair| ["-#{pair[0]}", pair[1].to_s] }.flatten
71
+
72
+ convert_args.unshift("--web-security=false", convert_js_path)
73
+ end
74
+
75
+ def convert_js_path
76
+ File.join(ROOT, 'phantomjs/highcharts-convert.js').to_s
77
+ end
78
+
79
+ def temp_write(tmp_file, content)
80
+ File.open(tmp_file.path, 'r+') do |f|
81
+ f.write content
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,3 @@
1
+ module HighchartsExporting
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,7 @@
1
+ require 'highcharts_exporting/version'
2
+ require 'highcharts_exporting/exporter'
3
+
4
+ module HighchartsExporting
5
+ ROOT = File.expand_path("../..", __FILE__)
6
+ VERBOSE = false
7
+ end
@@ -0,0 +1,6 @@
1
+ (function(h){function p(){return Array.prototype.slice.call(arguments,1)}var q=h.pick,n=h.wrap,r=h.extend,o=HighchartsAdapter.fireEvent,j=h.Axis,s=h.Series;r(j.prototype,{isInBreak:function(g,d){var a=g.repeat||Infinity,c=g.from,b=g.to-g.from,a=d>=c?(d-c)%a:a-(c-d)%a;return g.inclusive?a<=b:a<b&&a!==0},isInAnyBreak:function(g,d){if(!this.options.breaks)return!1;for(var a=this.options.breaks,c=a.length,b=!1,e=!1;c--;)this.isInBreak(a[c],g)&&(b=!0,e||(e=q(a[c].showPoints,this.isXAxis?!1:!0)));return b&&
2
+ d?b&&!e:b}});n(j.prototype,"setTickPositions",function(g){g.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}}});n(j.prototype,"init",function(g,d,a){if(a.breaks&&a.breaks.length)a.ordinal=!1;g.call(this,d,a);if(this.options.breaks){var c=this;c.doPostTranslate=
3
+ !0;this.val2lin=function(b){var e=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.to-e.from:c.isInBreak(e,b)&&(b+=e.to-e.from);return b};this.setExtremes=function(b,c,a,d,g){for(;this.isInAnyBreak(b);)b-=this.closestPointRange;for(;this.isInAnyBreak(c);)c-=this.closestPointRange;
4
+ j.prototype.setExtremes.call(this,b,c,a,d,g)};this.setAxisTranslation=function(b){j.prototype.setAxisTranslation.call(this,b);var a=c.options.breaks,b=[],d=[],g=0,h,f,k=c.userMin||c.min,l=c.userMax||c.max,i,m;for(m in a)f=a[m],c.isInBreak(f,k)&&(k+=f.to%f.repeat-k%f.repeat),c.isInBreak(f,l)&&(l-=l%f.repeat-f.from%f.repeat);for(m in a){f=a[m];i=f.from;for(h=f.repeat||Infinity;i-h>k;)i-=h;for(;i<k;)i+=h;for(;i<l;i+=h)b.push({value:i,move:"in"}),b.push({value:i+(f.to-f.from),move:"out",size:f.breakSize})}b.sort(function(a,
5
+ b){return a.value===b.value?(a.move==="in"?0:1)-(b.move==="in"?0:1):a.value-b.value});a=0;i=k;for(m in b){f=b[m];a+=f.move==="in"?1:-1;if(a===1&&f.move==="in")i=f.value;a===0&&(d.push({from:i,to:f.value,len:f.value-i-(f.size||0)}),g+=f.value-i-(f.size||0))}c.breakArray=d;o(c,"afterBreaks");c.transA*=(l-c.min)/(l-k-g);c.min=k;c.max=l}}});n(s.prototype,"generatePoints",function(g){g.apply(this,p(arguments));var d=this.xAxis,a=this.yAxis,c=this.points,b,e=c.length;if(d&&a&&(d.options.breaks||a.options.breaks))for(;e--;)if(b=
6
+ c[e],d.isInAnyBreak(b.x,!0)||a.isInAnyBreak(b.y,!0))c.splice(e,1),this.data[e].destroyElements()});n(h.seriesTypes.column.prototype,"drawPoints",function(g){g.apply(this);var g=this.points,d=this.yAxis,a=d.breakArray||[],c,b,e,h,j;for(e=0;e<g.length;e++){c=g[e];j=c.stackY||c.y;for(h=0;h<a.length;h++)if(b=a[h],j<b.from)break;else j>b.to?o(d,"pointBreak",{point:c,brk:b}):o(d,"pointInBreak",{point:c,brk:b})}})})(Highcharts);
data/phantomjs/data.js ADDED
@@ -0,0 +1,26 @@
1
+ /*
2
+ Highcharts JS v4.1.4 (2015-03-10)
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,16 @@
1
+ (function(g){function y(b,a,c){var e;!a.rgba.length||!b.rgba.length?(Highcharts.error(23),b=a.raw):(b=b.rgba,a=a.rgba,e=a[3]!==1||b[3]!==1,b=(e?"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))+(e?","+(a[3]+(b[3]-a[3])*(1-c)):"")+")");return b}var r=function(){},n=g.getOptions(),j=g.each,k=g.extend,z=g.format,s=g.pick,o=g.wrap,h=g.Chart,m=g.seriesTypes,t=m.pie,l=m.column,u=HighchartsAdapter.fireEvent,v=HighchartsAdapter.inArray,
2
+ p=[],w=1;j(["fill","stroke"],function(b){HighchartsAdapter.addAnimSetter(b,function(a){a.elem.attr(b,y(g.Color(a.start),g.Color(a.end),a.pos))})});k(n.lang,{drillUpText:"◁ Back to {series.name}"});n.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}}};g.SVGRenderer.prototype.Element.prototype.fadeIn=
3
+ function(b){this.attr({opacity:0.1,visibility:"inherit"}).animate({opacity:s(this.newOpacity,1)},b||{duration:250})};h.prototype.addSeriesAsDrilldown=function(b,a){this.addSingleSeriesAsDrilldown(b,a);this.applyDrilldown()};h.prototype.addSingleSeriesAsDrilldown=function(b,a){var c=b.series,e=c.xAxis,f=c.yAxis,d;d=b.color||c.color;var i,g=[],x=[],h;h=c.options._levelNumber||0;a=k({color:d,_ddSeriesId:w++},a);i=v(b,c.points);j(c.chart.series,function(a){if(a.xAxis===e)g.push(a),a.options._ddSeriesId=
4
+ a.options._ddSeriesId||w++,a.options._colorIndex=a.userOptions._colorIndex,x.push(a.options),a.options._levelNumber=a.options._levelNumber||h});d={levelNumber:h,seriesOptions:c.options,levelSeriesOptions:x,levelSeries:g,shapeArgs:b.shapeArgs,bBox:b.graphic?b.graphic.getBBox():{},color:d,lowerSeriesOptions:a,pointOptions:c.options.data[i],pointIndex:i,oldExtremes:{xMin:e&&e.userMin,xMax:e&&e.userMax,yMin:f&&f.userMin,yMax:f&&f.userMax}};if(!this.drilldownLevels)this.drilldownLevels=[];this.drilldownLevels.push(d);
5
+ d=d.lowerSeries=this.addSeries(a,!1);d.options._levelNumber=h+1;if(e)e.oldPos=e.pos,e.userMin=e.userMax=null,f.userMin=f.userMax=null;if(c.type===d.type)d.animate=d.animateDrilldown||r,d.options.animation=!0};h.prototype.applyDrilldown=function(){var b=this.drilldownLevels,a;if(b&&b.length>0)a=b[b.length-1].levelNumber,j(this.drilldownLevels,function(b){b.levelNumber===a&&j(b.levelSeries,function(b){b.options&&b.options._levelNumber===a&&b.remove(!1)})});this.redraw();this.showDrillUpButton()};h.prototype.getDrilldownBackText=
6
+ function(){var b=this.drilldownLevels;if(b&&b.length>0)return b=b[b.length-1],b.series=b.seriesOptions,z(this.options.lang.drillUpText,b)};h.prototype.showDrillUpButton=function(){var b=this,a=this.getDrilldownBackText(),c=b.options.drilldown.drillUpButton,e,f;this.drillUpButton?this.drillUpButton.attr({text:a}).align():(f=(e=c.theme)&&e.states,this.drillUpButton=this.renderer.button(a,null,null,function(){b.drillUp()},e,f&&f.hover,f&&f.select).attr({align:c.position.align,zIndex:9}).add().align(c.position,
7
+ !1,c.relativeTo||"plotBox"))};h.prototype.drillUp=function(){for(var b=this,a=b.drilldownLevels,c=a[a.length-1].levelNumber,e=a.length,f=b.series,d,i,g,h,k=function(a){var c;j(f,function(b){b.options._ddSeriesId===a._ddSeriesId&&(c=b)});c=c||b.addSeries(a,!1);if(c.type===g.type&&c.animateDrillupTo)c.animate=c.animateDrillupTo;a===i.seriesOptions&&(h=c)};e--;)if(i=a[e],i.levelNumber===c){a.pop();g=i.lowerSeries;if(!g.chart)for(d=f.length;d--;)if(f[d].options.id===i.lowerSeriesOptions.id){g=f[d];break}g.xData=
8
+ [];j(i.levelSeriesOptions,k);u(b,"drillup",{seriesOptions:i.seriesOptions});if(h.type===g.type)h.drilldownLevel=i,h.options.animation=b.options.drilldown.animation,g.animateDrillupFrom&&g.chart&&g.animateDrillupFrom(i);h.options._levelNumber=c;g.remove(!1);if(h.xAxis)d=i.oldExtremes,h.xAxis.setExtremes(d.xMin,d.xMax,!1),h.yAxis.setExtremes(d.yMin,d.yMax,!1)}this.redraw();this.drilldownLevels.length===0?this.drillUpButton=this.drillUpButton.destroy():this.drillUpButton.attr({text:this.getDrilldownBackText()}).align();
9
+ p.length=[]};l.prototype.supportsDrilldown=!0;l.prototype.animateDrillupTo=function(b){if(!b){var a=this,c=a.drilldownLevel;j(this.points,function(a){a.graphic&&a.graphic.hide();a.dataLabel&&a.dataLabel.hide();a.connector&&a.connector.hide()});setTimeout(function(){a.points&&j(a.points,function(a,b){var d=b===(c&&c.pointIndex)?"show":"fadeIn",i=d==="show"?!0:void 0;if(a.graphic)a.graphic[d](i);if(a.dataLabel)a.dataLabel[d](i);if(a.connector)a.connector[d](i)})},Math.max(this.chart.options.drilldown.animation.duration-
10
+ 50,0));this.animate=r}};l.prototype.animateDrilldown=function(b){var a=this,c=this.chart.drilldownLevels,e,f=this.chart.options.drilldown.animation,d=this.xAxis;if(!b)j(c,function(b){if(a.options._ddSeriesId===b.lowerSeriesOptions._ddSeriesId)e=b.shapeArgs,e.fill=b.color}),e.x+=s(d.oldPos,d.pos)-d.pos,j(this.points,function(a){a.graphic&&a.graphic.attr(e).animate(k(a.shapeArgs,{fill:a.color}),f);a.dataLabel&&a.dataLabel.fadeIn(f)}),this.animate=null};l.prototype.animateDrillupFrom=function(b){var a=
11
+ this.chart.options.drilldown.animation,c=this.group,e=this;j(e.trackerGroups,function(a){if(e[a])e[a].on("mouseover")});delete this.group;j(this.points,function(e){var d=e.graphic,i=function(){d.destroy();c&&(c=c.destroy())};d&&(delete e.graphic,a?d.animate(k(b.shapeArgs,{fill:b.color}),g.merge(a,{complete:i})):(d.attr(b.shapeArgs),i()))})};t&&k(t.prototype,{supportsDrilldown:!0,animateDrillupTo:l.prototype.animateDrillupTo,animateDrillupFrom:l.prototype.animateDrillupFrom,animateDrilldown:function(b){var a=
12
+ this.chart.drilldownLevels[this.chart.drilldownLevels.length-1],c=this.chart.options.drilldown.animation,e=a.shapeArgs,f=e.start,d=(e.end-f)/this.points.length;if(!b)j(this.points,function(b,h){b.graphic.attr(g.merge(e,{start:f+h*d,end:f+(h+1)*d,fill:a.color}))[c?"animate":"attr"](k(b.shapeArgs,{fill:b.color}),c)}),this.animate=null}});g.Point.prototype.doDrilldown=function(b,a){for(var c=this.series.chart,e=c.options.drilldown,f=(e.series||[]).length,d;f--&&!d;)e.series[f].id===this.drilldown&&v(this.drilldown,
13
+ p)===-1&&(d=e.series[f],p.push(this.drilldown));u(c,"drilldown",{point:this,seriesOptions:d,category:a,points:a!==void 0&&this.series.xAxis.ticks[a].label.ddPoints.slice(0)});d&&(b?c.addSingleSeriesAsDrilldown(this,d):c.addSeriesAsDrilldown(this,d))};g.Axis.prototype.drilldownCategory=function(b){j(this.ticks[b].label.ddPoints,function(a){a.series&&a.series.visible&&a.doDrilldown&&a.doDrilldown(!0,b)});this.chart.applyDrilldown()};o(g.Point.prototype,"init",function(b,a,c,e){var f=b.call(this,a,c,
14
+ e),b=a.chart;if(c=(c=a.xAxis&&a.xAxis.ticks[e])&&c.label){if(!c.ddPoints)c.ddPoints=[];if(c.levelNumber!==a.options._levelNumber)c.ddPoints.length=0}if(f.drilldown){if(g.addEvent(f,"click",function(){f.doDrilldown()}),c){if(!c.basicStyles)c.basicStyles=g.merge(c.styles);c.addClass("highcharts-drilldown-axis-label").css(b.options.drilldown.activeAxisLabelStyle).on("click",function(){a.xAxis.drilldownCategory(e)});c.ddPoints.push(f);c.levelNumber=a.options._levelNumber}}else if(c&&c.basicStyles&&c.levelNumber!==
15
+ a.options._levelNumber)c.styles={},c.css(c.basicStyles),c.on("click",null);return f});o(g.Series.prototype,"drawDataLabels",function(b){var a=this.chart.options.drilldown.activeDataLabelStyle;b.call(this);j(this.points,function(b){if(b.drilldown&&b.dataLabel)b.dataLabel.attr({"class":"highcharts-drilldown-data-label"}).css(a).on("click",function(){b.doDrilldown()})})});var q,n=function(b){b.call(this);j(this.points,function(a){a.drilldown&&a.graphic&&a.graphic.attr({"class":"highcharts-drilldown-point"}).css({cursor:"pointer"})})};
16
+ for(q in m)m[q].prototype.supportsDrilldown&&o(m[q].prototype,"drawTracker",n)})(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(b){var q=b.getOptions(),w=q.plotOptions,r=b.seriesTypes,G=b.merge,E=function(){},B=b.each,F=b.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=b.extendClass(r.pie,{type:"funnel",animate:E,translate:function(){var a=function(i,a){return/%$/.test(i)?a*parseInt(i,10)/100:parseInt(i,
10
+ 10)},C=0,e=this.chart,c=this.options,b=c.reversed,j=e.plotWidth,f=e.plotHeight,n=0,e=c.center,g=a(e[0],j),q=a(e[1],f),r=a(c.width,j),k,s,d=a(c.height,f),t=a(c.neckWidth,j),u=a(c.neckHeight,f),x=d-u,a=this.data,y,z,w=c.dataLabels.position==="left"?1:0,A,l,D,p,h,v,m;this.getWidthAt=s=function(i){return i>d-u||d===u?t:t+(r-t)*((d-u-i)/(d-u))};this.getX=function(i,a){return g+(a?-1:1)*(s(b?f-i:i)/2+c.dataLabels.distance)};this.center=[g,q,d];this.centerX=g;B(a,function(a){C+=a.y});B(a,function(a){m=null;
11
+ z=C?a.y/C:0;l=q-d/2+n*d;h=l+z*d;k=s(l);A=g-k/2;D=A+k;k=s(h);p=g-k/2;v=p+k;l>x?(A=p=g-t/2,D=v=g+t/2):h>x&&(m=h,k=s(x),p=g-k/2,v=p+k,h=x);b&&(l=d-l,h=d-h,m=m?d-m:null);y=["M",A,l,"L",D,l,v,h];m&&y.push(v,m,p,m);y.push(p,h,"Z");a.shapeType="path";a.shapeArgs={d:y};a.percentage=z*100;a.plotX=g;a.plotY=(l+(m||h))/2;a.tooltipPos=[g,a.plotY];a.slice=E;a.half=w;n+=z})},drawPoints:function(){var a=this,b=a.options,e=a.chart.renderer;B(a.data,function(c){var o=c.options,j=c.graphic,f=c.shapeArgs;j?j.animate(f):
12
+ c.graphic=e.path(f).attr({fill:c.color,stroke:F(o.borderColor,b.borderColor),"stroke-width":F(o.borderWidth,b.borderWidth)}).add(a.group)})},sortByAngle:function(a){a.sort(function(a,b){return a.plotY-b.plotY})},drawDataLabels:function(){var a=this.data,b=this.options.dataLabels.distance,e,c,o,j=a.length,f,n;for(this.center[2]-=2*b;j--;)o=a[j],c=(e=o.half)?1:-1,n=o.plotY,f=this.getX(n,e),o.labelPos=[0,n,f+(b-5)*c,n,f+b*c,n,e?"right":"left",0];r.pie.prototype.drawDataLabels.call(this)}});q.plotOptions.pyramid=
13
+ b.merge(q.plotOptions.funnel,{neckWidth:"0%",neckHeight:"0%",reversed:!0});b.seriesTypes.pyramid=b.extendClass(b.seriesTypes.funnel,{type:"pyramid"})})(Highcharts);
@@ -0,0 +1,22 @@
1
+ /*
2
+ Highcharts JS v4.1.4 (2015-03-10)
3
+
4
+ (c) 2011-2014 Torstein Honsi
5
+
6
+ License: www.highcharts.com/license
7
+ */
8
+ (function(h){var l=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,m=h.merge,n=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,l.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 e=a.options.legend.layout!=="vertical",c;c=m(this.defaultColorAxisOptions,{side:e?2:1,reversed:!e},b,{isX:e,opposite:!e,showEmpty:!1,title:null,isColor:!0});l.prototype.init.call(this,a,c);b.dataClasses&&this.initDataClasses(b);this.initStops(b);this.isXAxis=!0;this.horiz=e;this.zoomEnabled=!1},tweenColors:function(a,b,e){var c;!b.rgba.length||!a.rgba.length?(h.error(23),a=b.raw):(a=a.rgba,b=b.rgba,c=b[3]!==1||a[3]!==1,a=(c?
10
+ "rgba(":"rgb(")+Math.round(b[0]+(a[0]-b[0])*(1-e))+","+Math.round(b[1]+(a[1]-b[1])*(1-e))+","+Math.round(b[2]+(a[2]-b[2])*(1-e))+(c?","+(b[3]+(a[3]-b[3])*(1-e)):"")+")");return a},initDataClasses:function(a){var b=this,e=this.chart,c,d=0,f=this.options,g=a.dataClasses.length;this.dataClasses=c=[];this.legendItems=[];i(a.dataClasses,function(a,h){var i,a=m(a);c.push(a);if(!a.color)f.dataClassColor==="category"?(i=e.options.colors,a.color=i[d++],d===i.length&&(d=0)):a.color=b.tweenColors(k(f.minColor),
11
+ k(f.maxColor),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){l.prototype.setOptions.call(this,a);this.options.crosshair=this.options.marker;this.coll="colorAxis"},setAxisSize:function(){var a=this.legendSymbol,b=this.chart,e,c,d;if(a)this.left=e=a.attr("x"),this.top=c=a.attr("y"),this.width=d=a.attr("width"),this.height=a=a.attr("height"),this.right=b.chartWidth-
12
+ e-d,this.bottom=b.chartHeight-c-a,this.len=this.horiz?d:a,this.pos=this.horiz?e:c},toColor:function(a,b){var e,c=this.stops,d,f=this.dataClasses,g,j;if(f)for(j=f.length;j--;){if(g=f[j],d=g.from,c=g.to,(d===void 0||a>=d)&&(c===void 0||a<=c)){e=g.color;if(b)b.dataClass=j;break}}else{this.isLog&&(a=this.val2lin(a));e=1-(this.max-a)/(this.max-this.min||1);for(j=c.length;j--;)if(e>c[j][0])break;d=c[j]||c[j+1];c=c[j+1]||d;e=1-(c[0]-e)/(c[0]-d[0]||1);e=this.tweenColors(d.color,c.color,e)}return e},getOffset:function(){var a=
13
+ this.legendGroup,b=this.chart.axisOffset[this.side];if(a){l.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 e=a.padding,c=a.options,d=this.horiz,f=n(c.symbolWidth,d?200:12),g=n(c.symbolHeight,d?12:200),j=n(c.labelPadding,d?16:30),c=n(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+e+(d?c:j);this.legendItemHeight=g+e+(d?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 e=b&&b.plotX,c=b&&b.plotY,d,f=this.pos,g=this.len;if(b)d=this.toPixels(b[b.series.colorKey]),d<f?d=f-2:d>f+g&&(d=f+g+2),b.plotX=d,b.plotY=this.len-d,l.prototype.drawCrosshair.call(this,a,b),b.plotX=e,b.plotY=c,this.cross&&this.cross.attr({fill:this.crosshair.color}).add(this.legendGroup)},getPlotLinePath:function(a,b,e,c,d){return d?this.horiz?["M",d-4,this.top-6,"L",d+4,this.top-6,d,this.top,"Z"]:["M",this.left,d,"L",
16
+ this.left-6,d+6,this.left-6,d-6,"Z"]:l.prototype.getPlotLinePath.call(this,a,b,e,c)},update:function(a,b){i(this.series,function(a){a.isDirtyData=!0});l.prototype.update.call(this,a,b);this.legendItem&&(this.setLegendColor(),this.chart.legend.colorizeItem(this,!0))},getDataClassLegendSymbols:function(){var a=this,b=this.chart,e=this.legendItems,c=b.options.legend,d=c.valueDecimals,f=c.valueSuffix||"",g;e.length||i(this.dataClasses,function(c,l){var k=!0,m=c.from,n=c.to;g="";m===void 0?g="< ":n===
17
+ void 0&&(g="> ");m!==void 0&&(g+=h.numberFormat(m,d)+f);m!==void 0&&n!==void 0&&(g+=" - ");n!==void 0&&(g+=h.numberFormat(n,d)+f);e.push(s({chart:b,name:g,options:{},drawLegendSymbol:t.drawRectangle,visible:!0,setState:o,setVisible:function(){k=this.visible=!k;i(a.series,function(a){i(a.points,function(a){a.dataClass===l&&a.setVisible(k)})});b.legend.colorizeItem(this,k)}},c))});return e},name:""});i(["fill","stroke"],function(a){HighchartsAdapter.addAnimSetter(a,function(b){b.elem.attr(a,q.prototype.tweenColors(k(b.start),
18
+ 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=[],e=this.chart.colorAxis[0];e&&(e.options.dataClasses?b=b.concat(e.getDataClassLegendSymbols()):b.push(e),i(e.series,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"],
19
+ 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,e=this.colorAxis,c=this.colorKey;i(this.data,function(d){var f=d[c];if(f=f===null?b:e&&f!==void 0?e.toColor(f,d):d.color||a.color)d.color=f})}};v.plotOptions.heatmap=m(v.plotOptions.scatter,{animation:!1,borderWidth:0,nullColor:"#F8F8F8",dataLabels:{formatter:function(){return this.point.value},
20
+ inside:!0,verticalAlign:"middle",crop:!1,overflow:!1,padding:0},marker: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,m(r,{type:"heatmap",pointArrayMap:["y","value"],hasPointSpecificOptions:!0,supportsDrilldown:!0,getExtremesFromAll:!0,init:function(){p.scatter.prototype.init.apply(this,arguments);this.pointRange=this.options.colsize||1;this.yAxis.axisPointRange=this.options.rowsize||1},translate:function(){var a=
21
+ this.options,b=this.xAxis,e=this.yAxis;this.generatePoints();i(this.points,function(c){var d=(a.colsize||1)/2,f=(a.rowsize||1)/2,g=Math.round(b.len-b.translate(c.x-d,0,1,0,1)),d=Math.round(b.len-b.translate(c.x+d,0,1,0,1)),h=Math.round(e.translate(c.y-f,0,1,0,1)),f=Math.round(e.translate(c.y+f,0,1,0,1));c.plotX=(g+d)/2;c.plotY=(h+f)/2;c.shapeType="rect";c.shapeArgs={x:Math.min(g,d),y:Math.min(h,f),width:Math.abs(d-g),height:Math.abs(f-h)}});this.translateColors();this.chart.hasRendered&&i(this.points,
22
+ 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,this.valueData);this.valueMin=this.dataMin;this.valueMax=this.dataMax;u.prototype.getExtremes.call(this)}}))})(Highcharts);
@@ -0,0 +1,44 @@
1
+ /*
2
+ Highcharts JS v4.1.4 (2015-03-10)
3
+
4
+ (c) 2009-2013 Torstein Hønsi
5
+
6
+ License: www.highcharts.com/license
7
+ */
8
+ (function(c){function n(d,a,b){var e,f,g=a.options.chart.options3d,h=!1;b?(h=a.inverted,b=a.plotWidth/2,a=a.plotHeight/2,e=g.depth/2,f=A(g.depth,1)*A(g.viewDistance,0)):(b=a.plotLeft+a.plotWidth/2,a=a.plotTop+a.plotHeight/2,e=g.depth/2,f=A(g.depth,1)*A(g.viewDistance,0));var j=[],i=b,k=a,v=e,p=f,b=y*(h?g.beta:-g.beta),g=y*(h?-g.alpha:g.alpha),o=l(b),s=m(b),t=l(g),u=m(g),w,x,r,n,q,z;c.each(d,function(a){w=(h?a.y:a.x)-i;x=(h?a.x:a.y)-k;r=(a.z||0)-v;n=s*w-o*r;q=-o*t*w-s*t*r+u*x;z=o*u*w+s*u*r+t*x;p>0&&
9
+ p<Number.POSITIVE_INFINITY&&(n*=p/(z+v+p),q*=p/(z+v+p));n+=i;q+=k;z+=v;j.push({x:h?q:n,y:h?n:q,z:z})});return j}function q(d){return d!==void 0&&d!==null}function E(d){var a=0,b,e;for(b=0;b<d.length;b++)e=(b+1)%d.length,a+=d[b].x*d[e].y-d[e].x*d[b].y;return a/2}function D(d){var a=0,b;for(b=0;b<d.length;b++)a+=d[b].z;return d.length?a/d.length:0}function r(d,a,b,e,f,g,c,j){var i=[];return g>f&&g-f>o/2+1.0E-4?(i=i.concat(r(d,a,b,e,f,f+o/2,c,j)),i=i.concat(r(d,a,b,e,f+o/2,g,c,j))):g<f&&f-g>o/2+1.0E-4?
10
+ (i=i.concat(r(d,a,b,e,f,f-o/2,c,j)),i=i.concat(r(d,a,b,e,f-o/2,g,c,j))):(i=g-f,["C",d+b*m(f)-b*B*i*l(f)+c,a+e*l(f)+e*B*i*m(f)+j,d+b*m(g)+b*B*i*l(g)+c,a+e*l(g)-e*B*i*m(g)+j,d+b*m(g)+c,a+e*l(g)+j])}function F(d){if(this.chart.is3d()){var a=this.chart.options.plotOptions.column.grouping;a!==void 0&&!a&&this.group.zIndex!==void 0&&this.group.attr({zIndex:this.group.zIndex*10});var b=this.options,e=this.options.states;this.borderWidth=b.borderWidth=b.edgeWidth||1;c.each(this.data,function(a){if(a.y!==
11
+ null)a=a.pointAttr,this.borderColor=c.pick(b.edgeColor,a[""].fill),a[""].stroke=this.borderColor,a.hover.stroke=c.pick(e.hover.edgeColor,this.borderColor),a.select.stroke=c.pick(e.select.edgeColor,this.borderColor)})}d.apply(this,[].slice.call(arguments,1))}var o=Math.PI,y=o/180,l=Math.sin,m=Math.cos,A=c.pick,G=Math.round;c.perspective=n;var B=4*(Math.sqrt(2)-1)/3/(o/2);c.SVGRenderer.prototype.toLinePath=function(d,a){var b=[];c.each(d,function(a){b.push("L",a.x,a.y)});d.length&&(b[0]="M",a&&b.push("Z"));
12
+ return b};c.SVGRenderer.prototype.cuboid=function(d){var a=this.g(),d=this.cuboidPath(d);a.front=this.path(d[0]).attr({zIndex:d[3],"stroke-linejoin":"round"}).add(a);a.top=this.path(d[1]).attr({zIndex:d[4],"stroke-linejoin":"round"}).add(a);a.side=this.path(d[2]).attr({zIndex:d[5],"stroke-linejoin":"round"}).add(a);a.fillSetter=function(a){var d=c.Color(a).brighten(0.1).get(),f=c.Color(a).brighten(-0.1).get();this.front.attr({fill:a});this.top.attr({fill:d});this.side.attr({fill:f});this.color=a;
13
+ 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||q(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]})):c.SVGElement.prototype.attr.call(this,a);return this};a.animate=function(a,d,f){q(a.x)&&q(a.y)?(a=this.renderer.cuboidPath(a),this.front.attr({zIndex:a[3]}).animate({d:a[0]},
14
+ d,f),this.top.attr({zIndex:a[4]}).animate({d:a[1]},d,f),this.side.attr({zIndex:a[5]}).animate({d:a[2]},d,f)):a.opacity?(this.front.animate(a,d,f),this.top.animate(a,d,f),this.side.animate(a,d,f)):c.SVGElement.prototype.animate.call(this,a,d,f);return this};a.destroy=function(){this.front.destroy();this.top.destroy();this.side.destroy();return null};a.attr({zIndex:-d[3]});return a};c.SVGRenderer.prototype.cuboidPath=function(d){var a=d.x,b=d.y,e=d.z,f=d.height,g=d.width,h=d.depth,j=c.map,i=[{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+h},{x:a+g,y:b+f,z:e+h},{x:a+g,y:b,z:e+h},{x:a,y:b,z:e+h}],i=n(i,c.charts[this.chartIndex],d.insidePlotArea),b=function(a,b){a=j(a,function(a){return i[a]});b=j(b,function(a){return i[a]});return E(a)<0?a:E(b)<0?b:[]},d=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(d,!0),this.toLinePath(a,!0),this.toLinePath(b,!0),D(d),D(a),D(b)]};c.SVGRenderer.prototype.arc3d=function(d){d.alpha*=
16
+ y;d.beta*=y;var a=this.g(),b=this.arc3dPath(d),e=a.renderer,f=b.zTop*100;a.shapeArgs=d;a.top=e.path(b.top).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=c.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});this.top.attr({fill:a});
17
+ 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,d){q(a.end)||q(a.start)?(this._shapeArgs=this.shapeArgs,c.SVGElement.prototype.animate.call(this,
18
+ {_args:a},{duration:b,step:function(){var a=arguments[1],b=a.elem,d=b._shapeArgs,e=a.end,a=a.pos,d=c.merge(d,{x:d.x+(e.x-d.x)*a,y:d.y+(e.y-d.y)*a,r:d.r+(e.r-d.r)*a,innerR:d.innerR+(e.innerR-d.innerR)*a,start:d.start+(e.start-d.start)*a,end:d.end+(e.end-d.end)*a}),e=b.renderer.arc3dPath(d);b.shapeArgs=d;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})}},d)):
19
+ c.SVGElement.prototype.animate.call(this,a,b,d);return this};a.destroy=function(){this.top.destroy();this.out.destroy();this.inn.destroy();this.side1.destroy();this.side2.destroy();c.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};c.SVGRenderer.prototype.arc3dPath=
20
+ function(d){var a=d.x,b=d.y,e=d.start,c=d.end-1.0E-5,g=d.r,h=d.innerR,j=d.depth,i=d.alpha,k=d.beta,v=m(e),p=l(e),d=m(c),n=l(c),s=g*m(k),t=g*m(i),u=h*m(k);h*=m(i);var w=j*l(k),x=j*l(i),j=["M",a+s*v,b+t*p],j=j.concat(r(a,b,s,t,e,c,0,0)),j=j.concat(["L",a+u*d,b+h*n]),j=j.concat(r(a,b,u,h,c,e,0,0)),j=j.concat(["Z"]),k=k>0?o/2:0,i=i>0?0:o/2,k=e>-k?e:c>-k?-k:e,q=c<o-i?c:e<o-i?o-i:c,i=["M",a+s*m(k),b+t*l(k)],i=i.concat(r(a,b,s,t,k,q,0,0)),i=i.concat(["L",a+s*m(q)+w,b+t*l(q)+x]),i=i.concat(r(a,b,s,t,q,k,
21
+ w,x)),i=i.concat(["Z"]),k=["M",a+u*v,b+h*p],k=k.concat(r(a,b,u,h,e,c,0,0)),k=k.concat(["L",a+u*m(c)+w,b+h*l(c)+x]),k=k.concat(r(a,b,u,h,c,e,w,x)),k=k.concat(["Z"]),v=["M",a+s*v,b+t*p,"L",a+s*v+w,b+t*p+x,"L",a+u*v+w,b+h*p+x,"L",a+u*v,b+h*p,"Z"],a=["M",a+s*d,b+t*n,"L",a+s*d+w,b+t*n+x,"L",a+u*d+w,b+h*n+x,"L",a+u*d,b+h*n,"Z"],b=l((e+c)/2),e=l(e),c=l(c);return{top:j,zTop:g,out:i,zOut:Math.max(b,e,c)*g,inn:k,zInn:Math.max(b,e,c)*g,side1:v,zSide1:e*g*0.99,side2:a,zSide2:c*g*0.99}};c.Chart.prototype.is3d=
22
+ function(){return this.options.chart.options3d&&this.options.chart.options3d.enabled};c.wrap(c.Chart.prototype,"isInsidePlot",function(d){return this.is3d()?!0:d.apply(this,[].slice.call(arguments,1))});c.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)"}}};c.wrap(c.Chart.prototype,"init",function(d){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=c.pick(b.borderColor,void 0);d.apply(this,a)});c.wrap(c.Chart.prototype,"setChartSize",function(d){d.apply(this,[].slice.call(arguments,1));if(this.is3d()){var a=this.inverted,b=this.clipBox,c=this.margin;b[a?"y":"x"]=-(c[3]||0);b[a?"x":"y"]=-(c[0]||0);b[a?"height":"width"]=this.chartWidth+(c[3]||0)+(c[1]||0);b[a?"width":"height"]=this.chartHeight+(c[0]||0)+(c[2]||0)}});c.wrap(c.Chart.prototype,
24
+ "redraw",function(d){if(this.is3d())this.isDirtyBox=!0;d.apply(this,[].slice.call(arguments,1))});c.wrap(c.Chart.prototype,"renderSeries",function(d){var a=this.series.length;if(this.is3d())for(;a--;)d=this.series[a],d.translate(),d.render();else d.call(this)});c.Chart.prototype.retrieveStacks=function(d){var a=this.series,b={},e,f=1;c.each(this.series,function(c){e=d?c.options.stack||0:a.length-1-c.index;b[e]?b[e].series.push(c):(b[e]={series:[c],position:f},f++)});b.totalStacks=f+1;return b};c.wrap(c.Axis.prototype,
25
+ "init",function(d){var a=arguments;if(a[1].is3d())a[2].tickWidth=c.pick(a[2].tickWidth,0),a[2].gridLineWidth=c.pick(a[2].gridLineWidth,1);d.apply(this,[].slice.call(arguments,1))});c.wrap(c.Axis.prototype,"render",function(d){d.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var a=this.chart,b=a.renderer,c=a.options.chart.options3d,f=c.frame,g=f.bottom,h=f.back,f=f.side,j=c.depth,i=this.height,k=this.width,l=this.left,p=this.top;this.horiz?(this.axisLine&&this.axisLine.hide(),h={x:l,
26
+ y:p+(a.yAxis[0].reversed?-g.size:i),z:0,width:k,height:g.size,depth:j,insidePlotArea:!1},this.bottomFrame?this.bottomFrame.animate(h):this.bottomFrame=b.cuboid(h).attr({fill:g.color,zIndex:a.yAxis[0].reversed&&c.alpha>0?4:-1}).css({stroke:g.color}).add()):(c={x:l,y:p,z:j+1,width:k,height:i+g.size,depth:h.size,insidePlotArea:!1},this.backFrame?this.backFrame.animate(c):this.backFrame=b.cuboid(c).attr({fill:h.color,zIndex:-3}).css({stroke:h.color}).add(),this.axisLine&&this.axisLine.hide(),a={x:(a.yAxis[0].opposite?
27
+ k:0)+l-f.size,y:p,z:0,width:f.size,height:i+g.size,depth:j+h.size,insidePlotArea:!1},this.sideFrame?this.sideFrame.animate(a):this.sideFrame=b.cuboid(a).attr({fill:f.color,zIndex:-2}).css({stroke:f.color}).add())}});c.wrap(c.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.depth,a=[{x:a[1],y:a[2],z:this.horiz||this.opposite?b:0},{x:a[1],y:a[2],z:b},{x:a[4],y:a[5],
28
+ z:b},{x:a[4],y:a[5],z:this.horiz||this.opposite?0:b}],a=n(a,this.chart,!1);return a=this.chart.renderer.toLinePath(a,!1)});c.wrap(c.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(a[7],a[8],a[4],a[5],a[1],a[2]):b=null;return b}else return c.apply(this,[].slice.call(arguments,1))});c.wrap(c.Tick.prototype,"getMarkPath",function(c){var a=c.apply(this,[].slice.call(arguments,1));if(!this.axis.chart.is3d())return a;
29
+ a=[{x:a[1],y:a[2],z:0},{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]});c.wrap(c.Tick.prototype,"getLabelPosition",function(c){var a=c.apply(this,[].slice.call(arguments,1));if(!this.axis.chart.is3d())return a;a=n([{x:a.x,y:a.y,z:0}],this.axis.chart,!1)[0];a.x-=!this.axis.horiz&&this.axis.opposite?this.axis.transA:0;return a});c.wrap(c.Axis.prototype,"drawCrosshair",function(c){var a=arguments;this.chart.is3d()&&a[2]&&(a[2]={plotX:a[2].plotXold||a[2].plotX,
30
+ plotY:a[2].plotYold||a[2].plotY});c.apply(this,[].slice.call(a,1))});c.wrap(c.seriesTypes.column.prototype,"translate",function(d){d.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var a=this.chart,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;c.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}],
31
+ a,!1)[0];b.tooltipPos=[d.x,d.y]}})}});c.wrap(c.seriesTypes.column.prototype,"animate",function(d){if(this.chart.is3d()){var a=arguments[1],b=this.yAxis,e=this,f=this.yAxis.reversed;if(c.svg)a?c.each(e.data,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)}):(c.each(e.data,function(a){if(a.y!==null)a.shapeArgs.height=a.height,a.shapeArgs.y=a.shapey,a.graphic&&
32
+ a.graphic.animate(a.shapeArgs,e.options.animation)}),this.drawDataLabels(),e.animate=null)}else d.apply(this,[].slice.call(arguments,1))});c.wrap(c.seriesTypes.column.prototype,"init",function(c){c.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var a=this.options,b=a.grouping,e=a.stacking,f=0;if(b===void 0||b){b=this.chart.retrieveStacks(e);e=a.stack||0;for(f=0;f<b[e].series.length;f++)if(b[e].series[f]===this)break;f=b.totalStacks*10-10*(b.totalStacks-b[e].position)-f}a.zIndex=f}});
33
+ c.wrap(c.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:0},b=n([b],this.chart,!0)[0];a.x=b.x;a.y=b.y}c.apply(this,[].slice.call(arguments,1))});c.seriesTypes.columnrange&&c.wrap(c.seriesTypes.columnrange.prototype,"drawPoints",F);c.wrap(c.seriesTypes.column.prototype,"drawPoints",F);var C=c.getOptions();C.plotOptions.cylinder=c.merge(C.plotOptions.column);C=c.extendClass(c.seriesTypes.column,
34
+ {type:"cylinder"});c.seriesTypes.cylinder=C;c.wrap(c.seriesTypes.cylinder.prototype,"translate",function(d){d.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var a=this.chart,b=a.options,e=b.plotOptions.cylinder,b=b.chart.options3d,f=e.depth||0,g={x:a.inverted?a.plotHeight/2:a.plotWidth/2,y:a.inverted?a.plotWidth/2:a.plotHeight/2,z:b.depth,vd:b.viewDistance},h=b.alpha,j=e.stacking?(this.options.stack||0)*f:this._i*f;j+=f/2;e.grouping!==!1&&(j=0);c.each(this.data,function(a){var b=a.shapeArgs;
35
+ a.shapeType="arc3d";b.x+=f/2;b.z=j;b.start=0;b.end=2*o;b.r=f*0.95;b.innerR=0;b.depth=b.height*(1/l((90-h)*y))-j;b.alpha=90-h;b.beta=0;b.origin=g})}});c.wrap(c.seriesTypes.pie.prototype,"translate",function(d){d.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,h={x:b.plotWidth/2,y:b.plotHeight/2,z:g.depth},j=g.alpha,i=g.beta,k=e.stacking?(e.stack||0)*f:a._i*f;k+=f/2;e.grouping!==!1&&(k=0);c.each(a.data,function(b){b.shapeType=
36
+ "arc3d";var c=b.shapeArgs;if(b.y)c.z=k,c.depth=f*0.75,c.origin=h,c.alpha=j,c.beta=i,c=(c.end+c.start)/2,b.slicedTranslation={translateX:G(m(c)*a.options.slicedOffset*m(j*y)),translateY:G(l(c)*a.options.slicedOffset*m(j*y))}})}});c.wrap(c.seriesTypes.pie.prototype.pointClass.prototype,"haloPath",function(c){var a=arguments;return this.series.chart.is3d()?[]:c.call(this,a[1])});c.wrap(c.seriesTypes.pie.prototype,"drawPoints",function(d){if(this.chart.is3d()){var a=this.options,b=this.options.states;
37
+ this.borderWidth=a.borderWidth=a.edgeWidth||1;this.borderColor=a.edgeColor=c.pick(a.edgeColor,a.borderColor,void 0);b.hover.borderColor=c.pick(b.hover.edgeColor,this.borderColor);b.hover.borderWidth=c.pick(b.hover.edgeWidth,this.borderWidth);b.select.borderColor=c.pick(b.select.edgeColor,this.borderColor);b.select.borderWidth=c.pick(b.select.edgeWidth,this.borderWidth);c.each(this.data,function(a){var c=a.pointAttr;c[""].stroke=a.series.borderColor||a.color;c[""]["stroke-width"]=a.series.borderWidth;
38
+ c.hover.stroke=b.hover.borderColor;c.hover["stroke-width"]=b.hover.borderWidth;c.select.stroke=b.select.borderColor;c.select["stroke-width"]=b.select.borderWidth})}d.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var e=this.group;c.each(this.points,function(a){a.graphic.out.add(e);a.graphic.inn.add(e);a.graphic.side1.add(e);a.graphic.side2.add(e)})}});c.wrap(c.seriesTypes.pie.prototype,"drawDataLabels",function(d){if(this.chart.is3d()){var a=this;c.each(a.data,function(b){var c=b.shapeArgs,
39
+ d=c.r,g=c.depth,h=(c.alpha||a.chart.options.chart.options3d.alpha)*y,c=(c.start+c.end)/2,b=b.labelPos;b[1]+=-d*(1-m(h))*l(c)+(l(c)>0?l(h)*g:0);b[3]+=-d*(1-m(h))*l(c)+(l(c)>0?l(h)*g:0);b[5]+=-d*(1-m(h))*l(c)+(l(c)>0?l(h)*g:0)})}d.apply(this,[].slice.call(arguments,1))});c.wrap(c.seriesTypes.pie.prototype,"addPoint",function(c){c.apply(this,[].slice.call(arguments,1));this.chart.is3d()&&this.update(this.userOptions,!0)});c.wrap(c.seriesTypes.pie.prototype,"animate",function(d){if(this.chart.is3d()){var a=
40
+ arguments[1],b=this.options.animation,e=this.center,f=this.group,g=this.markerGroup;if(c.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 d.apply(this,[].slice.call(arguments,1))});c.wrap(c.seriesTypes.scatter.prototype,
41
+ "translate",function(c){c.apply(this,[].slice.call(arguments,1));if(this.chart.is3d()){var a=this.chart,b=a.options.chart.options3d.depth,e=a.options.zAxis||{min:0,max:b},f=b/(e.max-e.min),g=[],h;for(h=0;h<this.data.length;h++)b=this.data[h],g.push({x:b.plotX,y:b.plotY,z:(b.z-e.min)*f});a=n(g,a,!0);for(h=0;h<this.data.length;h++)b=this.data[h],e=a[h],b.plotXold=b.plotX,b.plotYold=b.plotY,b.plotX=e.x,b.plotY=e.y,b.plotZ=e.z}});c.wrap(c.seriesTypes.scatter.prototype,"init",function(c){var a=c.apply(this,
42
+ [].slice.call(arguments,1));if(this.chart.is3d())this.pointArrayMap=["x","y","z"],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 a});if(c.VMLRenderer)c.setOptions({animate:!1}),c.VMLRenderer.prototype.cuboid=c.SVGRenderer.prototype.cuboid,c.VMLRenderer.prototype.cuboidPath=c.SVGRenderer.prototype.cuboidPath,
43
+ c.VMLRenderer.prototype.toLinePath=c.SVGRenderer.prototype.toLinePath,c.VMLRenderer.prototype.createElement3D=c.SVGRenderer.prototype.createElement3D,c.VMLRenderer.prototype.arc3d=function(d){d=c.SVGRenderer.prototype.arc3d.call(this,d);d.css({zIndex:d.zIndex});return d},c.VMLRenderer.prototype.arc3dPath=c.SVGRenderer.prototype.arc3dPath,c.wrap(c.Axis.prototype,"render",function(c){c.apply(this,[].slice.call(arguments,1));this.sideFrame&&(this.sideFrame.css({zIndex:0}),this.sideFrame.front.attr({fill:this.sideFrame.color}));
44
+ 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,580 @@
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
+ files: {
26
+ JQUERY: 'jquery.1.9.1.min.js',
27
+ HIGHCHARTS: 'highstock.js',
28
+ /* HIGHCHARTS: 'highcharts.js',*/
29
+ HIGHCHARTS_MORE: 'highcharts-more.js',
30
+ HIGHCHARTS_DATA: 'data.js',
31
+ HIGHCHARTS_DRILLDOWN: 'drilldown.js',
32
+ HIGHCHARTS_FUNNEL: 'funnel.js',
33
+ HIGHCHARTS_HEATMAP: 'heatmap.js',
34
+ HIGHCHARTS_3D: 'highcharts-3d.js',
35
+ HIGHCHARTS_NODATA: 'no-data-to-display.js',
36
+ /*HIGHCHARTS_MAP: 'map.js',*/
37
+ HIGHCHARTS_SOLID_GAUGE: 'solid-gauge.js',
38
+ BROKEN_AXIS: 'broken-axis.js'
39
+ },
40
+ TIMEOUT: 5000 /* 5 seconds timout for loading images */
41
+ },
42
+ mapCLArguments,
43
+ render,
44
+ startServer = false,
45
+ args,
46
+ pick,
47
+ 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\">',
48
+ dpiCorrection = 1.4,
49
+ system = require('system'),
50
+ fs = require('fs'),
51
+ serverMode = false;
52
+
53
+ pick = function () {
54
+ var args = arguments, i, arg, length = args.length;
55
+ for (i = 0; i < length; i += 1) {
56
+ arg = args[i];
57
+ if (arg !== undefined && arg !== null && arg !== 'null' && arg != '0') {
58
+ return arg;
59
+ }
60
+ }
61
+ };
62
+
63
+ mapCLArguments = function () {
64
+ var map = {},
65
+ i,
66
+ key;
67
+
68
+ if (system.args.length < 1) {
69
+ console.log('Commandline Usage: highcharts-convert.js -infile URL -outfile filename -scale 2.5 -width 300 -constr Chart -callback callback.js');
70
+ console.log(', or run PhantomJS as server: highcharts-convert.js -host 127.0.0.1 -port 1234');
71
+ }
72
+
73
+ for (i = 0; i < system.args.length; i += 1) {
74
+ if (system.args[i].charAt(0) === '-') {
75
+ key = system.args[i].substr(1, i.length);
76
+ if (key === 'infile' || key === 'callback' || key === 'dataoptions' || key === 'globaloptions' || key === 'customcode') {
77
+ // get string from file
78
+ try {
79
+ map[key] = fs.read(system.args[i + 1]).replace(/^\s+/, '');
80
+ } catch (e) {
81
+ console.log('Error: cannot find file, ' + system.args[i + 1]);
82
+ phantom.exit();
83
+ }
84
+ } else {
85
+ map[key] = system.args[i + 1];
86
+ }
87
+ }
88
+ }
89
+ return map;
90
+ };
91
+
92
+ render = function (params, exitCallback) {
93
+
94
+ var page = require('webpage').create(),
95
+ messages = {},
96
+ scaleAndClipPage,
97
+ loadChart,
98
+ createChart,
99
+ input,
100
+ constr,
101
+ callback,
102
+ width,
103
+ output,
104
+ outType,
105
+ timer,
106
+ renderSVG,
107
+ convert,
108
+ exit,
109
+ interval,
110
+ counter,
111
+ imagesLoaded = false;
112
+
113
+ messages.optionsParsed = 'Highcharts.options.parsed';
114
+ messages.callbackParsed = 'Highcharts.cb.parsed';
115
+
116
+ window.optionsParsed = false;
117
+ window.callbackParsed = false;
118
+
119
+ page.onConsoleMessage = function (msg) {
120
+ console.log(msg);
121
+
122
+ /*
123
+ * Ugly hack, but only way to get messages out of the 'page.evaluate()'
124
+ * sandbox. If any, please contribute with improvements on this!
125
+ */
126
+
127
+ /* to check options or callback are properly parsed */
128
+ if (msg === messages.optionsParsed) {
129
+ window.optionsParsed = true;
130
+ }
131
+
132
+ if (msg === messages.callbackParsed) {
133
+ window.callbackParsed = true;
134
+ }
135
+ };
136
+
137
+ page.onAlert = function (msg) {
138
+ console.log(msg);
139
+ };
140
+
141
+ /* scale and clip the page */
142
+ scaleAndClipPage = function (svg) {
143
+ /* param: svg: The scg configuration object
144
+ */
145
+
146
+ var zoom = 1,
147
+ pageWidth = pick(params.width, svg.width),
148
+ clipwidth,
149
+ clipheight;
150
+
151
+ if (parseInt(pageWidth, 10) == pageWidth) {
152
+ zoom = pageWidth / svg.width;
153
+ }
154
+
155
+ /* set this line when scale factor has a higher precedence
156
+ scale has precedence : page.zoomFactor = params.scale ? zoom * params.scale : zoom;*/
157
+
158
+ /* params.width has a higher precedence over scaling, to not break backover compatibility */
159
+ page.zoomFactor = params.scale && params.width == undefined ? zoom * params.scale : zoom;
160
+
161
+ clipwidth = svg.width * page.zoomFactor;
162
+ clipheight = svg.height * page.zoomFactor;
163
+
164
+ /* define the clip-rectangle */
165
+ /* ignored for PDF, see https://github.com/ariya/phantomjs/issues/10465 */
166
+ page.clipRect = {
167
+ top: 0,
168
+ left: 0,
169
+ width: clipwidth,
170
+ height: clipheight
171
+ };
172
+
173
+ /* for pdf we need a bit more paperspace in some cases for example (w:600,h:400), I don't know why.*/
174
+ if (outType === 'pdf') {
175
+ // changed to a multiplication with 1.333 to correct systems dpi setting
176
+ clipwidth = clipwidth * dpiCorrection;
177
+ clipheight = clipheight * dpiCorrection;
178
+ // redefine the viewport
179
+ page.viewportSize = { width: clipwidth, height: clipheight};
180
+ // make the paper a bit larger than the viewport
181
+ page.paperSize = { width: clipwidth + 2 , height: clipheight + 2 };
182
+ }
183
+ };
184
+
185
+ exit = function (result) {
186
+ if (serverMode) {
187
+ //Calling page.close(), may stop the increasing heap allocation
188
+ page.close();
189
+ }
190
+ exitCallback(result);
191
+ };
192
+
193
+ convert = function (svg) {
194
+ var base64;
195
+ scaleAndClipPage(svg);
196
+ if (outType === 'pdf' || output !== undefined || !serverMode) {
197
+ if (output === undefined) {
198
+ // in case of pdf files
199
+ output = config.tmpDir + '/chart.' + outType;
200
+ }
201
+ page.render(output);
202
+ exit(output);
203
+ } else {
204
+ base64 = page.renderBase64(outType);
205
+ exit(base64);
206
+ }
207
+ };
208
+
209
+ function decrementImgCounter() {
210
+ counter -= 1;
211
+ if (counter < 1) {
212
+ imagesLoaded = true;
213
+ }
214
+ }
215
+
216
+ function loadImages(imgUrls) {
217
+ var i, img;
218
+ counter = imgUrls.length;
219
+ for (i = 0; i < imgUrls.length; i += 1) {
220
+ img = new Image();
221
+ /* onload decrements the counter, also when error (perhaps 404), don't wait for this image to be loaded */
222
+ img.onload = img.onerror = decrementImgCounter;
223
+ /* force loading of images by setting the src attr.*/
224
+ img.src = imgUrls[i];
225
+ }
226
+ }
227
+
228
+ renderSVG = function (svg) {
229
+ var svgFile;
230
+ // From this point we have 'loaded' or 'created' a SVG
231
+
232
+ // Do we have to load images?
233
+ if (svg.imgUrls.length > 0) {
234
+ loadImages(svg.imgUrls);
235
+ } else {
236
+ // no images present, no loading, no waiting
237
+ imagesLoaded = true;
238
+ }
239
+
240
+ try {
241
+ if (outType.toLowerCase() === 'svg') {
242
+ // output svg
243
+ svg = svg.html.replace(/<svg /, '<svg xmlns:xlink="http://www.w3.org/1999/xlink" ').replace(/ href=/g, ' xlink:href=').replace(/<\/svg>.*?$/, '</svg>');
244
+ // add xml doc type
245
+ svg = SVG_DOCTYPE + svg;
246
+
247
+ if (output !== undefined) {
248
+ // write the file
249
+ svgFile = fs.open(output, "w");
250
+ svgFile.write(svg);
251
+ svgFile.close();
252
+ exit(output);
253
+ } else {
254
+ // return the svg as a string
255
+ exit(svg);
256
+ }
257
+
258
+ } else {
259
+ // output binary images or pdf
260
+ if (!imagesLoaded) {
261
+ // render with interval, waiting for all images loaded
262
+ interval = window.setInterval(function () {
263
+ if (imagesLoaded) {
264
+ clearTimeout(timer);
265
+ clearInterval(interval);
266
+ convert(svg);
267
+ }
268
+ }, 50);
269
+
270
+ // we have a 5 second timeframe..
271
+ timer = window.setTimeout(function () {
272
+ clearInterval(interval);
273
+ exitCallback('ERROR: While rendering, there\'s is a timeout reached');
274
+ }, config.TIMEOUT);
275
+ } else {
276
+ // images are loaded, render rightaway
277
+ convert(svg);
278
+ }
279
+ }
280
+ } catch (e) {
281
+ console.log('ERROR: While rendering, ' + e);
282
+ }
283
+ };
284
+
285
+ loadChart = function (input, outputType) {
286
+ var nodeIter, nodes, elem, opacity, svgElem, imgs, imgUrls, imgIndex;
287
+
288
+ document.body.style.margin = '0px';
289
+ document.body.innerHTML = input;
290
+
291
+ if (outputType === 'jpeg') {
292
+ document.body.style.backgroundColor = 'white';
293
+ }
294
+
295
+ nodes = document.querySelectorAll('*[stroke-opacity]');
296
+
297
+ for (nodeIter = 0; nodeIter < nodes.length; nodeIter += 1) {
298
+ elem = nodes[nodeIter];
299
+ opacity = elem.getAttribute('stroke-opacity');
300
+ elem.removeAttribute('stroke-opacity');
301
+ elem.setAttribute('opacity', opacity);
302
+ }
303
+
304
+ svgElem = document.getElementsByTagName('svg')[0];
305
+
306
+ imgs = document.getElementsByTagName('image');
307
+ imgUrls = [];
308
+
309
+ for (imgIndex = 0; imgIndex < imgs.length; imgIndex = imgIndex + 1) {
310
+ imgUrls.push(imgs[imgIndex].href.baseVal);
311
+ }
312
+
313
+ return {
314
+ html: document.body.innerHTML,
315
+ width: svgElem.getAttribute("width"),
316
+ height: svgElem.getAttribute("height"),
317
+ imgUrls: imgUrls
318
+ };
319
+ };
320
+
321
+ createChart = function (constr, input, globalOptionsArg, dataOptionsArg, customCodeArg, outputType, callback, messages) {
322
+
323
+ var $container, chart, nodes, nodeIter, elem, opacity, imgIndex, imgs, imgUrls;
324
+
325
+ // dynamic script insertion
326
+ function loadScript(varStr, codeStr) {
327
+ var $script = $('<script>').attr('type', 'text/javascript');
328
+ $script.html('var ' + varStr + ' = ' + codeStr);
329
+ document.getElementsByTagName("head")[0].appendChild($script[0]);
330
+ if (window[varStr] !== undefined) {
331
+ console.log('Highcharts.' + varStr + '.parsed');
332
+ }
333
+ }
334
+
335
+ function parseData(completeHandler, chartOptions, dataConfig) {
336
+ try {
337
+ dataConfig.complete = completeHandler;
338
+ Highcharts.data(dataConfig, chartOptions);
339
+ } catch (error) {
340
+ completeHandler(undefined);
341
+ }
342
+ }
343
+
344
+ if (input !== 'undefined') {
345
+ loadScript('options', input);
346
+ }
347
+
348
+ if (callback !== 'undefined') {
349
+ loadScript('cb', callback);
350
+ }
351
+
352
+ if (globalOptionsArg !== 'undefined') {
353
+ loadScript('globalOptions', globalOptionsArg);
354
+ }
355
+
356
+ if (dataOptionsArg !== 'undefined') {
357
+ loadScript('dataOptions', dataOptionsArg);
358
+ }
359
+
360
+ if (customCodeArg !== 'undefined') {
361
+ loadScript('customCode', customCodeArg);
362
+ }
363
+
364
+ $(document.body).css('margin', '0px');
365
+
366
+ if (outputType === 'jpeg') {
367
+ $(document.body).css('backgroundColor', 'white');
368
+ }
369
+
370
+ $container = $('<div>').appendTo(document.body);
371
+ $container.attr('id', 'container');
372
+
373
+ // disable animations
374
+ Highcharts.SVGRenderer.prototype.Element.prototype.animate = Highcharts.SVGRenderer.prototype.Element.prototype.attr;
375
+ Highcharts.setOptions({
376
+ plotOptions: {
377
+ series: {
378
+ animation: false
379
+ }
380
+ }
381
+ });
382
+
383
+ if (!options.chart) {
384
+ options.chart = {};
385
+ }
386
+
387
+ options.chart.renderTo = $container[0];
388
+
389
+ // check if witdh is set. Order of precedence:
390
+ // args.width, options.chart.width and 600px
391
+
392
+ // OLD. options.chart.width = width || options.chart.width || 600;
393
+ // Notice we don't use commandline parameter width here. Commandline parameter width is used for scaling.
394
+
395
+ options.chart.width = (options.exporting && options.exporting.sourceWidth) || options.chart.width || 600;
396
+ options.chart.height = (options.exporting && options.exporting.sourceHeight) || options.chart.height || 400;
397
+
398
+ // Load globalOptions
399
+ if (globalOptions) {
400
+ Highcharts.setOptions(globalOptions);
401
+ }
402
+
403
+ // Load data
404
+ if (dataOptions) {
405
+ parseData(function completeHandler(opts) {
406
+ // Merge series configs
407
+ if (options.series) {
408
+ Highcharts.each(options.series, function (series, i) {
409
+ options.series[i] = Highcharts.merge(series, opts.series[i]);
410
+ });
411
+ }
412
+
413
+ var mergedOptions = Highcharts.merge(opts, options);
414
+
415
+ // Run customCode
416
+ if (customCode) {
417
+ customCode(mergedOptions);
418
+ }
419
+
420
+ chart = new Highcharts[constr](mergedOptions, cb);
421
+
422
+ }, options, dataOptions);
423
+ } else {
424
+ chart = new Highcharts[constr](options, cb);
425
+ }
426
+
427
+ /* remove stroke-opacity paths, used by mouse-trackers, they turn up as
428
+ * as fully opaque in the PDF
429
+ */
430
+ nodes = document.querySelectorAll('*[stroke-opacity]');
431
+
432
+ for (nodeIter = 0; nodeIter < nodes.length; nodeIter += 1) {
433
+ elem = nodes[nodeIter];
434
+ opacity = elem.getAttribute('stroke-opacity');
435
+ elem.removeAttribute('stroke-opacity');
436
+ elem.setAttribute('opacity', opacity);
437
+ }
438
+
439
+ imgs = document.getElementsByTagName('image');
440
+ imgUrls = [];
441
+
442
+ for (imgIndex = 0; imgIndex < imgs.length; imgIndex = imgIndex + 1) {
443
+ imgUrls.push(imgs[imgIndex].href.baseVal);
444
+ }
445
+
446
+ return {
447
+ html: $('div.highcharts-container')[0].innerHTML,
448
+ width: chart.chartWidth,
449
+ height: chart.chartHeight,
450
+ imgUrls: imgUrls
451
+ };
452
+ };
453
+
454
+ if (params.length < 1) {
455
+ exit("Error: Insufficient parameters");
456
+ } else {
457
+ input = params.infile;
458
+ output = params.outfile;
459
+
460
+ if (output !== undefined) {
461
+ outType = pick(output.split('.').pop(),'png');
462
+ } else {
463
+ outType = pick(params.type,'png');
464
+ }
465
+
466
+ constr = pick(params.constr, 'Chart');
467
+ callback = params.callback;
468
+ width = params.width;
469
+
470
+ if (input === undefined || input.length === 0) {
471
+ exit('Error: Insuficient or wrong parameters for rendering');
472
+ }
473
+
474
+ page.open('about:blank', function (status) {
475
+ var svg,
476
+ globalOptions = params.globaloptions,
477
+ dataOptions = params.dataoptions,
478
+ customCode = 'function customCode(options) {\n' + params.customcode + '}\n',
479
+ jsfile;
480
+
481
+ /* Decide if we have to generate a svg first before rendering */
482
+ if (input.substring(0, 4).toLowerCase() === "<svg" || input.substring(0, 5).toLowerCase() === "<?xml"
483
+ || input.substring(0, 9).toLowerCase() === "<!doctype") {
484
+ //render page directly from svg file
485
+ svg = page.evaluate(loadChart, input, outType);
486
+ page.viewportSize = { width: svg.width, height: svg.height };
487
+ renderSVG(svg);
488
+ } else {
489
+ // We have a js file, let highcharts create the chart first and grab the svg
490
+
491
+ // load necessary libraries
492
+ for (jsfile in config.files) {
493
+ if (config.files.hasOwnProperty(jsfile)) {
494
+ page.injectJs(config.files[jsfile]);
495
+ }
496
+ }
497
+
498
+ // load chart in page and return svg height and width
499
+ svg = page.evaluate(createChart, constr, input, globalOptions, dataOptions, customCode, outType, callback, messages);
500
+
501
+ if (!window.optionsParsed) {
502
+ exit('ERROR: the options variable was not available or couldn\'t be parsed, does the infile contain an syntax error? Input used:' + input);
503
+ }
504
+
505
+ if (callback !== undefined && !window.callbackParsed) {
506
+ exit('ERROR: the callback variable was not available, does the callback contain an syntax error? Callback used: ' + callback);
507
+ }
508
+ renderSVG(svg);
509
+ }
510
+ });
511
+ }
512
+ };
513
+
514
+ startServer = function (host, port) {
515
+ var server = require('webserver').create();
516
+
517
+ server.listen(host + ':' + port,
518
+ function (request, response) {
519
+ var jsonStr = request.postRaw || request.post,
520
+ params,
521
+ msg;
522
+ try {
523
+ params = JSON.parse(jsonStr);
524
+ if (params.status) {
525
+ // for server health validation
526
+ response.statusCode = 200;
527
+ response.write('OK');
528
+ response.close();
529
+ } else {
530
+ render(params, function (result) {
531
+ response.statusCode = 200;
532
+ response.write(result);
533
+ response.close();
534
+ });
535
+ }
536
+ } catch (e) {
537
+ msg = "Failed rendering: \n" + e;
538
+ response.statusCode = 500;
539
+ response.setHeader('Content-Type', 'text/plain');
540
+ response.setHeader('Content-Length', msg.length);
541
+ response.write(msg);
542
+ response.close();
543
+ }
544
+ }); // end server.listen
545
+
546
+ // switch to serverMode
547
+ serverMode = true;
548
+
549
+ console.log("OK, PhantomJS is ready.");
550
+ };
551
+
552
+ args = mapCLArguments();
553
+
554
+ // set tmpDir, for output temporary files.
555
+ if (args.tmpdir === undefined) {
556
+ config.tmpDir = fs.workingDirectory + '/tmp';
557
+ } else {
558
+ config.tmpDir = args.tmpdir;
559
+ }
560
+
561
+ // exists tmpDir and is it writable?
562
+ if (!fs.exists(config.tmpDir)) {
563
+ try{
564
+ fs.makeDirectory(config.tmpDir);
565
+ } catch (e) {
566
+ console.log('ERROR: Cannot create temp directory for ' + config.tmpDir);
567
+ }
568
+ }
569
+
570
+
571
+ if (args.host !== undefined && args.port !== undefined) {
572
+ startServer(args.host, args.port);
573
+ } else {
574
+ // presume commandline usage
575
+ render(args, function (msg) {
576
+ console.log(msg);
577
+ phantom.exit();
578
+ });
579
+ }
580
+ }());