highcharts-rails 2.2.4 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Highcharts JS v2.2.4 (2012-05-31)
2
+ * @license Highcharts JS v2.3.0 (2012-08-24)
3
3
  * MooTools adapter
4
4
  *
5
5
  * (c) 2010-2011 Torstein Hønsi
@@ -78,8 +78,9 @@ win.HighchartsAdapter = {
78
78
 
79
79
  // This currently works for getting inner width and height. If adding
80
80
  // more methods later, we need a conditional implementation for each.
81
- return $(el).getStyle(method).toInt();
82
-
81
+ if (method === 'width' || method === 'height') {
82
+ return parseInt($(el).getStyle(method), 10);
83
+ }
83
84
  },
84
85
 
85
86
  /**
@@ -182,6 +183,13 @@ win.HighchartsAdapter = {
182
183
  return arr.filter(fn);
183
184
  },
184
185
 
186
+ /**
187
+ * Return the index of an item in an array, or -1 if not matched
188
+ */
189
+ inArray: function (item, arr, from) {
190
+ return arr.indexOf(item, from);
191
+ },
192
+
185
193
  /**
186
194
  * Deep merge two objects and return a third
187
195
  */
@@ -303,9 +311,7 @@ win.HighchartsAdapter = {
303
311
  * Set back e.pageX and e.pageY that MooTools has abstracted away
304
312
  */
305
313
  washMouseEvent: function (e) {
306
- e.pageX = e.page.x;
307
- e.pageY = e.page.y;
308
- return e;
314
+ return e.event || e;
309
315
  },
310
316
 
311
317
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Highcharts JS v2.2.4 (2012-05-31)
2
+ * @license Highcharts JS v2.3.0 (2012-08-24)
3
3
  * Prototype adapter
4
4
  *
5
5
  * @author Michael Nelson, Torstein Hønsi.
@@ -201,6 +201,10 @@ return {
201
201
  $A(arr).each(fn);
202
202
  },
203
203
 
204
+ inArray: function (item, arr) {
205
+ return arr.indexOf(item);
206
+ },
207
+
204
208
  /**
205
209
  * Get the cumulative offset relative to the top left of the page. This method, unlike its
206
210
  * jQuery and MooTools counterpart, still suffers from issue #208 regarding the position
@@ -0,0 +1,33 @@
1
+ /*
2
+ Highcharts JS v2.3.0 (2012-08-24)
3
+
4
+ (c) 2009-2011 Torstein H?nsi
5
+
6
+ License: www.highcharts.com/license
7
+ */
8
+ (function(h,t){function z(a,b,c){this.init.call(this,a,b,c)}function A(a,b,c){a.call(this,b,c);if(this.chart.polar)this.closeSegment=function(a){var b=this.xAxis.center;a.push("L",b[0],b[1])},this.closedStacks=!0}function B(a,b){var c=this.chart,d=this.options.animation,f=this.group,e=this.markerGroup,g=this.xAxis.center,i=c.plotLeft,m=c.plotTop;if(c.polar){if(c.renderer.isSVG)if(d===!0&&(d={}),b){if(f.attrSetters.scaleX=f.attrSetters.scaleY=function(a,b){this[b]=a;this.scaleX!==t&&this.scaleY!==
9
+ t&&this.element.setAttribute("transform","translate("+this.translateX+","+this.translateY+") scale("+this.scaleX+","+this.scaleY+")");return!1},c={translateX:g[0]+i,translateY:g[1]+m,scaleX:0,scaleY:0},f.attr(c),e)e.attrSetters=f.attrSetters,e.attr(c)}else c={translateX:i,translateY:m,scaleX:1,scaleY:1},f.animate(c,d),e&&e.animate(c,d),this.animate=null}else a.call(this,b)}var p=h.each,u=h.extend,o=h.merge,D=h.map,n=h.pick,v=h.pInt,j=h.getOptions().plotOptions,k=h.seriesTypes,w=h.extendClass,l=h.wrap,
10
+ q=h.Axis,F=h.Tick,y=h.Series,r=k.column.prototype,s=function(){};u(z.prototype,{init:function(a,b,c){var d=this,f=d.defaultOptions;d.chart=b;if(b.angular)f.background={};d.options=a=o(f,a);(a=a.background)&&p([].concat(h.splat(a)).reverse(),function(a){var b=a.backgroundColor,a=o(d.defaultBackgroundOptions,a);if(b)a.backgroundColor=b;a.color=a.backgroundColor;c.options.plotBands.unshift(a)})},defaultOptions:{center:["50%","50%"],size:"85%",startAngle:0},defaultBackgroundOptions:{shape:"circle",borderWidth:1,
11
+ borderColor:"silver",backgroundColor:{linearGradient:{x1:0,y1:0,x2:0,y2:1},stops:[[0,"#FFF"],[1,"#DDD"]]},from:Number.MIN_VALUE,innerRadius:0,to:Number.MAX_VALUE,outerRadius:"105%"}});var x=q.prototype,q=F.prototype,G={getOffset:s,redraw:function(){this.isDirty=!1},render:function(){this.isDirty=!1},setScale:s,setCategories:s,setTitle:s},E={isRadial:!0,defaultRadialGaugeOptions:{labels:{align:"center",x:0,y:null},minorGridLineWidth:0,minorTickInterval:"auto",minorTickLength:10,minorTickPosition:"inside",
12
+ minorTickWidth:1,plotBands:[],tickLength:10,tickPosition:"inside",tickWidth:2,title:{rotation:0},zIndex:2},defaultRadialXOptions:{gridLineWidth:1,labels:{align:null,distance:15,x:0,y:null},maxPadding:0,minPadding:0,plotBands:[],showLastLabel:!1,tickLength:0},defaultRadialYOptions:{gridLineInterpolation:"circle",labels:{align:"right",x:-3,y:-2},plotBands:[],showLastLabel:!1,title:{x:4,text:null,rotation:90}},setOptions:function(a){this.options=o(this.defaultOptions,this.defaultRadialOptions,a)},getOffset:function(){x.getOffset.call(this);
13
+ this.chart.axisOffset[this.side]=0;this.center=this.pane.center=k.pie.prototype.getCenter.call(this.pane)},getLinePath:function(a,b){var c=this.center,b=n(b,c[2]/2-this.offset);return this.chart.renderer.symbols.arc(this.left+c[0],this.top+c[1],b,b,{start:this.startAngleRad,end:this.endAngleRad,open:!0,innerR:0})},setAxisTranslation:function(){x.setAxisTranslation.call(this);if(this.center&&(this.transA=this.isCircular?(this.endAngleRad-this.startAngleRad)/(this.max-this.min||1):this.center[2]/2/
14
+ (this.max-this.min||1),this.isXAxis))this.minPixelPadding=this.transA*this.minPointOffset+(this.reversed?(this.endAngleRad-this.startAngleRad)/4:0)},beforeSetTickPositions:function(){this.autoConnect&&(this.max+=this.closestPointRange)},setAxisSize:function(){x.setAxisSize.call(this);if(this.center)this.len=this.width=this.height=this.isCircular?this.center[2]*(this.endAngleRad-this.startAngleRad)/2:this.center[2]/2},getPosition:function(a,b){if(!this.isCircular)b=this.translate(a),a=this.min;return this.postTranslate(this.translate(a),
15
+ n(b,this.center[2]/2)-this.offset)},postTranslate:function(a,b){var c=this.chart,d=this.center,a=this.startAngleRad+a;return{x:c.plotLeft+d[0]+Math.cos(a)*b,y:c.plotTop+d[1]+Math.sin(a)*b}},getPlotBandPath:function(a,b,c){var d=this.center,f=this.startAngleRad,e=d[2]/2,g=[n(c.outerRadius,"100%"),c.innerRadius,n(c.thickness,10)],i=/%$/,m,C=this.isCircular;this.options.gridLineInterpolation==="polygon"?d=this.getPlotLinePath(a).concat(this.getPlotLinePath(b,!0)):(C||(g[0]=this.translate(a),g[1]=this.translate(b)),
16
+ g=D(g,function(a){i.test(a)&&(a=v(a,10)*e/100);return a}),c.shape==="circle"||!C?(a=-Math.PI/2,b=Math.PI*1.5,m=!0):(a=f+this.translate(a),b=f+this.translate(b)),d=this.chart.renderer.symbols.arc(this.left+d[0],this.top+d[1],g[0],g[0],{start:a,end:b,innerR:n(g[1],g[0]-g[2]),open:m}));return d},getPlotLinePath:function(a,b){var c=this.center,d=this.chart,f=this.getPosition(a),e,g,i;this.isCircular?i=["M",c[0]+d.plotLeft,c[1]+d.plotTop,"L",f.x,f.y]:this.options.gridLineInterpolation==="circle"?(a=this.translate(a))&&
17
+ (i=this.getLinePath(0,a)):(e=d.xAxis[0],i=[],a=this.translate(a),c=e.tickPositions,e.autoConnect&&(c=c.concat([c[0]])),b&&(c=[].concat(c).reverse()),p(c,function(b,c){g=e.getPosition(b,a);i.push(c?"L":"M",g.x,g.y)}));return i},getTitlePosition:function(){var a=this.center,b=this.chart,c=this.options.title;return{x:b.plotLeft+a[0]+(c.x||0),y:b.plotTop+a[1]-{high:0.5,middle:0.25,low:0}[c.align]*a[2]+(c.y||0)}}};l(x,"init",function(a,b,c){var d=this,f=b.angular,e=b.polar,g=c.isX,i=f&&g,m;if(f){if(u(this,
18
+ i?G:E),m=!g)this.defaultRadialOptions=this.defaultRadialGaugeOptions}else if(e)u(this,E),this.defaultRadialOptions=(m=g)?this.defaultRadialXOptions:o(this.defaultYAxisOptions,this.defaultRadialYOptions);a.call(this,b,c);if(!i&&(f||e)){a=this.options;if(!b.panes)b.panes=D(h.splat(b.options.pane),function(a){return new z(a,b,d)});this.pane=f=b.panes[c.pane||0];e=f.options;b.inverted=!1;b.options.chart.zoomType=null;this.startAngleRad=f=(e.startAngle-90)*Math.PI/180;this.endAngleRad=e=(n(e.endAngle,
19
+ e.startAngle+360)-90)*Math.PI/180;this.offset=a.offset||0;if((this.isCircular=m)&&c.max===t&&e-f===2*Math.PI)this.autoConnect=!0}});l(q,"getPosition",function(a,b,c,d,f){var e=this.axis;return e.getPosition?e.getPosition(c):a.call(this,b,c,d,f)});l(q,"getLabelPosition",function(a,b,c,d,f,e,g,i,m){var h=this.axis,k=e.y,j=e.align,l=(h.translate(this.pos)+h.startAngleRad+Math.PI/2)/Math.PI*180;h.isRadial?(a=h.getPosition(this.pos,h.center[2]/2+n(e.distance,-25)),e.rotation==="auto"?d.attr({rotation:l}):
20
+ k===null&&(k=v(d.styles.lineHeight)*0.9-d.getBBox().height/2),j===null&&(j=h.isCircular?l>20&&l<160?"left":l>200&&l<340?"right":"center":"center",d.attr({align:j})),a.x+=e.x,a.y+=k):a=a.call(this,b,c,d,f,e,g,i,m);return a});l(q,"getMarkPath",function(a,b,c,d,f,e,g){var i=this.axis;i.isRadial?(a=i.getPosition(this.pos,i.center[2]/2+d),b=["M",b,c,"L",a.x,a.y]):b=a.call(this,b,c,d,f,e,g);return b});j.arearange=o(j.area,{lineWidth:0,marker:null,threshold:null,tooltip:{pointFormat:'<span style="color:{series.color}">{series.name}</span>: <b>{point.low}</b> - <b>{point.high}</b><br/>'},
21
+ trackByArea:!0,dataLabels:{xLow:0,xHigh:0,yLow:16,yHigh:-6}});q=h.extendClass(h.Point,{applyOptions:function(a,b){var c=this.series,d=c.pointArrayMap,f=0,e=0,g=d.length;if(typeof a==="object"&&typeof a.length!=="number")u(this,a),this.options=a;else if(a.length){if(a.length>g){if(typeof a[0]==="string")this.name=a[0];else if(typeof a[0]==="number")this.x=a[0];f++}for(;e<g;)this[d[e++]]=a[f++]}this.y=this[c.pointValKey];if(this.x===t&&c)this.x=b===t?c.autoIncrement():b;return this},toYData:function(){return[this.low,
22
+ this.high]}});k.arearange=h.extendClass(k.area,{type:"arearange",pointArrayMap:["low","high"],pointClass:q,pointValKey:"low",translate:function(){var a=this.yAxis;k.area.prototype.translate.apply(this);p(this.points,function(b){if(b.y!==null)b.plotLow=b.plotY,b.plotHigh=a.translate(b.high,0,1,0,1)})},getSegmentPath:function(a){for(var b=[],c=a.length,d=y.prototype.getSegmentPath,f;c--;)f=a[c],b.push({plotX:f.plotX,plotY:f.plotHigh});a=d.call(this,a);d=d.call(this,b);b=[].concat(a,d);d[0]="L";this.areaPath=
23
+ this.areaPath.concat(a,d);return b},drawDataLabels:function(){var a=this.points,b=a.length,c,d=[],f=y.prototype.drawDataLabels,e=this.options.dataLabels,g,i=this.chart.inverted;for(c=b;c--;)g=a[c],g.y=g.high,g.plotY=g.plotHigh,d[c]=g.dataLabel,g.dataLabel=g.dataLabelUpper,i?(e.align="left",e.x=e.xHigh):e.y=e.yHigh;f.apply(this,arguments);for(c=b;c--;)g=a[c],g.dataLabelUpper=g.dataLabel,g.dataLabel=d[c],g.y=g.low,g.plotY=g.plotLow,i?(e.align="right",e.x=e.xLow):e.y=e.yLow;f.apply(this,arguments)},
24
+ getSymbol:k.column.prototype.getSymbol,drawPoints:s});j.areasplinerange=o(j.arearange);k.areasplinerange=w(k.arearange,{type:"areasplinerange",getPointSpline:k.spline.prototype.getPointSpline});j.columnrange=o(j.column,j.arearange,{lineWidth:1,pointRange:null});k.columnrange=w(k.arearange,{type:"columnrange",translate:function(){var a=this.yAxis,b;r.translate.apply(this);p(this.points,function(c){var d=c.shapeArgs;c.plotHigh=b=a.translate(c.high,0,1,0,1);c.plotLow=c.plotY;d.y=b;d.height=c.plotY-b;
25
+ c.trackerArgs=d})},drawGraph:s,pointAttrToOptions:r.pointAttrToOptions,drawPoints:r.drawPoints,drawTracker:r.drawTracker,animate:r.animate});j.gauge=o(j.line,{dataLabels:{enabled:!0,y:30,borderWidth:1,borderColor:"silver",borderRadius:3,style:{fontWeight:"bold"}},dial:{},pivot:{},tooltip:{headerFormat:""},showInLegend:!1});j={type:"gauge",pointClass:h.extendClass(h.Point,{setState:function(a){this.state=a}}),angular:!0,translate:function(){var a=this,b=a.yAxis,c=b.center;a.generatePoints();p(a.points,
26
+ function(d){var f=o(a.options.dial,d.dial),e=v(n(f.radius,80))*c[2]/200,g=v(n(f.baseLength,70))*e/100,i=v(n(f.rearLength,10))*e/100,m=f.baseWidth||3,h=f.topWidth||1;d.shapeType="path";d.shapeArgs={d:f.path||["M",-i,-m/2,"L",g,-m/2,e,-h/2,e,h/2,g,m/2,-i,m/2,"z"],translateX:c[0],translateY:c[1],rotation:(b.startAngleRad+b.translate(d.y))*180/Math.PI};d.plotX=c[0];d.plotY=c[1]})},drawPoints:function(){var a=this,b=a.yAxis.center,c=a.pivot,d=a.options,f=d.pivot,e=d.dial;p(a.points,function(b){var c=b.graphic,
27
+ d=b.shapeArgs,f=d.d;c?(c.animate(d),d.d=f):b.graphic=a.chart.renderer[b.shapeType](d).attr({stroke:e.borderColor||"none","stroke-width":e.borderWidth||0,fill:e.backgroundColor||"black",rotation:d.rotation}).add(a.group)});c?c.animate({cx:b[0],cy:b[1]}):a.pivot=a.chart.renderer.circle(b[0],b[1],n(f.radius,5)).attr({"stroke-width":f.borderWidth||0,stroke:f.borderColor||"silver",fill:f.backgroundColor||"black"}).add(a.group)},animate:function(){var a=this;p(a.points,function(b){var c=b.graphic;c&&(c.attr({rotation:a.yAxis.startAngleRad*
28
+ 180/Math.PI}),c.animate({rotation:b.shapeArgs.rotation},a.options.animation))});a.animate=null},render:function(){this.group=this.plotGroup("group","series",this.visible?"visible":"hidden",this.options.zIndex,this.chart.seriesGroup);k.pie.prototype.render.call(this);this.group.clip(this.chart.clipRect)},setData:k.pie.prototype.setData,drawTracker:k.column.prototype.drawTracker};k.gauge=h.extendClass(k.line,j);j=y.prototype;w=h.MouseTracker.prototype;j.toXY=function(a){var b,c=this.chart;b=a.plotX;
29
+ var d=a.plotY;a.rectPlotX=b;a.rectPlotY=d;a.deg=b/Math.PI*180;b=this.xAxis.postTranslate(a.plotX,this.yAxis.len-d);a.plotX=a.polarPlotX=b.x-c.plotLeft;a.plotY=a.polarPlotY=b.y-c.plotTop};l(k.area.prototype,"init",A);l(k.areaspline.prototype,"init",A);l(k.spline.prototype,"getPointSpline",function(a,b,c,d){var f,e,g,i,h,k,j;if(this.chart.polar){f=c.plotX;e=c.plotY;a=b[d-1];g=b[d+1];this.connectEnds&&(a||(a=b[b.length-2]),g||(g=b[1]));if(a&&g)i=a.plotX,h=a.plotY,b=g.plotX,k=g.plotY,i=(1.5*f+i)/2.5,
30
+ h=(1.5*e+h)/2.5,g=(1.5*f+b)/2.5,j=(1.5*e+k)/2.5,b=Math.sqrt(Math.pow(i-f,2)+Math.pow(h-e,2)),k=Math.sqrt(Math.pow(g-f,2)+Math.pow(j-e,2)),i=Math.atan2(h-e,i-f),h=Math.atan2(j-e,g-f),j=Math.PI/2+(i+h)/2,Math.abs(i-j)>Math.PI/2&&(j-=Math.PI),i=f+Math.cos(j)*b,h=e+Math.sin(j)*b,g=f+Math.cos(Math.PI+j)*k,j=e+Math.sin(Math.PI+j)*k,c.rightContX=g,c.rightContY=j;d?(c=["C",a.rightContX||a.plotX,a.rightContY||a.plotY,i||f,h||e,f,e],a.rightContX=a.rightContY=null):c=["M",f,e]}else c=a.call(this,b,c,d);return c});
31
+ l(j,"translate",function(a){a.call(this);if(this.chart.polar&&!this.preventPostTranslate)for(var a=this.points,b=a.length;b--;)this.toXY(a[b])});l(j,"getSegmentPath",function(a,b){var c=this.points;if(this.chart.polar&&this.options.connectEnds!==!1&&b[b.length-1]===c[c.length-1]&&c[0].y!==null)this.connectEnds=!0,b=[].concat(b,[c[0]]);return a.call(this,b)});l(j,"animate",B);l(r,"animate",B);l(j,"setTooltipPoints",function(a,b){this.chart.polar&&u(this.xAxis,{tooltipLen:360,tooltipPosName:"deg"});
32
+ return a.call(this,b)});l(r,"translate",function(a){var b=this.xAxis,c=this.yAxis.len,d=b.center,f=b.startAngleRad,e=this.chart.renderer,g;this.preventPostTranslate=!0;a.call(this);if(b.isRadial){a=this.points;for(g=a.length;g--;)b=a[g],b.shapeType="path",b.shapeArgs={d:e.symbols.arc(d[0],d[1],c-b.plotY,null,{start:f+b.barX,end:f+b.barX+b.pointWidth,innerR:c-n(b.yBottom,c)})},this.toXY(b)}});l(w,"getIndex",function(a,b){var c,d=this.chart,f;d.polar?(f=d.xAxis[0].center,c=b.chartX-f[0]-d.plotLeft,
33
+ d=b.chartY-f[1]-d.plotTop,c=180-Math.round(Math.atan2(c,d)/Math.PI*180)):c=a.call(this,b);return c});l(w,"getMouseCoordinates",function(a,b){var c=this.chart,d={xAxis:[],yAxis:[]};c.polar?p(c.axes,function(a){var e=a.isXAxis,g=a.center,h=b.chartX-g[0]-c.plotLeft,g=b.chartY-g[1]-c.plotTop;d[e?"xAxis":"yAxis"].push({axis:a,value:a.translate(e?Math.PI-Math.atan2(h,g):Math.sqrt(Math.pow(h,2)+Math.pow(g,2)),!0)})}):d=a.call(this,b);return d})})(Highcharts);
@@ -2908,7 +2908,7 @@ if (CanvasRenderingContext2D) {
2908
2908
  });
2909
2909
  }
2910
2910
  }/**
2911
- * @license Highcharts JS v2.2.4 (2012-05-31)
2911
+ * @license Highcharts JS v2.3.0 (2012-08-24)
2912
2912
  * CanVGRenderer Extension module
2913
2913
  *
2914
2914
  * (c) 2011-2012 Torstein Hønsi, Erik Olsson
@@ -2933,7 +2933,6 @@ if (CanvasRenderingContext2D) {
2933
2933
  extend = Highcharts.extend,
2934
2934
  merge = Highcharts.merge,
2935
2935
  addEvent = Highcharts.addEvent,
2936
- placeBox = Highcharts.placeBox,
2937
2936
  createElement = Highcharts.createElement,
2938
2937
  discardElement = Highcharts.discardElement;
2939
2938
 
@@ -3034,7 +3033,7 @@ if (CanvasRenderingContext2D) {
3034
3033
  tooltipDiv.innerHTML = args.text;
3035
3034
 
3036
3035
  // Compute the best position for the tooltip based on the divs size and container size.
3037
- position = placeBox(tooltipDiv.offsetWidth, tooltipDiv.offsetHeight, offsetLeft, offsetTop, chartContainer.offsetWidth, chartContainer.offsetHeight, {x: args.x, y: args.y}, 12);
3036
+ position = chart.tooltip.getPosition(tooltipDiv.offsetWidth, tooltipDiv.offsetHeight, {plotX: args.x, plotY: args.y});
3038
3037
 
3039
3038
  css(tooltipDiv, {
3040
3039
  visibility: VISIBLE,
@@ -0,0 +1,277 @@
1
+ /**
2
+ * @license Data plugin for Highcharts v0.1
3
+ *
4
+ * (c) 2012 Torstein Hønsi
5
+ *
6
+ * License: www.highcharts.com/license
7
+ */
8
+
9
+ /*
10
+ * Demo: http://jsfiddle.net/highcharts/SnLFj/
11
+ */
12
+
13
+ (function (Highcharts) {
14
+
15
+ // Utilities
16
+ var each = Highcharts.each;
17
+
18
+
19
+ // The Data constructor
20
+ var Data = function (options) {
21
+ this.init(options);
22
+ };
23
+
24
+ // Set the prototype properties
25
+ Highcharts.extend(Data.prototype, {
26
+
27
+ /**
28
+ * Initialize the Data object with the given options
29
+ */
30
+ init: function (options) {
31
+ this.options = options;
32
+ this.columns = [];
33
+
34
+
35
+ // Parse a CSV string if options.csv is given
36
+ this.parseCSV();
37
+
38
+ // Parse a HTML table if options.table is given
39
+ this.parseTable();
40
+
41
+ // Interpret the values into right types
42
+ this.parseTypes();
43
+
44
+ // Use first row for series names?
45
+ this.findHeaderRow();
46
+
47
+ // Handle columns if a handleColumns callback is given
48
+ this.parsed();
49
+
50
+ // Complete if a complete callback is given
51
+ this.complete();
52
+
53
+ },
54
+
55
+ /**
56
+ * Parse a CSV input string
57
+ */
58
+ parseCSV: function () {
59
+ var options = this.options,
60
+ csv = options.csv,
61
+ columns = this.columns,
62
+ startRow = options.startRow || 0,
63
+ endRow = options.endRow || Number.MAX_VALUE,
64
+ startColumn = options.startColumn || 0,
65
+ endColumn = options.endColumn || Number.MAX_VALUE,
66
+ lines;
67
+
68
+ if (csv) {
69
+ lines = csv.split(options.lineDelimiter || '\n');
70
+
71
+ each(lines, function (line, rowNo) {
72
+ if (rowNo >= startRow && rowNo <= endRow) {
73
+ var items = line.split(options.itemDelimiter || ',');
74
+ each(items, function (item, colNo) {
75
+ if (colNo >= startColumn && colNo <= endColumn) {
76
+ if (!columns[colNo - startColumn]) {
77
+ columns[colNo - startColumn] = [];
78
+ }
79
+
80
+ columns[colNo - startColumn][rowNo - startRow] = item;
81
+ }
82
+ });
83
+ }
84
+ });
85
+ }
86
+ },
87
+
88
+ /**
89
+ * Parse a HTML table
90
+ */
91
+ parseTable: function () {
92
+ var options = this.options,
93
+ table = options.table,
94
+ columns = this.columns,
95
+ startRow = options.startRow || 0,
96
+ endRow = options.endRow || Number.MAX_VALUE,
97
+ startColumn = options.startColumn || 0,
98
+ endColumn = options.endColumn || Number.MAX_VALUE,
99
+ colNo;
100
+
101
+ if (table) {
102
+
103
+ if (typeof table === 'string') {
104
+ table = document.getElementById(table);
105
+ }
106
+
107
+ each(table.getElementsByTagName('tr'), function (tr, rowNo) {
108
+ colNo = 0;
109
+ if (rowNo >= startRow && rowNo <= endRow) {
110
+ each(tr.childNodes, function (item) {
111
+ if ((item.tagName === 'TD' || item.tagName === 'TH') && colNo >= startColumn && colNo <= endColumn) {
112
+ if (!columns[colNo]) {
113
+ columns[colNo] = [];
114
+ }
115
+ columns[colNo][rowNo - startRow] = item.innerHTML;
116
+
117
+ colNo += 1;
118
+ }
119
+ });
120
+ }
121
+ });
122
+ }
123
+ },
124
+
125
+ /**
126
+ * Find the header row. For now, we just check whether the first row contains
127
+ * numbers or strings. Later we could loop down and find the first row with
128
+ * numbers.
129
+ */
130
+ findHeaderRow: function () {
131
+ var headerRow = 0;
132
+ each(this.columns, function (column) {
133
+ if (typeof column[0] !== 'string') {
134
+ headerRow = null;
135
+ }
136
+ });
137
+ this.headerRow = 0;
138
+ },
139
+
140
+ /**
141
+ * Trim a string from whitespace
142
+ */
143
+ trim: function (str) {
144
+ return str.replace(/^\s+|\s+$/g, '');
145
+ },
146
+
147
+ /**
148
+ * Parse numeric cells in to number types and date types in to true dates.
149
+ * @param {Object} columns
150
+ */
151
+ parseTypes: function () {
152
+ var columns = this.columns,
153
+ col = columns.length,
154
+ row,
155
+ val,
156
+ floatVal,
157
+ trimVal,
158
+ dateVal;
159
+
160
+ while (col--) {
161
+ row = columns[col].length;
162
+ while (row--) {
163
+ val = columns[col][row];
164
+ floatVal = parseFloat(val);
165
+ trimVal = this.trim(val);
166
+ /*jslint eqeq: true*/
167
+ if (trimVal == floatVal) { // is numeric
168
+ /*jslint eqeq: false*/
169
+ columns[col][row] = floatVal;
170
+
171
+ // If the number is greater than milliseconds in a year, assume datetime
172
+ if (floatVal > 365 * 24 * 3600 * 1000) {
173
+ columns[col].isDatetime = true;
174
+ } else {
175
+ columns[col].isNumeric = true;
176
+ }
177
+
178
+ } else { // string, continue to determine if it is a date string or really a string
179
+ dateVal = Date.parse(val);
180
+
181
+ if (col === 0 && typeof dateVal === 'number' && !isNaN(dateVal)) { // is date
182
+ columns[col][row] = dateVal;
183
+ columns[col].isDatetime = true;
184
+
185
+ } else { // string
186
+ columns[col][row] = trimVal;
187
+ }
188
+ }
189
+
190
+ }
191
+ }
192
+ },
193
+
194
+ parsed: function () {
195
+ if (this.options.parsed) {
196
+ this.options.parsed.call(this, this.columns);
197
+ }
198
+ },
199
+
200
+ /**
201
+ * If a complete callback function is provided in the options, interpret the
202
+ * columns into a Highcharts options object.
203
+ */
204
+ complete: function () {
205
+
206
+ var columns = this.columns,
207
+ hasXData,
208
+ categories,
209
+ firstCol,
210
+ type,
211
+ options = this.options,
212
+ series,
213
+ data,
214
+ name,
215
+ i,
216
+ j;
217
+
218
+
219
+ if (options.complete) {
220
+
221
+ // Use first column for X data or categories?
222
+ if (columns.length > 1) {
223
+ firstCol = columns.shift();
224
+ if (this.headerRow === 0) {
225
+ firstCol.shift(); // remove the first cell
226
+ }
227
+
228
+ // Use the first column for categories or X values
229
+ hasXData = firstCol.isNumeric || firstCol.isDatetime;
230
+ if (!hasXData) { // means type is neither datetime nor linear
231
+ categories = firstCol;
232
+ }
233
+
234
+ if (firstCol.isDatetime) {
235
+ type = 'datetime';
236
+ }
237
+ }
238
+
239
+ // Use the next columns for series
240
+ series = [];
241
+ for (i = 0; i < columns.length; i++) {
242
+ if (this.headerRow === 0) {
243
+ name = columns[i].shift();
244
+ }
245
+ data = [];
246
+ for (j = 0; j < columns[i].length; j++) {
247
+ data[j] = columns[i][j] !== undefined ?
248
+ (hasXData ?
249
+ [firstCol[j], columns[i][j]] :
250
+ columns[i][j]
251
+ ) :
252
+ null;
253
+ }
254
+ series[i] = {
255
+ name: name,
256
+ data: data
257
+ };
258
+ }
259
+
260
+ // Do the callback
261
+ options.complete({
262
+ xAxis: {
263
+ categories: categories,
264
+ type: type
265
+ },
266
+ series: series
267
+ });
268
+ }
269
+ }
270
+ });
271
+
272
+ // Register the Data prototype and data function on Highcharts
273
+ Highcharts.Data = Data;
274
+ Highcharts.data = function (options) {
275
+ return new Data(options);
276
+ };
277
+ }(Highcharts));
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Highcharts JS v2.2.4 (2012-05-31)
2
+ * @license Highcharts JS v2.3.0 (2012-08-24)
3
3
  * Exporting module
4
4
  *
5
5
  * (c) 2010-2011 Torstein Hønsi
@@ -192,11 +192,7 @@ extend(Chart.prototype, {
192
192
  if (!doc.createElementNS) {
193
193
  /*jslint unparam: true*//* allow unused parameter ns in function below */
194
194
  doc.createElementNS = function (ns, tagName) {
195
- var elem = doc.createElement(tagName);
196
- elem.getBBox = function () {
197
- return HC.Renderer.prototype.Element.prototype.getBBox.apply({ element: elem });
198
- };
199
- return elem;
195
+ return doc.createElement(tagName);
200
196
  };
201
197
  /*jslint unparam: false*/
202
198
  }
@@ -8,7 +8,7 @@ Highcharts.theme = {
8
8
  "#55BF3B", "#DF5353", "#7798BF", "#aaeeee"],
9
9
  chart: {
10
10
  backgroundColor: {
11
- linearGradient: [0, 0, 250, 500],
11
+ linearGradient: { x1: 0, y1: 0, x2: 1, y2: 1 },
12
12
  stops: [
13
13
  [0, 'rgb(48, 48, 96)'],
14
14
  [1, 'rgb(0, 0, 0)']
@@ -133,7 +133,7 @@ Highcharts.theme = {
133
133
  navigation: {
134
134
  buttonOptions: {
135
135
  backgroundColor: {
136
- linearGradient: [0, 0, 0, 20],
136
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
137
137
  stops: [
138
138
  [0.4, '#606060'],
139
139
  [0.6, '#333333']
@@ -160,7 +160,7 @@ Highcharts.theme = {
160
160
  rangeSelector: {
161
161
  buttonTheme: {
162
162
  fill: {
163
- linearGradient: [0, 0, 0, 20],
163
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
164
164
  stops: [
165
165
  [0.4, '#888'],
166
166
  [0.6, '#555']
@@ -174,7 +174,7 @@ Highcharts.theme = {
174
174
  states: {
175
175
  hover: {
176
176
  fill: {
177
- linearGradient: [0, 0, 0, 20],
177
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
178
178
  stops: [
179
179
  [0.4, '#BBB'],
180
180
  [0.6, '#888']
@@ -187,7 +187,7 @@ Highcharts.theme = {
187
187
  },
188
188
  select: {
189
189
  fill: {
190
- linearGradient: [0, 0, 0, 20],
190
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
191
191
  stops: [
192
192
  [0.1, '#000'],
193
193
  [0.3, '#333']
@@ -224,7 +224,7 @@ Highcharts.theme = {
224
224
 
225
225
  scrollbar: {
226
226
  barBackgroundColor: {
227
- linearGradient: [0, 0, 0, 20],
227
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
228
228
  stops: [
229
229
  [0.4, '#888'],
230
230
  [0.6, '#555']
@@ -233,7 +233,7 @@ Highcharts.theme = {
233
233
  barBorderColor: '#CCC',
234
234
  buttonArrowColor: '#CCC',
235
235
  buttonBackgroundColor: {
236
- linearGradient: [0, 0, 0, 20],
236
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
237
237
  stops: [
238
238
  [0.4, '#888'],
239
239
  [0.6, '#555']
@@ -242,7 +242,7 @@ Highcharts.theme = {
242
242
  buttonBorderColor: '#CCC',
243
243
  rifleColor: '#FFF',
244
244
  trackBackgroundColor: {
245
- linearGradient: [0, 0, 0, 10],
245
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
246
246
  stops: [
247
247
  [0, '#000'],
248
248
  [1, '#333']