Current File : /home/jvzmxxx/wiki/extensions/InteractiveTimeline/chap-links-library/js/src/graph3d/graph3d-min.js
/*

 Licensed under the Apache License, Version 2.0 (the "License"); you may not
 use this file except in compliance with the License. You may obtain a copy
 of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 License for the specific language governing permissions and limitations under
 the License.

 Copyright (C) 2010-2014 Almende B.V.

 @author  Jos de Jong, jos@almende.org
 @date    2014-05-27
 @version 1.4
*/
typeof links==="undefined"&&(links={});
links.Graph3d=function(a){this.containerElement=a;this.height=this.width="400px";this.margin=10;this.defaultXCenter="55%";this.defaultYCenter="50%";this.style=links.Graph3d.STYLE.DOT;this.keepAspectRatio=this.showGrid=this.showPerspective=!0;this.showTooltip=this.showGrayBottom=this.showShadow=!1;this.verticalRatio=0.5;this.animationInterval=1E3;this.animationPreload=!1;this.camera=new links.Graph3d.Camera;this.eye=new links.Point3d(0,0,-1);this.dataPoints=this.dataTable=null;this.colFilter=this.colValue=
this.colZ=this.colY=this.colX=void 0;this.xMin=0;this.xStep=void 0;this.xMax=1;this.yMin=0;this.yStep=void 0;this.yMax=1;this.zMin=0;this.zStep=void 0;this.zMax=1;this.valueMin=0;this.yBarWidth=this.xBarWidth=this.valueMax=1;this.colorAxis="#4D4D4D";this.colorGrid="#D3D3D3";this.colorDot="#7DC1FF";this.colorDotBorder="#3267D2";this.create()};
links.Graph3d.Camera=function(){this.armLocation=new links.Point3d;this.armRotation={};this.armRotation.horizontal=0;this.armRotation.vertical=0;this.armLength=1.7;this.cameraLocation=new links.Point3d;this.cameraRotation=new links.Point3d(Math.PI/2,0,0);this.calculateCameraOrientation()};links.Graph3d.Camera.prototype.setArmLocation=function(a,b,c){this.armLocation.x=a;this.armLocation.y=b;this.armLocation.z=c;this.calculateCameraOrientation()};
links.Graph3d.Camera.prototype.setArmRotation=function(a,b){if(a!==void 0)this.armRotation.horizontal=a;if(b!==void 0){this.armRotation.vertical=b;if(this.armRotation.vertical<0)this.armRotation.vertical=0;if(this.armRotation.vertical>0.5*Math.PI)this.armRotation.vertical=0.5*Math.PI}(a!==void 0||b!==void 0)&&this.calculateCameraOrientation()};links.Graph3d.Camera.prototype.getArmRotation=function(){var a={};a.horizontal=this.armRotation.horizontal;a.vertical=this.armRotation.vertical;return a};
links.Graph3d.Camera.prototype.setArmLength=function(a){if(a!==void 0){this.armLength=a;if(this.armLength<0.71)this.armLength=0.71;if(this.armLength>5)this.armLength=5;this.calculateCameraOrientation()}};links.Graph3d.Camera.prototype.getArmLength=function(){return this.armLength};links.Graph3d.Camera.prototype.getCameraLocation=function(){return this.cameraLocation};links.Graph3d.Camera.prototype.getCameraRotation=function(){return this.cameraRotation};
links.Graph3d.Camera.prototype.calculateCameraOrientation=function(){this.cameraLocation.x=this.armLocation.x-this.armLength*Math.sin(this.armRotation.horizontal)*Math.cos(this.armRotation.vertical);this.cameraLocation.y=this.armLocation.y-this.armLength*Math.cos(this.armRotation.horizontal)*Math.cos(this.armRotation.vertical);this.cameraLocation.z=this.armLocation.z+this.armLength*Math.sin(this.armRotation.vertical);this.cameraRotation.x=Math.PI/2-this.armRotation.vertical;this.cameraRotation.y=
0;this.cameraRotation.z=-this.armRotation.horizontal};
links.Graph3d.prototype._setScale=function(){this.scale=new links.Point3d(1/(this.xMax-this.xMin),1/(this.yMax-this.yMin),1/(this.zMax-this.zMin));if(this.keepAspectRatio)this.scale.x<this.scale.y?this.scale.y=this.scale.x:this.scale.x=this.scale.y;this.scale.z*=this.verticalRatio;this.scale.value=1/(this.valueMax-this.valueMin);this.camera.setArmLocation((this.xMax+this.xMin)/2*this.scale.x,(this.yMax+this.yMin)/2*this.scale.y,(this.zMax+this.zMin)/2*this.scale.z)};
links.Graph3d.prototype._convert3Dto2D=function(a){return this._convertTranslationToScreen(this._convertPointToTranslation(a))};
links.Graph3d.prototype._convertPointToTranslation=function(a){var b=a.x*this.scale.x,c=a.y*this.scale.y,a=a.z*this.scale.z,d=this.camera.getCameraLocation().x,e=this.camera.getCameraLocation().y,f=this.camera.getCameraLocation().z,i=Math.sin(this.camera.getCameraRotation().x),j=Math.cos(this.camera.getCameraRotation().x),g=Math.sin(this.camera.getCameraRotation().y),h=Math.cos(this.camera.getCameraRotation().y),k=Math.sin(this.camera.getCameraRotation().z),l=Math.cos(this.camera.getCameraRotation().z);
return new links.Point3d(h*(k*(c-e)+l*(b-d))-g*(a-f),i*(h*(a-f)+g*(k*(c-e)+l*(b-d)))+j*(l*(c-e)-k*(b-d)),j*(h*(a-f)+g*(k*(c-e)+l*(b-d)))-i*(l*(c-e)-k*(b-d)))};links.Graph3d.prototype._convertTranslationToScreen=function(a){var b=this.eye.x,c=this.eye.y,d=this.eye.z,e=a.x,f=a.y,a=a.z;this.showPerspective?(b=(e-b)*(d/a),c=(f-c)*(d/a)):(b=e*-(d/this.camera.getArmLength()),c=f*-(d/this.camera.getArmLength()));return new links.Point2d(this.xcenter+b*this.frame.canvas.clientWidth,this.ycenter-c*this.frame.canvas.clientWidth)};
links.Graph3d.prototype.draw=function(a,b){var c=void 0;if(b!==void 0){if(b.width!==void 0)this.width=b.width;if(b.height!==void 0)this.height=b.height;if(b.xCenter!==void 0)this.defaultXCenter=b.xCenter;if(b.yCenter!==void 0)this.defaultYCenter=b.yCenter;if(b.style!==void 0){var d=this._getStyleNumber(b.style);if(d!==-1)this.style=d}if(b.showGrid!==void 0)this.showGrid=b.showGrid;if(b.showPerspective!==void 0)this.showPerspective=b.showPerspective;if(b.showShadow!==void 0)this.showShadow=b.showShadow;
if(b.tooltip!==void 0)this.showTooltip=b.tooltip;if(b.showAnimationControls!==void 0)this.showAnimationControls=b.showAnimationControls;if(b.keepAspectRatio!==void 0)this.keepAspectRatio=b.keepAspectRatio;if(b.verticalRatio!==void 0)this.verticalRatio=b.verticalRatio;if(b.animationInterval!==void 0)this.animationInterval=b.animationInterval;if(b.animationPreload!==void 0)this.animationPreload=b.animationPreload;if(b.animationAutoStart!==void 0)this.animationAutoStart=b.animationAutoStart;if(b.xBarWidth!==
void 0)this.defaultXBarWidth=b.xBarWidth;if(b.yBarWidth!==void 0)this.defaultYBarWidth=b.yBarWidth;if(b.xMin!==void 0)this.defaultXMin=b.xMin;if(b.xStep!==void 0)this.defaultXStep=b.xStep;if(b.xMax!==void 0)this.defaultXMax=b.xMax;if(b.yMin!==void 0)this.defaultYMin=b.yMin;if(b.yStep!==void 0)this.defaultYStep=b.yStep;if(b.yMax!==void 0)this.defaultYMax=b.yMax;if(b.zMin!==void 0)this.defaultZMin=b.zMin;if(b.zStep!==void 0)this.defaultZStep=b.zStep;if(b.zMax!==void 0)this.defaultZMax=b.zMax;if(b.valueMin!==
void 0)this.defaultValueMin=b.valueMin;if(b.valueMax!==void 0)this.defaultValueMax=b.valueMax;if(b.cameraPosition!==void 0)c=b.cameraPosition}this._setBackgroundColor(b.backgroundColor);this.setSize(this.width,this.height);c!==void 0?(this.camera.setArmRotation(c.horizontal,c.vertical),this.camera.setArmLength(c.distance)):(this.camera.setArmRotation(1,0.5),this.camera.setArmLength(1.7));this.redraw(a);this.animationAutoStart&&this.dataFilter&&this.animationStart();google.visualization.events.trigger(this,
"ready",null)};links.Graph3d.prototype._setBackgroundColor=function(a){var b="white",c="gray",d=1;if(typeof a==="string")b=a,c="none",d=0;else if(typeof a==="object"){if(a.fill!==void 0)b=a.fill;if(a.stroke!==void 0)c=a.stroke;if(a.strokeWidth!==void 0)d=a.strokeWidth}else if(a!==void 0)throw"Unsupported type of backgroundColor";this.frame.style.backgroundColor=b;this.frame.style.borderColor=c;this.frame.style.borderWidth=d+"px";this.frame.style.borderStyle="solid"};
links.Graph3d.STYLE={BAR:0,BARCOLOR:1,BARSIZE:2,DOT:3,DOTLINE:4,DOTCOLOR:5,DOTSIZE:6,GRID:7,LINE:8,SURFACE:9};
links.Graph3d.prototype._getStyleNumber=function(a){switch(a){case "dot":return links.Graph3d.STYLE.DOT;case "dot-line":return links.Graph3d.STYLE.DOTLINE;case "dot-color":return links.Graph3d.STYLE.DOTCOLOR;case "dot-size":return links.Graph3d.STYLE.DOTSIZE;case "line":return links.Graph3d.STYLE.LINE;case "grid":return links.Graph3d.STYLE.GRID;case "surface":return links.Graph3d.STYLE.SURFACE;case "bar":return links.Graph3d.STYLE.BAR;case "bar-color":return links.Graph3d.STYLE.BARCOLOR;case "bar-size":return links.Graph3d.STYLE.BARSIZE}return-1};
links.Graph3d.prototype._determineColumnIndexes=function(a){if(this.style===links.Graph3d.STYLE.DOT||this.style===links.Graph3d.STYLE.DOTLINE||this.style===links.Graph3d.STYLE.LINE||this.style===links.Graph3d.STYLE.GRID||this.style===links.Graph3d.STYLE.SURFACE||this.style===links.Graph3d.STYLE.BAR){if(this.colX=0,this.colY=1,this.colZ=2,this.colValue=void 0,a.getNumberOfColumns()>3)this.colFilter=3}else if(this.style===links.Graph3d.STYLE.DOTCOLOR||this.style===links.Graph3d.STYLE.DOTSIZE||this.style===
links.Graph3d.STYLE.BARCOLOR||this.style===links.Graph3d.STYLE.BARSIZE){if(this.colX=0,this.colY=1,this.colZ=2,this.colValue=3,a.getNumberOfColumns()>4)this.colFilter=4}else throw"Unknown style '"+this.style+"'";};
links.Graph3d.prototype._dataInitialize=function(a,b){if(!(a===void 0||a.getNumberOfRows===void 0)){this._determineColumnIndexes(a,b);this.dataTable=a;this.dataFilter=void 0;if(this.colFilter&&a.getNumberOfColumns()>=this.colFilter&&this.dataFilter===void 0){this.dataFilter=new links.Filter(a,this.colFilter,this);var c=this;this.dataFilter.setOnLoadCallback(function(){c.redraw()})}var d=this.style==links.Graph3d.STYLE.BAR||this.style==links.Graph3d.STYLE.BARCOLOR||this.style==links.Graph3d.STYLE.BARSIZE;
if(d){if(this.defaultXBarWidth!==void 0)this.xBarWidth=this.defaultXBarWidth;else{var e=a.getDistinctValues(this.colX);this.xBarWidth=e[1]-e[0]||1}this.defaultYBarWidth!==void 0?this.yBarWidth=this.defaultYBarWidth:(e=a.getDistinctValues(this.colY),this.yBarWidth=e[1]-e[0]||1)}e=a.getColumnRange(this.colX);d&&(e.min-=this.xBarWidth/2,e.max+=this.xBarWidth/2);this.xMin=this.defaultXMin!==void 0?this.defaultXMin:e.min;this.xMax=this.defaultXMax!==void 0?this.defaultXMax:e.max;if(this.xMax<=this.xMin)this.xMax=
this.xMin+1;this.xStep=this.defaultXStep!==void 0?this.defaultXStep:(this.xMax-this.xMin)/5;e=a.getColumnRange(this.colY);d&&(e.min-=this.yBarWidth/2,e.max+=this.yBarWidth/2);this.yMin=this.defaultYMin!==void 0?this.defaultYMin:e.min;this.yMax=this.defaultYMax!==void 0?this.defaultYMax:e.max;if(this.yMax<=this.yMin)this.yMax=this.yMin+1;this.yStep=this.defaultYStep!==void 0?this.defaultYStep:(this.yMax-this.yMin)/5;d=a.getColumnRange(this.colZ);this.zMin=this.defaultZMin!==void 0?this.defaultZMin:
d.min;this.zMax=this.defaultZMax!==void 0?this.defaultZMax:d.max;if(this.zMax<=this.zMin)this.zMax=this.zMin+1;this.zStep=this.defaultZStep!==void 0?this.defaultZStep:(this.zMax-this.zMin)/5;if(this.colValue!==void 0&&(d=a.getColumnRange(this.colValue),this.valueMin=this.defaultValueMin!==void 0?this.defaultValueMin:d.min,this.valueMax=this.defaultValueMax!==void 0?this.defaultValueMax:d.max,this.valueMax<=this.valueMin))this.valueMax=this.valueMin+1;this._setScale()}};
links.Graph3d.prototype._getDataPoints=function(a){var b,c,d,e,f,i=[];if(this.style===links.Graph3d.STYLE.GRID||this.style===links.Graph3d.STYLE.SURFACE){f=[];var j=[];for(d=0;d<a.getNumberOfRows();d++)b=a.getValue(d,this.colX)||0,c=a.getValue(d,this.colY)||0,f.indexOf(b)===-1&&f.push(b),j.indexOf(c)===-1&&j.push(c);d=function(a,b){return a-b};f.sort(d);j.sort(d);var g=[];for(d=0;d<a.getNumberOfRows();d++){b=a.getValue(d,this.colX)||0;c=a.getValue(d,this.colY)||0;e=a.getValue(d,this.colZ)||0;var h=
f.indexOf(b),k=j.indexOf(c);g[h]===void 0&&(g[h]=[]);var l=new links.Point3d;l.x=b;l.y=c;l.z=e;e={};e.point=l;e.trans=void 0;e.screen=void 0;e.bottom=new links.Point3d(b,c,this.zMin);g[h][k]=e;i.push(e)}for(b=0;b<g.length;b++)for(c=0;c<g[b].length;c++)if(g[b][c])g[b][c].pointRight=b<g.length-1?g[b+1][c]:void 0,g[b][c].pointTop=c<g[b].length-1?g[b][c+1]:void 0,g[b][c].pointCross=b<g.length-1&&c<g[b].length-1?g[b+1][c+1]:void 0}else for(d=0;d<a.getNumberOfRows();d++){f=new links.Point3d;f.x=a.getValue(d,
this.colX)||0;f.y=a.getValue(d,this.colY)||0;f.z=a.getValue(d,this.colZ)||0;if(this.colValue!==void 0)f.value=a.getValue(d,this.colValue)||0;e={};e.point=f;e.bottom=new links.Point3d(f.x,f.y,this.zMin);e.trans=void 0;e.screen=void 0;i.push(e)}return i};links.Graph3d.px=function(a){return a+"px"};
links.Graph3d.prototype.create=function(){for(;this.containerElement.hasChildNodes();)this.containerElement.removeChild(this.containerElement.firstChild);this.frame=document.createElement("div");this.frame.style.position="relative";this.frame.style.overflow="hidden";this.frame.canvas=document.createElement("canvas");this.frame.canvas.style.position="relative";this.frame.appendChild(this.frame.canvas);var a=document.createElement("DIV");a.style.color="red";a.style.fontWeight="bold";a.style.padding=
"10px";a.innerHTML="Error: your browser does not support HTML canvas";this.frame.canvas.appendChild(a);this.frame.filter=document.createElement("div");this.frame.filter.style.position="absolute";this.frame.filter.style.bottom="0px";this.frame.filter.style.left="0px";this.frame.filter.style.width="100%";this.frame.appendChild(this.frame.filter);var b=this;links.addEventListener(this.frame.canvas,"keydown",onkeydown);links.addEventListener(this.frame.canvas,"mousedown",function(a){b._onMouseDown(a)});
links.addEventListener(this.frame.canvas,"touchstart",function(a){b._onTouchStart(a)});links.addEventListener(this.frame.canvas,"mousewheel",function(a){b._onWheel(a)});links.addEventListener(this.frame.canvas,"mousemove",function(a){b._onTooltip(a)});this.containerElement.appendChild(this.frame)};links.Graph3d.prototype.setSize=function(a,b){this.frame.style.width=a;this.frame.style.height=b;this._resizeCanvas()};
links.Graph3d.prototype._resizeCanvas=function(){this.frame.canvas.style.width="100%";this.frame.canvas.style.height="100%";this.frame.canvas.width=this.frame.canvas.clientWidth;this.frame.canvas.height=this.frame.canvas.clientHeight;this.frame.filter.style.width=this.frame.canvas.clientWidth-20+"px"};links.Graph3d.prototype.animationStart=function(){if(!this.frame.filter||!this.frame.filter.slider)throw"No animation available";this.frame.filter.slider.play()};
links.Graph3d.prototype.animationStop=function(){if(!this.frame.filter||!this.frame.filter.slider)throw"No animation available";this.frame.filter.slider.stop()};
links.Graph3d.prototype._resizeCenter=function(){this.xcenter=this.defaultXCenter.charAt(this.defaultXCenter.length-1)==="%"?parseFloat(this.defaultXCenter)/100*this.frame.canvas.clientWidth:parseFloat(this.defaultXCenter);this.ycenter=this.defaultYCenter.charAt(this.defaultYCenter.length-1)==="%"?parseFloat(this.defaultYCenter)/100*(this.frame.canvas.clientHeight-this.frame.filter.clientHeight):parseFloat(this.defaultYCenter)};
links.Graph3d.prototype.setCameraPosition=function(a){a!==void 0&&(a.horizontal!==void 0&&a.vertical!==void 0&&this.camera.setArmRotation(a.horizontal,a.vertical),a.distance!==void 0&&this.camera.setArmLength(a.distance),this.redraw())};links.Graph3d.prototype.getCameraPosition=function(){var a=this.camera.getArmRotation();a.distance=this.camera.getArmLength();return a};
links.Graph3d.prototype._readData=function(a){this._dataInitialize(a,this.style);this.dataPoints=this.dataFilter?this.dataFilter._getDataPoints():this._getDataPoints(this.dataTable);this._redrawFilter()};
links.Graph3d.prototype.redraw=function(a){a!==void 0&&this._readData(a);if(this.dataPoints===void 0)throw"Error: graph data not initialized";this._resizeCanvas();this._resizeCenter();this._redrawSlider();this._redrawClear();this._redrawAxis();this.style===links.Graph3d.STYLE.GRID||this.style===links.Graph3d.STYLE.SURFACE?this._redrawDataGrid():this.style===links.Graph3d.STYLE.LINE?this._redrawDataLine():this.style===links.Graph3d.STYLE.BAR||this.style===links.Graph3d.STYLE.BARCOLOR||this.style===
links.Graph3d.STYLE.BARSIZE?this._redrawDataBar():this._redrawDataDot();this._redrawInfo();this._redrawLegend()};links.Graph3d.prototype._redrawClear=function(){var a=this.frame.canvas;a.getContext("2d").clearRect(0,0,a.width,a.height)};
links.Graph3d.prototype._redrawLegend=function(){var a;if(this.style===links.Graph3d.STYLE.DOTCOLOR||this.style===links.Graph3d.STYLE.DOTSIZE){var b=this.frame.clientWidth*0.02,c,d;this.style===links.Graph3d.STYLE.DOTSIZE?(c=b/2,d=b/2+b*2):d=c=20;var e=Math.max(this.frame.clientHeight*0.25,100),f=this.margin,b=this.frame.clientWidth-this.margin,i=b-d,j=f+e}var g=this.frame.canvas.getContext("2d");g.lineWidth=1;g.font="14px arial";if(this.style===links.Graph3d.STYLE.DOTCOLOR){var h=e;for(a=0;a<h;a++){var k=
this._hsv2rgb((a-0)/(h-0)*240,1,1);g.strokeStyle=k;g.beginPath();g.moveTo(i,f+a);g.lineTo(b,f+a);g.stroke()}g.strokeStyle=this.colorAxis;g.strokeRect(i,f,d,e)}if(this.style===links.Graph3d.STYLE.DOTSIZE)g.strokeStyle=this.colorAxis,g.fillStyle=this.colorDot,g.beginPath(),g.moveTo(i,f),g.lineTo(b,f),g.lineTo(b-d+c,j),g.lineTo(i,j),g.closePath(),g.fill(),g.stroke();if(this.style===links.Graph3d.STYLE.DOTCOLOR||this.style===links.Graph3d.STYLE.DOTSIZE){c=new links.StepNumber(this.valueMin,this.valueMax,
(this.valueMax-this.valueMin)/5,!0);c.start();for(c.getCurrent()<this.valueMin&&c.next();!c.end();)a=j-(c.getCurrent()-this.valueMin)/(this.valueMax-this.valueMin)*e,g.beginPath(),g.moveTo(i-5,a),g.lineTo(i,a),g.stroke(),g.textAlign="right",g.textBaseline="middle",g.fillStyle=this.colorAxis,g.fillText(c.getCurrent(),i-10,a),c.next();g.textAlign="right";g.textBaseline="top";a=this.dataTable.getColumnLabel(this.colValue);g.fillText(a,b,j+this.margin)}};
links.Graph3d.prototype._redrawFilter=function(){this.frame.filter.innerHTML="";if(this.dataFilter){var a=new links.Slider(this.frame.filter,{visible:this.showAnimationControls});this.frame.filter.slider=a;this.frame.filter.style.padding="10px";a.setValues(this.dataFilter.values);a.setPlayInterval(this.animationInterval);var b=this;a.setOnChangeCallback(function(){var c=a.getIndex();b.dataFilter.selectValue(c);b.dataPoints=b.dataFilter._getDataPoints();b.redraw()})}else this.frame.filter.slider=void 0};
links.Graph3d.prototype._redrawSlider=function(){this.frame.filter.slider!==void 0&&this.frame.filter.slider.redraw()};links.Graph3d.prototype._redrawInfo=function(){if(this.dataFilter){var a=this.frame.canvas.getContext("2d");a.font="14px arial";a.lineStyle="gray";a.fillStyle="gray";a.textAlign="left";a.textBaseline="top";var b=this.margin,c=this.margin;a.fillText(this.dataFilter.getLabel()+": "+this.dataFilter.getSelectedValue(),b,c)}};
links.Graph3d.prototype._redrawAxis=function(){var a=this.frame.canvas.getContext("2d"),b,c,d,e,f;a.font=24/this.camera.getArmLength()+"px arial";e=0.025/this.scale.x;var i=0.025/this.scale.y,j=5/this.camera.getArmLength();f=this.camera.getArmRotation().horizontal;a.lineWidth=1;c=this.defaultXStep===void 0;d=new links.StepNumber(this.xMin,this.xMax,this.xStep,c);d.start();for(d.getCurrent()<this.xMin&&d.next();!d.end();){var g=d.getCurrent();this.showGrid?(b=this._convert3Dto2D(new links.Point3d(g,
this.yMin,this.zMin)),c=this._convert3Dto2D(new links.Point3d(g,this.yMax,this.zMin)),a.strokeStyle=this.colorGrid):(b=this._convert3Dto2D(new links.Point3d(g,this.yMin,this.zMin)),c=this._convert3Dto2D(new links.Point3d(g,this.yMin+e,this.zMin)),a.strokeStyle=this.colorAxis,a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(c.x,c.y),a.stroke(),b=this._convert3Dto2D(new links.Point3d(g,this.yMax,this.zMin)),c=this._convert3Dto2D(new links.Point3d(g,this.yMax-e,this.zMin)),a.strokeStyle=this.colorAxis);a.beginPath();
a.moveTo(b.x,b.y);a.lineTo(c.x,c.y);a.stroke();c=Math.cos(f)>0?this.yMin:this.yMax;c=this._convert3Dto2D(new links.Point3d(g,c,this.zMin));Math.cos(f*2)>0?(a.textAlign="center",a.textBaseline="top",c.y+=j):(a.textAlign=Math.sin(f*2)<0?"right":"left",a.textBaseline="middle");a.fillStyle=this.colorAxis;a.fillText("  "+d.getCurrent()+"  ",c.x,c.y);d.next()}a.lineWidth=1;c=this.defaultYStep===void 0;d=new links.StepNumber(this.yMin,this.yMax,this.yStep,c);d.start();for(d.getCurrent()<this.yMin&&d.next();!d.end();)this.showGrid?
(b=this._convert3Dto2D(new links.Point3d(this.xMin,d.getCurrent(),this.zMin)),c=this._convert3Dto2D(new links.Point3d(this.xMax,d.getCurrent(),this.zMin)),a.strokeStyle=this.colorGrid):(b=this._convert3Dto2D(new links.Point3d(this.xMin,d.getCurrent(),this.zMin)),c=this._convert3Dto2D(new links.Point3d(this.xMin+i,d.getCurrent(),this.zMin)),a.strokeStyle=this.colorAxis,a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(c.x,c.y),a.stroke(),b=this._convert3Dto2D(new links.Point3d(this.xMax,d.getCurrent(),this.zMin)),
c=this._convert3Dto2D(new links.Point3d(this.xMax-i,d.getCurrent(),this.zMin)),a.strokeStyle=this.colorAxis),a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(c.x,c.y),a.stroke(),e=Math.sin(f)>0?this.xMin:this.xMax,c=this._convert3Dto2D(new links.Point3d(e,d.getCurrent(),this.zMin)),Math.cos(f*2)<0?(a.textAlign="center",a.textBaseline="top",c.y+=j):(a.textAlign=Math.sin(f*2)>0?"right":"left",a.textBaseline="middle"),a.fillStyle=this.colorAxis,a.fillText("  "+d.getCurrent()+"  ",c.x,c.y),d.next();a.lineWidth=
1;c=this.defaultZStep===void 0;d=new links.StepNumber(this.zMin,this.zMax,this.zStep,c);d.start();d.getCurrent()<this.zMin&&d.next();e=Math.cos(f)>0?this.xMin:this.xMax;for(c=Math.sin(f)<0?this.yMin:this.yMax;!d.end();)b=this._convert3Dto2D(new links.Point3d(e,c,d.getCurrent())),a.strokeStyle=this.colorAxis,a.beginPath(),a.moveTo(b.x,b.y),a.lineTo(b.x-j,b.y),a.stroke(),a.textAlign="right",a.textBaseline="middle",a.fillStyle=this.colorAxis,a.fillText(d.getCurrent()+" ",b.x-5,b.y),d.next();a.lineWidth=
1;b=this._convert3Dto2D(new links.Point3d(e,c,this.zMin));c=this._convert3Dto2D(new links.Point3d(e,c,this.zMax));a.strokeStyle=this.colorAxis;a.beginPath();a.moveTo(b.x,b.y);a.lineTo(c.x,c.y);a.stroke();a.lineWidth=1;c=this._convert3Dto2D(new links.Point3d(this.xMin,this.yMin,this.zMin));e=this._convert3Dto2D(new links.Point3d(this.xMax,this.yMin,this.zMin));a.strokeStyle=this.colorAxis;a.beginPath();a.moveTo(c.x,c.y);a.lineTo(e.x,e.y);a.stroke();c=this._convert3Dto2D(new links.Point3d(this.xMin,
this.yMax,this.zMin));e=this._convert3Dto2D(new links.Point3d(this.xMax,this.yMax,this.zMin));a.strokeStyle=this.colorAxis;a.beginPath();a.moveTo(c.x,c.y);a.lineTo(e.x,e.y);a.stroke();a.lineWidth=1;b=this._convert3Dto2D(new links.Point3d(this.xMin,this.yMin,this.zMin));c=this._convert3Dto2D(new links.Point3d(this.xMin,this.yMax,this.zMin));a.strokeStyle=this.colorAxis;a.beginPath();a.moveTo(b.x,b.y);a.lineTo(c.x,c.y);a.stroke();b=this._convert3Dto2D(new links.Point3d(this.xMax,this.yMin,this.zMin));
c=this._convert3Dto2D(new links.Point3d(this.xMax,this.yMax,this.zMin));a.strokeStyle=this.colorAxis;a.beginPath();a.moveTo(b.x,b.y);a.lineTo(c.x,c.y);a.stroke();i=this.dataTable.getColumnLabel(this.colX);if(i.length>0)c=0.1/this.scale.y,e=(this.xMin+this.xMax)/2,c=Math.cos(f)>0?this.yMin-c:this.yMax+c,c=this._convert3Dto2D(new links.Point3d(e,c,this.zMin)),Math.cos(f*2)>0?(a.textAlign="center",a.textBaseline="top"):(a.textAlign=Math.sin(f*2)<0?"right":"left",a.textBaseline="middle"),a.fillStyle=
this.colorAxis,a.fillText(i,c.x,c.y);i=this.dataTable.getColumnLabel(this.colY);if(i.length>0)c=0.1/this.scale.x,e=Math.sin(f)>0?this.xMin-c:this.xMax+c,c=(this.yMin+this.yMax)/2,c=this._convert3Dto2D(new links.Point3d(e,c,this.zMin)),Math.cos(f*2)<0?(a.textAlign="center",a.textBaseline="top"):(a.textAlign=Math.sin(f*2)>0?"right":"left",a.textBaseline="middle"),a.fillStyle=this.colorAxis,a.fillText(i,c.x,c.y);i=this.dataTable.getColumnLabel(this.colZ);if(i.length>0)e=Math.cos(f)>0?this.xMin:this.xMax,
c=Math.sin(f)<0?this.yMin:this.yMax,f=(this.zMin+this.zMax)/2,c=this._convert3Dto2D(new links.Point3d(e,c,f)),a.textAlign="right",a.textBaseline="middle",a.fillStyle=this.colorAxis,a.fillText(i,c.x-30,c.y)};
links.Graph3d.prototype._hsv2rgb=function(a,b,c){var d;b*=c;c=Math.floor(a/60);d=b*(1-Math.abs(a/60%2-1));switch(c){case 0:a=b;c=d;b=0;break;case 1:a=d;c=b;b=0;break;case 2:a=0;c=b;b=d;break;case 3:a=0;c=d;break;case 4:a=d;c=0;break;case 5:a=b;c=0;b=d;break;default:b=c=a=0}return"RGB("+parseInt(a*255)+","+parseInt(c*255)+","+parseInt(b*255)+")"};
links.Graph3d.prototype._redrawDataGrid=function(){var a=this.frame.canvas.getContext("2d"),b,c,d,e,f,i,j,g;if(!(this.dataPoints===void 0||this.dataPoints.length<=0)){for(f=0;f<this.dataPoints.length;f++)b=this._convertPointToTranslation(this.dataPoints[f].point),c=this._convertTranslationToScreen(b),this.dataPoints[f].trans=b,this.dataPoints[f].screen=c,b=this._convertPointToTranslation(this.dataPoints[f].bottom),this.dataPoints[f].dist=this.showPerspective?b.length():-b.z;this.dataPoints.sort(function(a,
b){return b.dist-a.dist});if(this.style===links.Graph3d.STYLE.SURFACE)for(f=0;f<this.dataPoints.length;f++){if(b=this.dataPoints[f],c=this.dataPoints[f].pointRight,d=this.dataPoints[f].pointTop,e=this.dataPoints[f].pointCross,b!==void 0&&c!==void 0&&d!==void 0&&e!==void 0){if(this.showGrayBottom||this.showShadow){var h=links.Point3d.subtract(e.trans,b.trans),k=links.Point3d.subtract(d.trans,c.trans),h=links.Point3d.crossProduct(h,k),k=h.length();i=h.z>0}else i=!0;i?(j=(b.point.z+c.point.z+d.point.z+
e.point.z)/4,j=(1-(j-this.zMin)*this.scale.z/this.verticalRatio)*240,this.showShadow?(i=Math.min(1+h.x/k/2,1),g=j=this._hsv2rgb(j,1,i)):(i=1,j=this._hsv2rgb(j,1,i),g=this.colorAxis)):(j="gray",g=this.colorAxis);i=0.5;a.lineWidth=i;a.fillStyle=j;a.strokeStyle=g;a.beginPath();a.moveTo(b.screen.x,b.screen.y);a.lineTo(c.screen.x,c.screen.y);a.lineTo(e.screen.x,e.screen.y);a.lineTo(d.screen.x,d.screen.y);a.closePath();a.fill();a.stroke()}}else for(f=0;f<this.dataPoints.length;f++){b=this.dataPoints[f];
c=this.dataPoints[f].pointRight;d=this.dataPoints[f].pointTop;b!==void 0&&(i=this.showPerspective?2/-b.trans.z:2*-(this.eye.z/this.camera.getArmLength()));if(b!==void 0&&c!==void 0)j=(b.point.z+c.point.z)/2,j=(1-(j-this.zMin)*this.scale.z/this.verticalRatio)*240,a.lineWidth=i,a.strokeStyle=this._hsv2rgb(j,1,1),a.beginPath(),a.moveTo(b.screen.x,b.screen.y),a.lineTo(c.screen.x,c.screen.y),a.stroke();if(b!==void 0&&d!==void 0)j=(b.point.z+d.point.z)/2,j=(1-(j-this.zMin)*this.scale.z/this.verticalRatio)*
240,a.lineWidth=i,a.strokeStyle=this._hsv2rgb(j,1,1),a.beginPath(),a.moveTo(b.screen.x,b.screen.y),a.lineTo(d.screen.x,d.screen.y),a.stroke()}}};
links.Graph3d.prototype._redrawDataDot=function(){var a=this.frame.canvas.getContext("2d"),b;if(!(this.dataPoints===void 0||this.dataPoints.length<=0)){for(b=0;b<this.dataPoints.length;b++){var c=this._convertPointToTranslation(this.dataPoints[b].point),d=this._convertTranslationToScreen(c);this.dataPoints[b].trans=c;this.dataPoints[b].screen=d;c=this._convertPointToTranslation(this.dataPoints[b].bottom);this.dataPoints[b].dist=this.showPerspective?c.length():-c.z}this.dataPoints.sort(function(a,
b){return b.dist-a.dist});c=this.frame.clientWidth*0.02;for(b=0;b<this.dataPoints.length;b++){d=this.dataPoints[b];if(this.style===links.Graph3d.STYLE.DOTLINE){var e=this._convert3Dto2D(d.bottom);a.lineWidth=1;a.strokeStyle=this.colorGrid;a.beginPath();a.moveTo(e.x,e.y);a.lineTo(d.screen.x,d.screen.y);a.stroke()}e=this.style===links.Graph3d.STYLE.DOTSIZE?c/2+2*c*(d.point.value-this.valueMin)/(this.valueMax-this.valueMin):c;e=this.showPerspective?e/-d.trans.z:e*-(this.eye.z/this.camera.getArmLength());
e<0&&(e=0);var f,i;this.style===links.Graph3d.STYLE.DOTCOLOR?(f=(1-(d.point.value-this.valueMin)*this.scale.value)*240,i=this._hsv2rgb(f,1,1),f=this._hsv2rgb(f,1,0.8)):this.style===links.Graph3d.STYLE.DOTSIZE?(i=this.colorDot,f=this.colorDotBorder):(f=(1-(d.point.z-this.zMin)*this.scale.z/this.verticalRatio)*240,i=this._hsv2rgb(f,1,1),f=this._hsv2rgb(f,1,0.8));a.lineWidth=1;a.strokeStyle=f;a.fillStyle=i;a.beginPath();a.arc(d.screen.x,d.screen.y,e,0,Math.PI*2,!0);a.fill();a.stroke()}}};
links.Graph3d.prototype._redrawDataBar=function(){var a=this.frame.canvas.getContext("2d"),b,c,d,e;if(!(this.dataPoints===void 0||this.dataPoints.length<=0)){for(b=0;b<this.dataPoints.length;b++){var f=this._convertPointToTranslation(this.dataPoints[b].point),i=this._convertTranslationToScreen(f);this.dataPoints[b].trans=f;this.dataPoints[b].screen=i;f=this._convertPointToTranslation(this.dataPoints[b].bottom);this.dataPoints[b].dist=this.showPerspective?f.length():-f.z}this.dataPoints.sort(function(a,
b){return b.dist-a.dist});f=this.xBarWidth/2;i=this.yBarWidth/2;for(b=0;b<this.dataPoints.length;b++){c=this.dataPoints[b];var j;this.style===links.Graph3d.STYLE.BARCOLOR?(j=(1-(c.point.value-this.valueMin)*this.scale.value)*240,e=this._hsv2rgb(j,1,1),j=this._hsv2rgb(j,1,0.8)):this.style===links.Graph3d.STYLE.BARSIZE?(e=this.colorDot,j=this.colorDotBorder):(j=(1-(c.point.z-this.zMin)*this.scale.z/this.verticalRatio)*240,e=this._hsv2rgb(j,1,1),j=this._hsv2rgb(j,1,0.8));this.style===links.Graph3d.STYLE.BARSIZE&&
(f=this.xBarWidth/2*((c.point.value-this.valueMin)/(this.valueMax-this.valueMin)*0.8+0.2),i=this.yBarWidth/2*((c.point.value-this.valueMin)/(this.valueMax-this.valueMin)*0.8+0.2));var g=this,h=c.point,k=[{point:new links.Point3d(h.x-f,h.y-i,h.z)},{point:new links.Point3d(h.x+f,h.y-i,h.z)},{point:new links.Point3d(h.x+f,h.y+i,h.z)},{point:new links.Point3d(h.x-f,h.y+i,h.z)}],h=[{point:new links.Point3d(h.x-f,h.y-i,this.zMin)},{point:new links.Point3d(h.x+f,h.y-i,this.zMin)},{point:new links.Point3d(h.x+
f,h.y+i,this.zMin)},{point:new links.Point3d(h.x-f,h.y+i,this.zMin)}];k.forEach(function(a){a.screen=g._convert3Dto2D(a.point)});h.forEach(function(a){a.screen=g._convert3Dto2D(a.point)});h=[{corners:k,center:links.Point3d.avg(h[0].point,h[2].point)},{corners:[k[0],k[1],h[1],h[0]],center:links.Point3d.avg(h[1].point,h[0].point)},{corners:[k[1],k[2],h[2],h[1]],center:links.Point3d.avg(h[2].point,h[1].point)},{corners:[k[2],k[3],h[3],h[2]],center:links.Point3d.avg(h[3].point,h[2].point)},{corners:[k[3],
k[0],h[0],h[3]],center:links.Point3d.avg(h[0].point,h[3].point)}];c.surfaces=h;for(c=0;c<h.length;c++){d=h[c];var l=this._convertPointToTranslation(d.center);d.dist=this.showPerspective?l.length():-l.z}h.sort(function(a,b){var c=b.dist-a.dist;return c?c:a.corners===k?1:b.corners===k?-1:0});a.lineWidth=1;a.strokeStyle=j;a.fillStyle=e;for(c=2;c<h.length;c++)d=h[c],e=d.corners,a.beginPath(),a.moveTo(e[3].screen.x,e[3].screen.y),a.lineTo(e[0].screen.x,e[0].screen.y),a.lineTo(e[1].screen.x,e[1].screen.y),
a.lineTo(e[2].screen.x,e[2].screen.y),a.lineTo(e[3].screen.x,e[3].screen.y),a.fill(),a.stroke()}}};
links.Graph3d.prototype._redrawDataLine=function(){var a=this.frame.canvas.getContext("2d"),b,c;if(!(this.dataPoints===void 0||this.dataPoints.length<=0)){for(c=0;c<this.dataPoints.length;c++){b=this._convertPointToTranslation(this.dataPoints[c].point);var d=this._convertTranslationToScreen(b);this.dataPoints[c].trans=b;this.dataPoints[c].screen=d}if(this.dataPoints.length>0)b=this.dataPoints[0],a.lineWidth=1,a.strokeStyle="blue",a.beginPath(),a.moveTo(b.screen.x,b.screen.y);for(c=1;c<this.dataPoints.length;c++)b=
this.dataPoints[c],a.lineTo(b.screen.x,b.screen.y);this.dataPoints.length>0&&a.stroke()}};
links.Graph3d.prototype._onMouseDown=function(a){a=a||window.event;this.leftButtonDown&&this._onMouseUp(a);if((this.leftButtonDown=a.which?a.which===1:a.button===1)||this.touchDown){this.startMouseX=links.getMouseX(a);this.startMouseY=links.getMouseY(a);this.startStart=new Date(this.start);this.startEnd=new Date(this.end);this.startArmRotation=this.camera.getArmRotation();this.frame.style.cursor="move";var b=this;this.onmousemove=function(a){b._onMouseMove(a)};this.onmouseup=function(a){b._onMouseUp(a)};
links.addEventListener(document,"mousemove",b.onmousemove);links.addEventListener(document,"mouseup",b.onmouseup);links.preventDefault(a)}};
links.Graph3d.prototype._onMouseMove=function(a){var a=a||window.event,b=parseFloat(links.getMouseX(a))-this.startMouseX,c=parseFloat(links.getMouseY(a))-this.startMouseY,b=this.startArmRotation.horizontal+b/200,c=this.startArmRotation.vertical+c/200,d=Math.sin(4/360*2*Math.PI);Math.abs(Math.sin(b))<d&&(b=Math.round(b/Math.PI)*Math.PI-0.001);Math.abs(Math.cos(b))<d&&(b=(Math.round(b/Math.PI-0.5)+0.5)*Math.PI-0.001);Math.abs(Math.sin(c))<d&&(c=Math.round(c/Math.PI)*Math.PI);Math.abs(Math.cos(c))<d&&
(c=(Math.round(c/Math.PI-0.5)+0.5)*Math.PI);this.camera.setArmRotation(b,c);this.redraw();b=this.getCameraPosition();google.visualization.events.trigger(this,"camerapositionchange",b);links.preventDefault(a)};links.Graph3d.prototype._onMouseUp=function(a){this.frame.style.cursor="auto";this.leftButtonDown=!1;links.removeEventListener(document,"mousemove",this.onmousemove);links.removeEventListener(document,"mouseup",this.onmouseup);links.preventDefault(a)};
links.Graph3d.prototype._onTooltip=function(a){var b=links.getMouseX(a)-links.getAbsoluteLeft(this.frame),c=links.getMouseY(a)-links.getAbsoluteTop(this.frame);if(this.showTooltip)if(this.tooltipTimeout&&clearTimeout(this.tooltipTimeout),this.leftButtonDown)this._hideTooltip();else if(this.tooltip&&this.tooltip.dataPoint)a=this._dataPointFromXY(b,c),a!==this.tooltip.dataPoint&&(a?this._showTooltip(a):this._hideTooltip());else{var d=this;this.tooltipTimeout=setTimeout(function(){d.tooltipTimeout=null;
var a=d._dataPointFromXY(b,c);a&&d._showTooltip(a)},300)}};links.Graph3d.prototype._onTouchStart=function(a){this.touchDown=!0;var b=this;this.ontouchmove=function(a){b._onTouchMove(a)};this.ontouchend=function(a){b._onTouchEnd(a)};links.addEventListener(document,"touchmove",b.ontouchmove);links.addEventListener(document,"touchend",b.ontouchend);this._onMouseDown(a)};links.Graph3d.prototype._onTouchMove=function(a){this._onMouseMove(a)};
links.Graph3d.prototype._onTouchEnd=function(a){this.touchDown=!1;links.removeEventListener(document,"touchmove",this.ontouchmove);links.removeEventListener(document,"touchend",this.ontouchend);this._onMouseUp(a)};
links.Graph3d.prototype._onWheel=function(a){if(!a)a=window.event;var b=0;a.wheelDelta?b=a.wheelDelta/120:a.detail&&(b=-a.detail/3);b&&(this.camera.setArmLength(this.camera.getArmLength()*(1-b/10)),this.redraw(),this._hideTooltip());b=this.getCameraPosition();google.visualization.events.trigger(this,"camerapositionchange",b);links.preventDefault(a)};
links.Graph3d.prototype._insideTriangle=function(a,b){var c=b[0],d=b[1],e=b[2],f=(d.x-c.x)*(a.y-c.y)-(d.y-c.y)*(a.x-c.x)>0?1:(d.x-c.x)*(a.y-c.y)-(d.y-c.y)*(a.x-c.x)<0?-1:0,d=(e.x-d.x)*(a.y-d.y)-(e.y-d.y)*(a.x-d.x)>0?1:(e.x-d.x)*(a.y-d.y)-(e.y-d.y)*(a.x-d.x)<0?-1:0,c=(c.x-e.x)*(a.y-e.y)-(c.y-e.y)*(a.x-e.x)>0?1:(c.x-e.x)*(a.y-e.y)-(c.y-e.y)*(a.x-e.x)<0?-1:0;return(f==0||d==0||f==d)&&(d==0||c==0||d==c)&&(f==0||c==0||f==c)};
links.Graph3d.prototype._dataPointFromXY=function(a,b){var c,d=null,e=null,f=null,i=new links.Point2d(a,b);if(this.style===links.Graph3d.STYLE.BAR||this.style===links.Graph3d.STYLE.BARCOLOR||this.style===links.Graph3d.STYLE.BARSIZE)for(c=this.dataPoints.length-1;c>=0;c--){if(d=this.dataPoints[c],f=d.surfaces)for(var j=f.length-1;j>=0;j--){var g=f[j].corners,h=[g[2].screen,g[3].screen,g[0].screen];if(this._insideTriangle(i,[g[0].screen,g[1].screen,g[2].screen])||this._insideTriangle(i,h))return d}}else for(c=
0;c<this.dataPoints.length;c++)if(d=this.dataPoints[c],j=d.screen)if(i=Math.abs(a-j.x),j=Math.abs(b-j.y),i=Math.sqrt(i*i+j*j),(f===null||i<f)&&i<100)f=i,e=d;return e};
links.Graph3d.prototype._showTooltip=function(a){var b,c,d;this.tooltip?(b=this.tooltip.dom.content,c=this.tooltip.dom.line,d=this.tooltip.dom.dot):(b=document.createElement("div"),b.style.position="absolute",b.style.padding="10px",b.style.border="1px solid #4d4d4d",b.style.color="#1a1a1a",b.style.background="rgba(255,255,255,0.7)",b.style.borderRadius="2px",b.style.boxShadow="5px 5px 10px rgba(128,128,128,0.5)",c=document.createElement("div"),c.style.position="absolute",c.style.height="40px",c.style.width=
"0",c.style.borderLeft="1px solid #4d4d4d",d=document.createElement("div"),d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.border="5px solid #4d4d4d",d.style.borderRadius="5px",this.tooltip={dataPoint:null,dom:{content:b,line:c,dot:d}});this._hideTooltip();this.tooltip.dataPoint=a;b.innerHTML=typeof this.showTooltip==="function"?this.showTooltip(a.point):"<table><tr><td>x:</td><td>"+a.point.x+"</td></tr><tr><td>y:</td><td>"+a.point.y+"</td></tr><tr><td>z:</td><td>"+a.point.z+
"</td></tr></table>";b.style.left="0";b.style.top="0";this.frame.appendChild(b);this.frame.appendChild(c);this.frame.appendChild(d);var e=b.offsetWidth,f=b.offsetHeight,i=c.offsetHeight,j=d.offsetWidth,g=d.offsetHeight,h=a.screen.x-e/2,h=Math.min(Math.max(h,10),this.frame.clientWidth-10-e);c.style.left=a.screen.x+"px";c.style.top=a.screen.y-i+"px";b.style.left=h+"px";b.style.top=a.screen.y-i-f+"px";d.style.left=a.screen.x-j/2+"px";d.style.top=a.screen.y-g/2+"px"};
links.Graph3d.prototype._hideTooltip=function(){if(this.tooltip){this.tooltip.dataPoint=null;for(var a in this.tooltip.dom)if(this.tooltip.dom.hasOwnProperty(a)){var b=this.tooltip.dom[a];b&&b.parentNode&&b.parentNode.removeChild(b)}}};links.Point3d=function(a,b,c){this.x=a!==void 0?a:0;this.y=b!==void 0?b:0;this.z=c!==void 0?c:0};links.Point3d.subtract=function(a,b){var c=new links.Point3d;c.x=a.x-b.x;c.y=a.y-b.y;c.z=a.z-b.z;return c};
links.Point3d.add=function(a,b){var c=new links.Point3d;c.x=a.x+b.x;c.y=a.y+b.y;c.z=a.z+b.z;return c};links.Point3d.avg=function(a,b){return new links.Point3d((a.x+b.x)/2,(a.y+b.y)/2,(a.z+b.z)/2)};links.Point3d.crossProduct=function(a,b){var c=new links.Point3d;c.x=a.y*b.z-a.z*b.y;c.y=a.z*b.x-a.x*b.z;c.z=a.x*b.y-a.y*b.x;return c};links.Point3d.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)};
links.Point2d=function(a,b){this.x=a!==void 0?a:0;this.y=b!==void 0?b:0};links.Filter=function(a,b,c){this.data=a;this.column=b;this.graph=c;this.value=this.index=void 0;this.values=a.getDistinctValues(this.column);this.values.length&&this.selectValue(0);this.dataPoints=[];this.loaded=!1;this.onLoadCallback=void 0;c.animationPreload?(this.loaded=!1,this.loadInBackground()):this.loaded=!0};links.Filter.prototype.isLoaded=function(){return this.loaded};
links.Filter.prototype.getLoadedProgress=function(){for(var a=this.values.length,b=0;this.dataPoints[b];)b++;return Math.round(b/a*100)};links.Filter.prototype.getLabel=function(){return this.data.getColumnLabel(this.column)};links.Filter.prototype.getColumn=function(){return this.column};links.Filter.prototype.getSelectedValue=function(){return this.index===void 0?void 0:this.values[this.index]};links.Filter.prototype.getValues=function(){return this.values};
links.Filter.prototype.getValue=function(a){if(a>=this.values.length)throw"Error: index out of range";return this.values[a]};links.Filter.prototype._getDataPoints=function(a){if(a===void 0)a=this.index;if(a===void 0)return[];var b;if(this.dataPoints[a])b=this.dataPoints[a];else{b=new google.visualization.DataView(this.data);var c={};c.column=this.column;c.value=this.values[a];c=this.data.getFilteredRows([c]);b.setRows(c);b=this.graph._getDataPoints(b);this.dataPoints[a]=b}return b};
links.Filter.prototype.setOnLoadCallback=function(a){this.onLoadCallback=a};links.Filter.prototype.selectValue=function(a){if(a>=this.values.length)throw"Error: index out of range";this.index=a;this.value=this.values[a]};
links.Filter.prototype.loadInBackground=function(a){a===void 0&&(a=0);var b=this.graph.frame;if(a<this.values.length){this._getDataPoints(a);if(b.progress===void 0)b.progress=document.createElement("DIV"),b.progress.style.position="absolute",b.progress.style.color="gray",b.appendChild(b.progress);var c=this.getLoadedProgress();b.progress.innerHTML="Loading animation... "+c+"%";b.progress.style.bottom=links.Graph3d.px(60);b.progress.style.left=links.Graph3d.px(10);var d=this;setTimeout(function(){d.loadInBackground(a+
1)},10);this.loaded=!1}else{this.loaded=!0;if(b.progress!==void 0)b.removeChild(b.progress),b.progress=void 0;if(this.onLoadCallback)this.onLoadCallback()}};links.StepNumber=function(a,b,c,d){this._end=this._start=0;this._step=1;this.prettyStep=!0;this.precision=5;this._current=0;this.setRange(a,b,c,d)};links.StepNumber.prototype.setRange=function(a,b,c,d){this._start=a?a:0;this._end=b?b:0;this.setStep(c,d)};
links.StepNumber.prototype.setStep=function(a,b){if(!(a===void 0||a<=0)){if(b!==void 0)this.prettyStep=b;this._step=this.prettyStep===!0?links.StepNumber.calculatePrettyStep(a):a}};links.StepNumber.calculatePrettyStep=function(a){var b=Math.pow(10,Math.round(Math.log(a)/Math.LN10)),c=2*Math.pow(10,Math.round(Math.log(a/2)/Math.LN10)),d=5*Math.pow(10,Math.round(Math.log(a/5)/Math.LN10));Math.abs(c-a)<=Math.abs(b-a)&&(b=c);Math.abs(d-a)<=Math.abs(b-a)&&(b=d);b<=0&&(b=1);return b};
links.StepNumber.prototype.getCurrent=function(){return parseFloat(this._current.toPrecision(this.precision))};links.StepNumber.prototype.getStep=function(){return this._step};links.StepNumber.prototype.start=function(){this._current=this._start-this._start%this._step};links.StepNumber.prototype.next=function(){this._current+=this._step};links.StepNumber.prototype.end=function(){return this._current>this._end};
links.Slider=function(a,b){if(a===void 0)throw"Error: No container element defined";this.container=a;if(this.visible=b&&b.visible!=void 0?b.visible:!0){this.frame=document.createElement("DIV");this.frame.style.width="100%";this.frame.style.position="relative";this.container.appendChild(this.frame);this.frame.prev=document.createElement("INPUT");this.frame.prev.type="BUTTON";this.frame.prev.value="Prev";this.frame.appendChild(this.frame.prev);this.frame.play=document.createElement("INPUT");this.frame.play.type=
"BUTTON";this.frame.play.value="Play";this.frame.appendChild(this.frame.play);this.frame.next=document.createElement("INPUT");this.frame.next.type="BUTTON";this.frame.next.value="Next";this.frame.appendChild(this.frame.next);this.frame.bar=document.createElement("INPUT");this.frame.bar.type="BUTTON";this.frame.bar.style.position="absolute";this.frame.bar.style.border="1px solid red";this.frame.bar.style.width="100px";this.frame.bar.style.height="6px";this.frame.bar.style.borderRadius="2px";this.frame.bar.style.MozBorderRadius=
"2px";this.frame.bar.style.border="1px solid #7F7F7F";this.frame.bar.style.backgroundColor="#E5E5E5";this.frame.appendChild(this.frame.bar);this.frame.slide=document.createElement("INPUT");this.frame.slide.type="BUTTON";this.frame.slide.style.margin="0px";this.frame.slide.value=" ";this.frame.slide.style.position="relative";this.frame.slide.style.left="-100px";this.frame.appendChild(this.frame.slide);var c=this;this.frame.slide.onmousedown=function(a){c._onMouseDown(a)};this.frame.prev.onclick=function(a){c.prev(a)};
this.frame.play.onclick=function(a){c.togglePlay(a)};this.frame.next.onclick=function(a){c.next(a)}}this.onChangeCallback=void 0;this.values=[];this.playTimeout=this.index=void 0;this.playInterval=1E3;this.playLoop=!0};links.Slider.prototype.prev=function(){var a=this.getIndex();a>0&&(a--,this.setIndex(a))};links.Slider.prototype.next=function(){var a=this.getIndex();a<this.values.length-1&&(a++,this.setIndex(a))};
links.Slider.prototype.playNext=function(){var a=new Date,b=this.getIndex();b<this.values.length-1?(b++,this.setIndex(b)):this.playLoop&&this.setIndex(0);var a=Math.max(this.playInterval-(new Date-a),0),c=this;this.playTimeout=setTimeout(function(){c.playNext()},a)};links.Slider.prototype.togglePlay=function(){this.playTimeout===void 0?this.play():this.stop()};links.Slider.prototype.play=function(){this.playNext();if(this.frame)this.frame.play.value="Stop"};
links.Slider.prototype.stop=function(){clearInterval(this.playTimeout);this.playTimeout=void 0;if(this.frame)this.frame.play.value="Play"};links.Slider.prototype.setOnChangeCallback=function(a){this.onChangeCallback=a};links.Slider.prototype.setPlayInterval=function(a){this.playInterval=a};links.Slider.prototype.getPlayInterval=function(){return this.playInterval};links.Slider.prototype.setPlayLoop=function(a){this.playLoop=a};
links.Slider.prototype.onChange=function(){if(this.onChangeCallback!==void 0)this.onChangeCallback()};links.Slider.prototype.redraw=function(){if(this.frame)this.frame.bar.style.top=this.frame.clientHeight/2-this.frame.bar.offsetHeight/2+"px",this.frame.bar.style.width=this.frame.clientWidth-this.frame.prev.clientWidth-this.frame.play.clientWidth-this.frame.next.clientWidth-30+"px",this.frame.slide.style.left=this.indexToLeft(this.index)+"px"};
links.Slider.prototype.setValues=function(a){this.values=a;this.values.length>0?this.setIndex(0):this.index=void 0};links.Slider.prototype.setIndex=function(a){if(a<this.values.length)this.index=a,this.redraw(),this.onChange();else throw"Error: index out of range";};links.Slider.prototype.getIndex=function(){return this.index};links.Slider.prototype.get=function(){return this.values[this.index]};
links.Slider.prototype._onMouseDown=function(a){if(a.which?a.which===1:a.button===1){this.startClientX=a.clientX;this.startSlideX=parseFloat(this.frame.slide.style.left);this.frame.style.cursor="move";var b=this;this.onmousemove=function(a){b._onMouseMove(a)};this.onmouseup=function(a){b._onMouseUp(a)};links.addEventListener(document,"mousemove",this.onmousemove);links.addEventListener(document,"mouseup",this.onmouseup);links.preventDefault(a)}};
links.Slider.prototype.leftToIndex=function(a){var b=parseFloat(this.frame.bar.style.width)-this.frame.slide.clientWidth-10,a=Math.round((a-3)/b*(this.values.length-1));a<0&&(a=0);a>this.values.length-1&&(a=this.values.length-1);return a};links.Slider.prototype.indexToLeft=function(a){var b=parseFloat(this.frame.bar.style.width)-this.frame.slide.clientWidth-10;return a/(this.values.length-1)*b+3};
links.Slider.prototype._onMouseMove=function(a){this.setIndex(this.leftToIndex(this.startSlideX+(a.clientX-this.startClientX)));links.preventDefault()};links.Slider.prototype._onMouseUp=function(){this.frame.style.cursor="auto";links.removeEventListener(document,"mousemove",this.onmousemove);links.removeEventListener(document,"mouseup",this.onmouseup);links.preventDefault()};
links.addEventListener=function(a,b,c,d){a.addEventListener?(d===void 0&&(d=!1),b==="mousewheel"&&navigator.userAgent.indexOf("Firefox")>=0&&(b="DOMMouseScroll"),a.addEventListener(b,c,d)):a.attachEvent("on"+b,c)};links.removeEventListener=function(a,b,c,d){a.removeEventListener?(d===void 0&&(d=!1),b==="mousewheel"&&navigator.userAgent.indexOf("Firefox")>=0&&(b="DOMMouseScroll"),a.removeEventListener(b,c,d)):a.detachEvent("on"+b,c)};
links.stopPropagation=function(a){if(!a)a=window.event;a.stopPropagation?a.stopPropagation():a.cancelBubble=!0};links.preventDefault=function(a){if(!a)a=window.event;a.preventDefault?a.preventDefault():a.returnValue=!1};links.getAbsoluteLeft=function(a){for(var b=0;a!==null;)b+=a.offsetLeft,b-=a.scrollLeft,a=a.offsetParent;return b};links.getAbsoluteTop=function(a){for(var b=0;a!==null;)b+=a.offsetTop,b-=a.scrollTop,a=a.offsetParent;return b};
links.getMouseX=function(a){return"clientX"in a?a.clientX:a.targetTouches[0]&&a.targetTouches[0].clientX||0};links.getMouseY=function(a){return"clientY"in a?a.clientY:a.targetTouches[0]&&a.targetTouches[0].clientY||0};