vis-graph3d
Version:
Create interactive, animated 3d graphs. Surfaces, lines, dots and block styling out of the box.
26 lines • 55.8 kB
JavaScript
/**
* vis-graph3d
* https://visjs.github.io/vis-graph3d/
*
* Create interactive, animated 3d graphs. Surfaces, lines, dots and block styling out of the box.
*
* @version 7.0.2
* @date 2025-09-15T17:38:11.097Z
*
* @copyright (c) 2011-2017 Almende B.V, http://almende.com
* @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
*
* @license
* vis.js is dual licensed under both
*
* 1. The Apache 2.0 License
* http://www.apache.org/licenses/LICENSE-2.0
*
* and
*
* 2. The MIT License
* http://opensource.org/licenses/MIT
*
* vis.js may be distributed under either license.
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("component-emitter"),require("vis-util/esnext/umd/vis-util.js"),require("vis-data/esnext/umd/vis-data.js")):"function"==typeof define&&define.amd?define(["exports","component-emitter","vis-util/esnext/umd/vis-util.js","vis-data/esnext/umd/vis-data.js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).vis=t.vis||{},t.Emitter,t.vis,t.vis)}(this,function(t,e,i,o){function n(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(i){if("default"!==i){var o=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:function(){return t[i]}})}}),e.default=t,Object.freeze(e)}var s=n(i);function a(t,e,i){this.x=void 0!==t?t:0,this.y=void 0!==e?e:0,this.z=void 0!==i?i:0}function r(t,e){this.x=void 0!==t?t:0,this.y=void 0!==e?e:0}function h(t,e){if(void 0===t)throw new Error("No container element defined");if(this.container=t,this.visible=!e||null==e.visible||e.visible,this.visible){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);const t=this;this.frame.slide.onmousedown=function(e){t._onMouseDown(e)},this.frame.prev.onclick=function(e){t.prev(e)},this.frame.play.onclick=function(e){t.togglePlay(e)},this.frame.next.onclick=function(e){t.next(e)}}this.onChangeCallback=void 0,this.values=[],this.index=void 0,this.playTimeout=void 0,this.playInterval=1e3,this.playLoop=!0}function l(t,e,i,o){this._start=0,this._end=0,this._step=1,this.prettyStep=!0,this.precision=5,this._current=0,this.setRange(t,e,i,o)}function c(){this.armLocation=new a,this.armRotation={},this.armRotation.horizontal=0,this.armRotation.vertical=0,this.armLength=1.7,this.cameraOffset=new a,this.offsetMultiplier=.6,this.cameraLocation=new a,this.cameraRotation=new a(.5*Math.PI,0,0),this.calculateCameraOrientation()}a.subtract=function(t,e){const i=new a;return i.x=t.x-e.x,i.y=t.y-e.y,i.z=t.z-e.z,i},a.add=function(t,e){const i=new a;return i.x=t.x+e.x,i.y=t.y+e.y,i.z=t.z+e.z,i},a.avg=function(t,e){return new a((t.x+e.x)/2,(t.y+e.y)/2,(t.z+e.z)/2)},a.scalarProduct=function(t,e){return new a(t.x*e,t.y*e,t.z*e)},a.dotProduct=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z},a.crossProduct=function(t,e){const i=new a;return i.x=t.y*e.z-t.z*e.y,i.y=t.z*e.x-t.x*e.z,i.z=t.x*e.y-t.y*e.x,i},a.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},a.prototype.normalize=function(){return a.scalarProduct(this,1/this.length())},h.prototype.prev=function(){let t=this.getIndex();t>0&&(t--,this.setIndex(t))},h.prototype.next=function(){let t=this.getIndex();t<this.values.length-1&&(t++,this.setIndex(t))},h.prototype.playNext=function(){const t=new Date;let e=this.getIndex();e<this.values.length-1?(e++,this.setIndex(e)):this.playLoop&&(e=0,this.setIndex(e));const i=new Date-t,o=Math.max(this.playInterval-i,0),n=this;this.playTimeout=setTimeout(function(){n.playNext()},o)},h.prototype.togglePlay=function(){void 0===this.playTimeout?this.play():this.stop()},h.prototype.play=function(){this.playTimeout||(this.playNext(),this.frame&&(this.frame.play.value="Stop"))},h.prototype.stop=function(){clearInterval(this.playTimeout),this.playTimeout=void 0,this.frame&&(this.frame.play.value="Play")},h.prototype.setOnChangeCallback=function(t){this.onChangeCallback=t},h.prototype.setPlayInterval=function(t){this.playInterval=t},h.prototype.getPlayInterval=function(){return this.playInterval},h.prototype.setPlayLoop=function(t){this.playLoop=t},h.prototype.onChange=function(){void 0!==this.onChangeCallback&&this.onChangeCallback()},h.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";const t=this.indexToLeft(this.index);this.frame.slide.style.left=t+"px"}},h.prototype.setValues=function(t){this.values=t,this.values.length>0?this.setIndex(0):this.index=void 0},h.prototype.setIndex=function(t){if(!(t<this.values.length))throw new Error("Index out of range");this.index=t,this.redraw(),this.onChange()},h.prototype.getIndex=function(){return this.index},h.prototype.get=function(){return this.values[this.index]},h.prototype._onMouseDown=function(t){if(!(t.which?1===t.which:1===t.button))return;this.startClientX=t.clientX,this.startSlideX=parseFloat(this.frame.slide.style.left),this.frame.style.cursor="move";const e=this;this.onmousemove=function(t){e._onMouseMove(t)},this.onmouseup=function(t){e._onMouseUp(t)},document.addEventListener("mousemove",this.onmousemove),document.addEventListener("mouseup",this.onmouseup),s.preventDefault(t)},h.prototype.leftToIndex=function(t){const e=parseFloat(this.frame.bar.style.width)-this.frame.slide.clientWidth-10,i=t-3;let o=Math.round(i/e*(this.values.length-1));return o<0&&(o=0),o>this.values.length-1&&(o=this.values.length-1),o},h.prototype.indexToLeft=function(t){const e=parseFloat(this.frame.bar.style.width)-this.frame.slide.clientWidth-10;return t/(this.values.length-1)*e+3},h.prototype._onMouseMove=function(t){const e=t.clientX-this.startClientX,i=this.startSlideX+e,o=this.leftToIndex(i);this.setIndex(o),s.preventDefault()},h.prototype._onMouseUp=function(){this.frame.style.cursor="auto",document.removeEventListener("mousemove",this.onmousemove),document.removeEventListener("mouseup",this.onmouseup),s.preventDefault()},l.prototype.isNumeric=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},l.prototype.setRange=function(t,e,i,o){if(!this.isNumeric(t))throw new Error("Parameter 'start' is not numeric; value: "+t);if(!this.isNumeric(e))throw new Error("Parameter 'end' is not numeric; value: "+t);if(!this.isNumeric(i))throw new Error("Parameter 'step' is not numeric; value: "+t);this._start=t||0,this._end=e||0,this.setStep(i,o)},l.prototype.setStep=function(t,e){void 0===t||t<=0||(void 0!==e&&(this.prettyStep=e),!0===this.prettyStep?this._step=l.calculatePrettyStep(t):this._step=t)},l.calculatePrettyStep=function(t){const e=function(t){return Math.log(t)/Math.LN10},i=Math.pow(10,Math.round(e(t))),o=2*Math.pow(10,Math.round(e(t/2))),n=5*Math.pow(10,Math.round(e(t/5)));let s=i;return Math.abs(o-t)<=Math.abs(s-t)&&(s=o),Math.abs(n-t)<=Math.abs(s-t)&&(s=n),s<=0&&(s=1),s},l.prototype.getCurrent=function(){return parseFloat(this._current.toPrecision(this.precision))},l.prototype.getStep=function(){return this._step},l.prototype.start=function(t){void 0===t&&(t=!1),this._current=this._start-this._start%this._step,t&&this.getCurrent()<this._start&&this.next()},l.prototype.next=function(){this._current+=this._step},l.prototype.end=function(){return this._current>this._end},c.prototype.setOffset=function(t,e){const i=Math.abs,o=Math.sign,n=this.offsetMultiplier,s=this.armLength*n;i(t)>s&&(t=o(t)*s),i(e)>s&&(e=o(e)*s),this.cameraOffset.x=t,this.cameraOffset.y=e,this.calculateCameraOrientation()},c.prototype.getOffset=function(){return this.cameraOffset},c.prototype.setArmLocation=function(t,e,i){this.armLocation.x=t,this.armLocation.y=e,this.armLocation.z=i,this.calculateCameraOrientation()},c.prototype.setArmRotation=function(t,e){void 0!==t&&(this.armRotation.horizontal=t),void 0!==e&&(this.armRotation.vertical=e,this.armRotation.vertical<0&&(this.armRotation.vertical=0),this.armRotation.vertical>.5*Math.PI&&(this.armRotation.vertical=.5*Math.PI)),void 0===t&&void 0===e||this.calculateCameraOrientation()},c.prototype.getArmRotation=function(){const t={};return t.horizontal=this.armRotation.horizontal,t.vertical=this.armRotation.vertical,t},c.prototype.setArmLength=function(t){void 0!==t&&(this.armLength=t,this.armLength<.71&&(this.armLength=.71),this.armLength>5&&(this.armLength=5),this.setOffset(this.cameraOffset.x,this.cameraOffset.y),this.calculateCameraOrientation())},c.prototype.getArmLength=function(){return this.armLength},c.prototype.getCameraLocation=function(){return this.cameraLocation},c.prototype.getCameraRotation=function(){return this.cameraRotation},c.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;const t=this.cameraRotation.x,e=this.cameraRotation.z,i=this.cameraOffset.x,o=this.cameraOffset.y,n=Math.sin,s=Math.cos;this.cameraLocation.x=this.cameraLocation.x+i*s(e)+o*-n(e)*s(t),this.cameraLocation.y=this.cameraLocation.y+i*n(e)+o*s(e)*s(t),this.cameraLocation.z=this.cameraLocation.z+o*n(t)};const d={BAR:0,BARCOLOR:1,BARSIZE:2,DOT:3,DOTLINE:4,DOTCOLOR:5,DOTSIZE:6,GRID:7,LINE:8,SURFACE:9},u={dot:d.DOT,"dot-line":d.DOTLINE,"dot-color":d.DOTCOLOR,"dot-size":d.DOTSIZE,line:d.LINE,grid:d.GRID,surface:d.SURFACE,bar:d.BAR,"bar-color":d.BARCOLOR,"bar-size":d.BARSIZE},p=["width","height","filterLabel","legendLabel","xLabel","yLabel","zLabel","xValueLabel","yValueLabel","zValueLabel","showXAxis","showYAxis","showZAxis","showGrayBottom","showGrid","showPerspective","showShadow","showSurfaceGrid","keepAspectRatio","rotateAxisLabels","verticalRatio","dotSizeRatio","dotSizeMinFraction","dotSizeMaxFraction","showAnimationControls","animationInterval","animationPreload","animationAutoStart","axisColor","axisFontSize","axisFontType","gridColor","xCenter","yCenter","zoomable","tooltipDelay","ctrlToZoom"],f=["xBarWidth","yBarWidth","valueMin","valueMax","xMin","xMax","xStep","yMin","yMax","yStep","zMin","zMax","zStep"];let m;function y(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function g(t,e){return void 0===t||""===t?e:t+(void 0===(i=e)||""===i||"string"!=typeof i?i:i.charAt(0).toUpperCase()+i.slice(1));var i}function x(t,e,i,o){let n,s;for(let a=0;a<i.length;++a)n=i[a],s=g(o,n),e[s]=t[n]}function v(t,e,i,o){let n,s;for(let a=0;a<i.length;++a)n=i[a],void 0!==t[n]&&(s=g(o,n),e[s]=t[n])}function w(t,e){if(void 0!==t.backgroundColor&&function(t,e){let i="white",o="gray",n=1;if("string"==typeof t)i=t,o="none",n=0;else{if("object"!=typeof t)throw new Error("Unsupported type of backgroundColor");void 0!==t.fill&&(i=t.fill),void 0!==t.stroke&&(o=t.stroke),void 0!==t.strokeWidth&&(n=t.strokeWidth)}e.frame.style.backgroundColor=i,e.frame.style.borderColor=o,e.frame.style.borderWidth=n+"px",e.frame.style.borderStyle="solid"}(t.backgroundColor,e),function(t,e){if(void 0===t)return;void 0===e.dataColor&&(e.dataColor={});"string"==typeof t?(e.dataColor.fill=t,e.dataColor.stroke=t):(t.fill&&(e.dataColor.fill=t.fill),t.stroke&&(e.dataColor.stroke=t.stroke),void 0!==t.strokeWidth&&(e.dataColor.strokeWidth=t.strokeWidth))}(t.dataColor,e),function(t,e){if(void 0===t)return;let i;if("string"==typeof t){if(i=function(t){const e=u[t];if(void 0===e)return-1;return e}(t),-1===i)throw new Error("Style '"+t+"' is invalid")}else{if(!function(t){let e=!1;for(const i in d)if(d[i]===t){e=!0;break}return e}(t))throw new Error("Style '"+t+"' is invalid");i=t}e.style=i}(t.style,e),void 0!==t.surfaceColors){if(console.warn("`options.surfaceColors` is deprecated and may be removed in a future version. Please use `options.colormap` instead. Note that the `colormap` option uses the inverse array ordering (running from vMin to vMax)."),void 0!==t.colormap)throw new Error("The `colormap` and `surfaceColors` options are mutually exclusive.");"surface"!==e.style?console.warn("Ignoring `surfaceColors` in graph style `"+e.style+"` for backward compatibility (only effective in `surface` plots)."):function(t,e){if(void 0===t||!0===t)return;if(!1===t)return void(e.surfaceColors=void 0);void 0===e.surfaceColors&&(e.surfaceColors={});let i;if(Array.isArray(t))i=b(t);else{if("object"!=typeof t)throw new Error("Unsupported type of surfaceColors");i=_(t.hue)}i.reverse(),e.colormap=i}(t.surfaceColors,e)}else!function(t,e){if(void 0===t)return;let i;if(Array.isArray(t))i=b(t);else if("object"==typeof t)i=_(t.hue);else{if("function"!=typeof t)throw new Error("Unsupported type of colormap");i=t}e.colormap=i}(t.colormap,e);!function(t,e){if(void 0===t){if(void 0===m.showLegend){const t=e.style===d.DOTCOLOR||e.style===d.DOTSIZE;e.showLegend=t}}else e.showLegend=t}(t.showLegend,e),C(t.cameraPosition,e),void 0!==t.tooltip&&(e.showTooltip=t.tooltip),null!=t.onclick&&(e.onclick_callback=t.onclick,console.warn("`options.onclick` is deprecated and may be removed in a future version. Please use `Graph3d.on('click', handler)` instead.")),void 0!==t.tooltipStyle&&s.selectiveDeepExtend(["tooltipStyle"],e,t)}function b(t){if(t.length<2)throw new Error("Colormap array length must be 2 or above.");return t.map(function(t){if(!s.isValidHex(t))throw new Error("Invalid hex color code supplied to colormap.");return s.hexToRGB(t)})}function _(t){if(void 0===t)throw new Error("Unsupported type of colormap");if(!(t.saturation>=0&&t.saturation<=100))throw new Error("Saturation is out of bounds. Expected range is 0-100.");if(!(t.brightness>=0&&t.brightness<=100))throw new Error("Brightness is out of bounds. Expected range is 0-100.");if(!(t.colorStops>=2))throw new Error("colorStops is out of bounds. Expected 2 or above.");const e=(t.end-t.start)/(t.colorStops-1),i=[];for(let o=0;o<t.colorStops;++o){const n=(t.start+e*o)%360/360;i.push(s.HSVToRGB(n<0?n+1:n,t.saturation/100,t.brightness/100))}return i}function C(t,e){const i=t;void 0!==i&&(void 0===e.camera&&(e.camera=new c),e.camera.setArmRotation(i.horizontal,i.vertical),e.camera.setArmLength(i.distance))}const L="string",S="boolean",T="number",R="object",M="array",D={fill:{string:L},stroke:{string:L},strokeWidth:{number:T},__type__:{string:L,object:R,undefined:"undefined"}},z={animationAutoStart:{boolean:S,undefined:"undefined"},animationInterval:{number:T},animationPreload:{boolean:S},axisColor:{string:L},axisFontSize:{number:T},axisFontType:{string:L},backgroundColor:D,xBarWidth:{number:T,undefined:"undefined"},yBarWidth:{number:T,undefined:"undefined"},cameraPosition:{distance:{number:T},horizontal:{number:T},vertical:{number:T},__type__:{object:R}},zoomable:{boolean:S},ctrlToZoom:{boolean:S},xCenter:{string:L},yCenter:{string:L},colormap:{hue:{start:{number:T},end:{number:T},saturation:{number:T},brightness:{number:T},colorStops:{number:T},__type__:{object:R}},__type__:{array:M,object:R,function:"function",undefined:"undefined"}},dataColor:D,dotSizeMinFraction:{number:T},dotSizeMaxFraction:{number:T},dotSizeRatio:{number:T},filterLabel:{string:L},gridColor:{string:L},onclick:{function:"function"},keepAspectRatio:{boolean:S},xLabel:{string:L},yLabel:{string:L},zLabel:{string:L},legendLabel:{string:L},xMin:{number:T,undefined:"undefined"},yMin:{number:T,undefined:"undefined"},zMin:{number:T,undefined:"undefined"},xMax:{number:T,undefined:"undefined"},yMax:{number:T,undefined:"undefined"},zMax:{number:T,undefined:"undefined"},showAnimationControls:{boolean:S,undefined:"undefined"},showGrayBottom:{boolean:S},showGrid:{boolean:S},showLegend:{boolean:S,undefined:"undefined"},showPerspective:{boolean:S},showShadow:{boolean:S},showSurfaceGrid:{boolean:S},showXAxis:{boolean:S},showYAxis:{boolean:S},showZAxis:{boolean:S},rotateAxisLabels:{boolean:S},surfaceColors:{hue:{start:{number:T},end:{number:T},saturation:{number:T},brightness:{number:T},colorStops:{number:T},__type__:{object:R}},__type__:{boolean:S,array:M,object:R,undefined:"undefined"}},xStep:{number:T,undefined:"undefined"},yStep:{number:T,undefined:"undefined"},zStep:{number:T,undefined:"undefined"},style:{number:T,string:["bar","bar-color","bar-size","dot","dot-line","dot-color","dot-size","line","grid","surface"]},tooltip:{boolean:S,function:"function"},tooltipDelay:{number:T},tooltipStyle:{content:{color:{string:L},background:{string:L},border:{string:L},borderRadius:{string:L},boxShadow:{string:L},padding:{string:L},__type__:{object:R}},line:{borderLeft:{string:L},height:{string:L},width:{string:L},pointerEvents:{string:L},__type__:{object:R}},dot:{border:{string:L},borderRadius:{string:L},height:{string:L},width:{string:L},pointerEvents:{string:L},__type__:{object:R}},__type__:{object:R}},xValueLabel:{function:"function"},yValueLabel:{function:"function"},zValueLabel:{function:"function"},valueMax:{number:T,undefined:"undefined"},valueMin:{number:T,undefined:"undefined"},verticalRatio:{number:T},height:{string:L},width:{string:L},__type__:{object:R}};function E(){this.min=void 0,this.max=void 0}function P(t,e,i){this.dataGroup=t,this.column=e,this.graph=i,this.index=void 0,this.value=void 0,this.values=t.getDistinctValues(this.column),this.values.length>0&&this.selectValue(0),this.dataPoints=[],this.loaded=!1,this.onLoadCallback=void 0,i.animationPreload?(this.loaded=!1,this.loadInBackground()):this.loaded=!0}function A(){this.dataTable=null}E.prototype.adjust=function(t){void 0!==t&&((void 0===this.min||this.min>t)&&(this.min=t),(void 0===this.max||this.max<t)&&(this.max=t))},E.prototype.combine=function(t){this.add(t.min),this.add(t.max)},E.prototype.expand=function(t){if(void 0===t)return;const e=this.min-t,i=this.max+t;if(e>i)throw new Error("Passed expansion value makes range invalid");this.min=e,this.max=i},E.prototype.range=function(){return this.max-this.min},E.prototype.center=function(){return(this.min+this.max)/2},P.prototype.isLoaded=function(){return this.loaded},P.prototype.getLoadedProgress=function(){const t=this.values.length;let e=0;for(;this.dataPoints[e];)e++;return Math.round(e/t*100)},P.prototype.getLabel=function(){return this.graph.filterLabel},P.prototype.getColumn=function(){return this.column},P.prototype.getSelectedValue=function(){if(void 0!==this.index)return this.values[this.index]},P.prototype.getValues=function(){return this.values},P.prototype.getValue=function(t){if(t>=this.values.length)throw new Error("Index out of range");return this.values[t]},P.prototype._getDataPoints=function(t){if(void 0===t&&(t=this.index),void 0===t)return[];let e;if(this.dataPoints[t])e=this.dataPoints[t];else{const i={};i.column=this.column,i.value=this.values[t];const n=new o.DataView(this.dataGroup.getDataSet(),{filter:function(t){return t[i.column]==i.value}}).get();e=this.dataGroup._getDataPoints(n),this.dataPoints[t]=e}return e},P.prototype.setOnLoadCallback=function(t){this.onLoadCallback=t},P.prototype.selectValue=function(t){if(t>=this.values.length)throw new Error("Index out of range");this.index=t,this.value=this.values[t]},P.prototype.loadInBackground=function(t){void 0===t&&(t=0);const e=this.graph.frame;if(t<this.values.length){void 0===e.progress&&(e.progress=document.createElement("DIV"),e.progress.style.position="absolute",e.progress.style.color="gray",e.appendChild(e.progress));const i=this.getLoadedProgress();e.progress.innerHTML="Loading animation... "+i+"%",e.progress.style.bottom="60px",e.progress.style.left="10px";const o=this;setTimeout(function(){o.loadInBackground(t+1)},10),this.loaded=!1}else this.loaded=!0,void 0!==e.progress&&(e.removeChild(e.progress),e.progress=void 0),this.onLoadCallback&&this.onLoadCallback()},A.prototype.initializeData=function(t,e,i){if(void 0===e)return;let n;if(Array.isArray(e)&&(e=new o.DataSet(e)),!(e instanceof o.DataSet||e instanceof o.DataView))throw new Error("Array, DataSet, or DataView expected");if(n=e.get(),0==n.length)return;this.style=i,this.dataSet&&this.dataSet.off("*",this._onChange),this.dataSet=e,this.dataTable=n;const s=this;this._onChange=function(){t.setData(s.dataSet)},this.dataSet.on("*",this._onChange),this.colX="x",this.colY="y",this.colZ="z";const a=t.hasBars(i);if(a&&(void 0!==t.defaultXBarWidth?this.xBarWidth=t.defaultXBarWidth:this.xBarWidth=this.getSmallestDifference(n,this.colX)||1,void 0!==t.defaultYBarWidth?this.yBarWidth=t.defaultYBarWidth:this.yBarWidth=this.getSmallestDifference(n,this.colY)||1),this._initializeRange(n,this.colX,t,a),this._initializeRange(n,this.colY,t,a),this._initializeRange(n,this.colZ,t,!1),Object.prototype.hasOwnProperty.call(n[0],"style")){this.colValue="style";const e=this.getColumnRange(n,this.colValue);this._setRangeDefaults(e,t.defaultValueMin,t.defaultValueMax),this.valueRange=e}else this.colValue="z",this.valueRange=this.zRange;const r=this.getDataTable();let h;return Object.prototype.hasOwnProperty.call(r[0],"filter")&&void 0===this.dataFilter&&(this.dataFilter=new P(this,"filter",t),this.dataFilter.setOnLoadCallback(function(){t.redraw()})),h=this.dataFilter?this.dataFilter._getDataPoints():this._getDataPoints(this.getDataTable()),h},A.prototype._collectRangeSettings=function(t,e){if(-1==["x","y","z"].indexOf(t))throw new Error("Column '"+t+"' invalid");const i=t.toUpperCase();return{barWidth:this[t+"BarWidth"],min:e["default"+i+"Min"],max:e["default"+i+"Max"],step:e["default"+i+"Step"],range_label:t+"Range",step_label:t+"Step"}},A.prototype._initializeRange=function(t,e,i,o){const n=this._collectRangeSettings(e,i),s=this.getColumnRange(t,e);o&&"z"!=e&&s.expand(n.barWidth/2),this._setRangeDefaults(s,n.min,n.max),this[n.range_label]=s,this[n.step_label]=void 0!==n.step?n.step:s.range()/5},A.prototype.getDistinctValues=function(t,e){void 0===e&&(e=this.dataTable);const i=[];for(let o=0;o<e.length;o++){const n=e[o][t]||0;-1===i.indexOf(n)&&i.push(n)}return i.sort(function(t,e){return t-e})},A.prototype.getSmallestDifference=function(t,e){const i=this.getDistinctValues(t,e);let o=null;for(let t=1;t<i.length;t++){const e=i[t]-i[t-1];(null==o||o>e)&&(o=e)}return o},A.prototype.getColumnRange=function(t,e){const i=new E;for(let o=0;o<t.length;o++){const n=t[o][e];i.adjust(n)}return i},A.prototype.getNumberOfRows=function(){return this.dataTable.length},A.prototype._setRangeDefaults=function(t,e,i){void 0!==e&&(t.min=e),void 0!==i&&(t.max=i),t.max<=t.min&&(t.max=t.min+1)},A.prototype.getDataTable=function(){return this.dataTable},A.prototype.getDataSet=function(){return this.dataSet},A.prototype.getDataPoints=function(t){const e=[];for(let i=0;i<t.length;i++){const o=new a;o.x=t[i][this.colX]||0,o.y=t[i][this.colY]||0,o.z=t[i][this.colZ]||0,o.data=t[i],o.value=t[i][this.colValue]||0;const n={};n.point=o,n.bottom=new a(o.x,o.y,this.zRange.min),n.trans=void 0,n.screen=void 0,e.push(n)}return e},A.prototype.initDataAsMatrix=function(t){let e,i,o,n;const s=this.getDistinctValues(this.colX,t),a=this.getDistinctValues(this.colY,t),r=this.getDataPoints(t),h=[];for(o=0;o<r.length;o++){n=r[o];const t=s.indexOf(n.point.x),e=a.indexOf(n.point.y);void 0===h[t]&&(h[t]=[]),h[t][e]=n}for(e=0;e<h.length;e++)for(i=0;i<h[e].length;i++)h[e][i]&&(h[e][i].pointRight=e<h.length-1?h[e+1][i]:void 0,h[e][i].pointTop=i<h[e].length-1?h[e][i+1]:void 0,h[e][i].pointCross=e<h.length-1&&i<h[e].length-1?h[e+1][i+1]:void 0);return r},A.prototype.getInfo=function(){const t=this.dataFilter;if(t)return t.getLabel()+": "+t.getSelectedValue()},A.prototype.reload=function(){this.dataTable&&this.setData(this.dataTable)},A.prototype._getDataPoints=function(t){let e=[];if(this.style===d.GRID||this.style===d.SURFACE)e=this.initDataAsMatrix(t);else if(e=this.getDataPoints(t),this.style===d.LINE)for(let t=0;t<e.length;t++)t>0&&(e[t-1].pointNext=e[t]);return e},B.STYLE=d;const k=void 0;function B(t,e,i){if(!(this instanceof B))throw new SyntaxError("Constructor must be called with the new operator");this.containerElement=t,this.dataGroup=new A,this.dataPoints=null,this.create(),function(t,e){if(void 0===t||y(t))throw new Error("No DEFAULTS passed");if(void 0===e)throw new Error("No dst passed");m=t,x(t,e,p),x(t,e,f,"default"),w(t,e),e.margin=10,e.showTooltip=!1,e.onclick_callback=null,e.eye=new a(0,0,-1)}(B.DEFAULTS,this),this.colX=void 0,this.colY=void 0,this.colZ=void 0,this.colValue=void 0,this.setOptions(i),this.setData(e)}function O(t){return"clientX"in t?t.clientX:t.targetTouches[0]&&t.targetTouches[0].clientX||0}function I(t){return"clientY"in t?t.clientY:t.targetTouches[0]&&t.targetTouches[0].clientY||0}B.DEFAULTS={width:"400px",height:"400px",filterLabel:"time",legendLabel:"value",xLabel:"x",yLabel:"y",zLabel:"z",xValueLabel:function(t){return t},yValueLabel:function(t){return t},zValueLabel:function(t){return t},showXAxis:!0,showYAxis:!0,showZAxis:!0,showGrayBottom:!1,showGrid:!0,showPerspective:!0,showShadow:!1,showSurfaceGrid:!0,keepAspectRatio:!0,rotateAxisLabels:!0,verticalRatio:.5,dotSizeRatio:.02,dotSizeMinFraction:.5,dotSizeMaxFraction:2.5,showAnimationControls:k,animationInterval:1e3,animationPreload:!1,animationAutoStart:k,axisFontSize:14,axisFontType:"arial",axisColor:"#4D4D4D",gridColor:"#D3D3D3",xCenter:"55%",yCenter:"50%",style:B.STYLE.DOT,tooltip:!1,tooltipDelay:300,tooltipStyle:{content:{padding:"10px",border:"1px solid #4d4d4d",color:"#1a1a1a",background:"rgba(255,255,255,0.7)",borderRadius:"2px",boxShadow:"5px 5px 10px rgba(128,128,128,0.5)"},line:{height:"40px",width:"0",borderLeft:"1px solid #4d4d4d",pointerEvents:"none"},dot:{height:"0",width:"0",border:"5px solid #4d4d4d",borderRadius:"5px",pointerEvents:"none"}},dataColor:{fill:"#7DC1FF",stroke:"#3267D2",strokeWidth:1},surfaceColors:k,colormap:k,cameraPosition:{horizontal:1,vertical:.5,distance:1.7},zoomable:!0,ctrlToZoom:!1,showLegend:k,backgroundColor:k,xBarWidth:k,yBarWidth:k,valueMin:k,valueMax:k,xMin:k,xMax:k,xStep:k,yMin:k,yMax:k,yStep:k,zMin:k,zMax:k,zStep:k},e(B.prototype),B.prototype._setScale=function(){this.scale=new a(1/this.xRange.range(),1/this.yRange.range(),1/this.zRange.range()),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,void 0!==this.valueRange&&(this.scale.value=1/this.valueRange.range());const t=this.xRange.center()*this.scale.x,e=this.yRange.center()*this.scale.y,i=this.zRange.center()*this.scale.z;this.camera.setArmLocation(t,e,i)},B.prototype._convert3Dto2D=function(t){const e=this._convertPointToTranslation(t);return this._convertTranslationToScreen(e)},B.prototype._convertPointToTranslation=function(t){const e=this.camera.getCameraLocation(),i=this.camera.getCameraRotation(),o=t.x*this.scale.x,n=t.y*this.scale.y,s=t.z*this.scale.z,r=e.x,h=e.y,l=e.z,c=Math.sin(i.x),d=Math.cos(i.x),u=Math.sin(i.y),p=Math.cos(i.y),f=Math.sin(i.z),m=Math.cos(i.z);return new a(p*(f*(n-h)+m*(o-r))-u*(s-l),c*(p*(s-l)+u*(f*(n-h)+m*(o-r)))+d*(m*(n-h)-f*(o-r)),d*(p*(s-l)+u*(f*(n-h)+m*(o-r)))-c*(m*(n-h)-f*(o-r)))},B.prototype._convertTranslationToScreen=function(t){const e=this.eye.x,i=this.eye.y,o=this.eye.z,n=t.x,s=t.y,a=t.z;let h,l;return this.showPerspective?(h=o/a*(n-e),l=o/a*(s-i)):(h=n*(-o/this.camera.getArmLength()),l=s*(-o/this.camera.getArmLength())),new r(this.currentXCenter+h*this.frame.canvas.clientWidth,this.currentYCenter-l*this.frame.canvas.clientWidth)},B.prototype._calcTranslations=function(t){for(let e=0;e<t.length;e++){const i=t[e];i.trans=this._convertPointToTranslation(i.point),i.screen=this._convertTranslationToScreen(i.trans);const o=this._convertPointToTranslation(i.bottom);i.dist=this.showPerspective?o.length():-o.z}t.sort(function(t,e){return e.dist-t.dist})},B.prototype._initializeRanges=function(){const t=this.dataGroup;this.xRange=t.xRange,this.yRange=t.yRange,this.zRange=t.zRange,this.valueRange=t.valueRange,this.xStep=t.xStep,this.yStep=t.yStep,this.zStep=t.zStep,this.xBarWidth=t.xBarWidth,this.yBarWidth=t.yBarWidth,this.colX=t.colX,this.colY=t.colY,this.colZ=t.colZ,this.colValue=t.colValue,this._setScale()},B.prototype.getDataPoints=function(t){const e=[];for(let i=0;i<t.length;i++){const o=new a;o.x=t[i][this.colX]||0,o.y=t[i][this.colY]||0,o.z=t[i][this.colZ]||0,o.data=t[i],o.value=t[i][this.colValue]||0;const n={};n.point=o,n.bottom=new a(o.x,o.y,this.zRange.min),n.trans=void 0,n.screen=void 0,e.push(n)}return e},B.prototype._getDataPoints=function(t){let e,i,o,n,s=[];if(this.style===B.STYLE.GRID||this.style===B.STYLE.SURFACE){const a=this.dataGroup.getDistinctValues(this.colX,t),r=this.dataGroup.getDistinctValues(this.colY,t);s=this.getDataPoints(t);const h=[];for(o=0;o<s.length;o++){n=s[o];const t=a.indexOf(n.point.x),e=r.indexOf(n.point.y);void 0===h[t]&&(h[t]=[]),h[t][e]=n}for(e=0;e<h.length;e++)for(i=0;i<h[e].length;i++)h[e][i]&&(h[e][i].pointRight=e<h.length-1?h[e+1][i]:void 0,h[e][i].pointTop=i<h[e].length-1?h[e][i+1]:void 0,h[e][i].pointCross=e<h.length-1&&i<h[e].length-1?h[e+1][i+1]:void 0)}else if(s=this.getDataPoints(t),this.style===B.STYLE.LINE)for(o=0;o<s.length;o++)o>0&&(s[o-1].pointNext=s[o]);return s},B.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);{const t=document.createElement("DIV");t.style.color="red",t.style.fontWeight="bold",t.style.padding="10px",t.innerHTML="Error: your browser does not support HTML canvas",this.frame.canvas.appendChild(t)}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);const t=this;this.frame.canvas.addEventListener("mousedown",function(e){t._onMouseDown(e)}),this.frame.canvas.addEventListener("touchstart",function(e){t._onTouchStart(e)}),this.frame.canvas.addEventListener("mousewheel",function(e){t._onWheel(e)}),this.frame.canvas.addEventListener("mousemove",function(e){t._onTooltip(e)}),this.frame.canvas.addEventListener("click",function(e){t._onClick(e)}),this.containerElement.appendChild(this.frame)},B.prototype._setSize=function(t,e){this.frame.style.width=t,this.frame.style.height=e,this._resizeCanvas()},B.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"},B.prototype.animationStart=function(){if(this.animationAutoStart&&this.dataGroup.dataFilter){if(!this.frame.filter||!this.frame.filter.slider)throw new Error("No animation available");this.frame.filter.slider.play()}},B.prototype.animationStop=function(){this.frame.filter&&this.frame.filter.slider&&this.frame.filter.slider.stop()},B.prototype._resizeCenter=function(){"%"===this.xCenter.charAt(this.xCenter.length-1)?this.currentXCenter=parseFloat(this.xCenter)/100*this.frame.canvas.clientWidth:this.currentXCenter=parseFloat(this.xCenter),"%"===this.yCenter.charAt(this.yCenter.length-1)?this.currentYCenter=parseFloat(this.yCenter)/100*(this.frame.canvas.clientHeight-this.frame.filter.clientHeight):this.currentYCenter=parseFloat(this.yCenter)},B.prototype.getCameraPosition=function(){const t=this.camera.getArmRotation();return t.distance=this.camera.getArmLength(),t},B.prototype._readData=function(t){this.dataPoints=this.dataGroup.initializeData(this,t,this.style),this._initializeRanges(),this._redrawFilter()},B.prototype.setData=function(t){null!=t&&(this._readData(t),this.redraw(),this.animationStart())},B.prototype.setOptions=function(t){if(void 0===t)return;!0===i.Validator.validate(t,z)&&console.error("%cErrors have been found in the supplied options object.",i.VALIDATOR_PRINT_STYLE),this.animationStop(),function(t,e){if(void 0!==t){if(void 0===e)throw new Error("No dst passed");if(void 0===m||y(m))throw new Error("DEFAULTS not set for module Settings");v(t,e,p),v(t,e,f,"default"),w(t,e)}}(t,this),this.setPointDrawingMethod(),this._setSize(this.width,this.height),this.setAxisLabelMethod(),this.setData(this.dataGroup.getDataTable()),this.animationStart()},B.prototype.setPointDrawingMethod=function(){let t;switch(this.style){case B.STYLE.BAR:t=this._redrawBarGraphPoint;break;case B.STYLE.BARCOLOR:t=this._redrawBarColorGraphPoint;break;case B.STYLE.BARSIZE:t=this._redrawBarSizeGraphPoint;break;case B.STYLE.DOT:t=this._redrawDotGraphPoint;break;case B.STYLE.DOTLINE:t=this._redrawDotLineGraphPoint;break;case B.STYLE.DOTCOLOR:t=this._redrawDotColorGraphPoint;break;case B.STYLE.DOTSIZE:t=this._redrawDotSizeGraphPoint;break;case B.STYLE.SURFACE:t=this._redrawSurfaceGraphPoint;break;case B.STYLE.GRID:t=this._redrawGridGraphPoint;break;case B.STYLE.LINE:t=this._redrawLineGraphPoint;break;default:throw new Error("Can not determine point drawing method for graph style '"+this.style+"'")}this._pointDrawingMethod=t},B.prototype.setAxisLabelMethod=function(){this.rotateAxisLabels?(this._drawAxisLabelX=this.drawAxisLabelXRotate,this._drawAxisLabelY=this.drawAxisLabelYRotate,this._drawAxisLabelZ=this.drawAxisLabelZRotate):(this._drawAxisLabelX=this.drawAxisLabelX,this._drawAxisLabelY=this.drawAxisLabelY,this._drawAxisLabelZ=this.drawAxisLabelZ)},B.prototype.redraw=function(){if(void 0===this.dataPoints)throw new Error("Graph data not initialized");this._resizeCanvas(),this._resizeCenter(),this._redrawSlider(),this._redrawClear(),this._redrawAxis(),this._redrawDataGraph(),this._redrawInfo(),this._redrawLegend()},B.prototype._getContext=function(){const t=this.frame.canvas.getContext("2d");return t.lineJoin="round",t.lineCap="round",t},B.prototype._redrawClear=function(){const t=this.frame.canvas;t.getContext("2d").clearRect(0,0,t.width,t.height)},B.prototype._dotSize=function(){return this.frame.clientWidth*this.dotSizeRatio},B.prototype._getLegendWidth=function(){let t;if(this.style===B.STYLE.DOTSIZE){t=this._dotSize()*this.dotSizeMaxFraction}else t=this.style===B.STYLE.BARSIZE?this.xBarWidth:20;return t},B.prototype._redrawLegend=function(){if(!0!==this.showLegend)return;if(this.style===B.STYLE.LINE||this.style===B.STYLE.BARSIZE)return;const t=this.style===B.STYLE.BARSIZE||this.style===B.STYLE.DOTSIZE,e=this.style===B.STYLE.DOTSIZE||this.style===B.STYLE.DOTCOLOR||this.style===B.STYLE.SURFACE||this.style===B.STYLE.BARCOLOR,i=Math.max(.25*this.frame.clientHeight,100),o=this.margin,n=this._getLegendWidth(),s=this.frame.clientWidth-this.margin,a=s-n,h=o+i,c=this._getContext();if(c.lineWidth=1,c.font="14px arial",!1===t){const t=0,e=i;let r;for(r=t;r<e;r++){const i=1-(r-t)/(e-t),n=this._colormap(i,1);c.strokeStyle=n,c.beginPath(),c.moveTo(a,o+r),c.lineTo(s,o+r),c.stroke()}c.strokeStyle=this.axisColor,c.strokeRect(a,o,n,i)}else{let t;this.style===B.STYLE.DOTSIZE?t=n*(this.dotSizeMinFraction/this.dotSizeMaxFraction):(this.style,B.STYLE.BARSIZE),c.strokeStyle=this.axisColor,c.fillStyle=this.dataColor.fill,c.beginPath(),c.moveTo(a,o),c.lineTo(s,o),c.lineTo(a+t,h),c.lineTo(a,h),c.closePath(),c.fill(),c.stroke()}const d=e?this.valueRange.min:this.zRange.min,u=e?this.valueRange.max:this.zRange.max,p=new l(d,u,(u-d)/5,!0);for(p.start(!0);!p.end();){const t=h-(p.getCurrent()-d)/(u-d)*i,e=new r(a-5,t),o=new r(a,t);this._line(c,e,o),c.textAlign="right",c.textBaseline="middle",c.fillStyle=this.axisColor,c.fillText(p.getCurrent(),a-10,t),p.next()}c.textAlign="right",c.textBaseline="top";const f=this.legendLabel;c.fillText(f,s,h+this.margin)},B.prototype._redrawFilter=function(){const t=this.dataGroup.dataFilter,e=this.frame.filter;if(e.innerHTML="",!t)return void(e.slider=void 0);const i=new h(e,{visible:this.showAnimationControls});e.slider=i,e.style.padding="10px",i.setValues(t.values),i.setPlayInterval(this.animationInterval);const o=this;i.setOnChangeCallback(function(){const t=o.dataGroup.dataFilter,e=i.getIndex();t.selectValue(e),o.dataPoints=t._getDataPoints(),o.redraw()})},B.prototype._redrawSlider=function(){void 0!==this.frame.filter.slider&&this.frame.filter.slider.redraw()},B.prototype._redrawInfo=function(){const t=this.dataGroup.getInfo();if(void 0===t)return;const e=this._getContext();e.font="14px arial",e.lineStyle="gray",e.fillStyle="gray",e.textAlign="left",e.textBaseline="top";const i=this.margin,o=this.margin;e.fillText(t,i,o)},B.prototype._line=function(t,e,i,o){void 0!==o&&(t.strokeStyle=o),t.beginPath(),t.moveTo(e.x,e.y),t.lineTo(i.x,i.y),t.stroke()},B.prototype.drawAxisLabelX=function(t,e,i,o,n){void 0===n&&(n=0);const s=this._convert3Dto2D(e);Math.cos(2*o)>0?(t.textAlign="center",t.textBaseline="top",s.y+=n):Math.sin(2*o)<0?(t.textAlign="right",t.textBaseline="middle"):(t.textAlign="left",t.textBaseline="middle"),t.fillStyle=this.axisColor,t.fillText(i,s.x,s.y)},B.prototype.drawAxisLabelY=function(t,e,i,o,n){void 0===n&&(n=0);const s=this._convert3Dto2D(e);Math.cos(2*o)<0?(t.textAlign="center",t.textBaseline="top",s.y+=n):Math.sin(2*o)>0?(t.textAlign="right",t.textBaseline="middle"):(t.textAlign="left",t.textBaseline="middle"),t.fillStyle=this.axisColor,t.fillText(i,s.x,s.y)},B.prototype.drawAxisLabelZ=function(t,e,i,o){void 0===o&&(o=0);const n=this._convert3Dto2D(e);t.textAlign="right",t.textBaseline="middle",t.fillStyle=this.axisColor,t.fillText(i,n.x-o,n.y)},B.prototype.drawAxisLabelXRotate=function(t,e,i,o,n){const s=this._convert3Dto2D(e);Math.cos(2*o)>0?(t.save(),t.translate(s.x,s.y),t.rotate(-Math.PI/2),t.textAlign="right",t.textBaseline="middle",t.fillStyle=this.axisColor,t.fillText(i,0,0),t.restore()):Math.sin(2*o)<0?(t.textAlign="right",t.textBaseline="middle",t.fillStyle=this.axisColor,t.fillText(i,s.x,s.y)):(t.textAlign="left",t.textBaseline="middle",t.fillStyle=this.axisColor,t.fillText(i,s.x,s.y))},B.prototype.drawAxisLabelYRotate=function(t,e,i,o,n){const s=this._convert3Dto2D(e);Math.cos(2*o)<0?(t.save(),t.translate(s.x,s.y),t.rotate(-Math.PI/2),t.textAlign="right",t.textBaseline="middle",t.fillStyle=this.axisColor,t.fillText(i,0,0),t.restore()):Math.sin(2*o)>0?(t.textAlign="right",t.textBaseline="middle",t.fillStyle=this.axisColor,t.fillText(i,s.x,s.y)):(t.textAlign="left",t.textBaseline="middle",t.fillStyle=this.axisColor,t.fillText(i,s.x,s.y))},B.prototype.drawAxisLabelZRotate=function(t,e,i,o){void 0===o&&(o=0);const n=this._convert3Dto2D(e);t.textAlign="right",t.textBaseline="middle",t.fillStyle=this.axisColor,t.fillText(i,n.x-o,n.y)},B.prototype._line3d=function(t,e,i,o){const n=this._convert3Dto2D(e),s=this._convert3Dto2D(i);this._line(t,n,s,o)},B.prototype._redrawAxis=function(){const t=this._getContext();let e,i,o,n,s,h,c,d,u,p,f;t.font=this.axisFontSize/this.camera.getArmLength()+"px "+this.axisFontType;const m=.025/this.scale.x,y=.025/this.scale.y,g=5/this.camera.getArmLength(),x=this.camera.getArmRotation().horizontal,v=new r(Math.cos(x),Math.sin(x)),w=this.xRange,b=this.yRange,_=this.zRange;let C;for(t.lineWidth=1,n=void 0===this.defaultXStep,o=new l(w.min,w.max,this.xStep,n),o.start(!0);!o.end();){const n=o.getCurrent();if(this.showGrid?(e=new a(n,b.min,_.min),i=new a(n,b.max,_.min),this._line3d(t,e,i,this.gridColor)):this.showXAxis&&(e=new a(n,b.min,_.min),i=new a(n,b.min+m,_.min),this._line3d(t,e,i,this.axisColor),e=new a(n,b.max,_.min),i=new a(n,b.max-m,_.min),this._line3d(t,e,i,this.axisColor)),this.showXAxis){c=v.x>0?b.min:b.max,C=new a(n,c,_.min);const e=" "+this.xValueLabel(n)+" ";this._drawAxisLabelX.call(this,t,C,e,x,g)}o.next()}for(t.lineWidth=1,n=void 0===this.defaultYStep,o=new l(b.min,b.max,this.yStep,n),o.start(!0);!o.end();){const n=o.getCurrent();if(this.showGrid?(e=new a(w.min,n,_.min),i=new a(w.max,n,_.min),this._line3d(t,e,i,this.gridColor)):this.showYAxis&&(e=new a(w.min,n,_.min),i=new a(w.min+y,n,_.min),this._line3d(t,e,i,this.axisColor),e=new a(w.max,n,_.min),i=new a(w.max-y,n,_.min),this._line3d(t,e,i,this.axisColor)),this.showYAxis){h=v.y>0?w.min:w.max,C=new a(h,n,_.min);const e=" "+this.yValueLabel(n)+" ";this._drawAxisLabelY.call(this,t,C,e,x,g)}o.next()}if(this.showZAxis){for(t.lineWidth=1,n=void 0===this.defaultZStep,o=new l(_.min,_.max,this.zStep,n),o.start(!0),h=v.x>0?w.min:w.max,c=v.y<0?b.min:b.max;!o.end();){const e=o.getCurrent(),n=new a(h,c,e),s=this._convert3Dto2D(n);i=new r(s.x-g,s.y),this._line(t,s,i,this.axisColor);const l=this.zValueLabel(e)+" ";this._drawAxisLabelZ.call(this,t,n,l,5),o.next()}t.lineWidth=1,e=new a(h,c,_.min),i=new a(h,c,_.max),this._line3d(t,e,i,this.axisColor)}if(this.showXAxis){let e,i;t.lineWidth=1,e=new a(w.min,b.min,_.min),i=new a(w.max,b.min,_.min),this._line3d(t,e,i,this.axisColor),e=new a(w.min,b.max,_.min),i=new a(w.max,b.max,_.min),this._line3d(t,e,i,this.axisColor)}this.showYAxis&&(t.lineWidth=1,e=new a(w.min,b.min,_.min),i=new a(w.min,b.max,_.min),this._line3d(t,e,i,this.axisColor),e=new a(w.max,b.min,_.min),i=new a(w.max,b.max,_.min),this._line3d(t,e,i,this.axisColor));const L=this.xLabel;L.length>0&&this.showXAxis&&(f=.1/this.scale.y,h=(w.max+3*w.min)/4,c=v.x>0?b.min-f:b.max+f,s=new a(h,c,_.min),this.drawAxisLabelX(t,s,L,x));const S=this.yLabel;S.length>0&&this.showYAxis&&(p=.1/this.scale.x,h=v.y>0?w.min-p:w.max+p,c=(b.max+3*b.min)/4,s=new a(h,c,_.min),this.drawAxisLabelY(t,s,S,x));const T=this.zLabel;T.length>0&&this.showZAxis&&(u=30,h=v.x>0?w.min:w.max,c=v.y<0?b.min:b.max,d=(_.max+3*_.min)/4,s=new a(h,c,d),this.drawAxisLabelZ(t,s,T,30))},B.prototype._getStrokeWidth=function(t){return void 0!==t?this.showPerspective?1/-t.trans.z*this.dataColor.strokeWidth:-this.eye.z/this.camera.getArmLength()*this.dataColor.strokeWidth:this.dataColor.strokeWidth},B.prototype._redrawBar=function(t,e,i,o,n,s){let r;const h=this,l=e.point,c=this.zRange.min,d=[{point:new a(l.x-i,l.y-o,l.z)},{point:new a(l.x+i,l.y-o,l.z)},{point:new a(l.x+i,l.y+o,l.z)},{point:new a(l.x-i,l.y+o,l.z)}],u=[{point:new a(l.x-i,l.y-o,c)},{point:new a(l.x+i,l.y-o,c)},{point:new a(l.x+i,l.y+o,c)},{point:new a(l.x-i,l.y+o,c)}];d.forEach(function(t){t.screen=h._convert3Dto2D(t.point)}),u.forEach(function(t){t.screen=h._convert3Dto2D(t.point)});const p=[{corners:d,center:a.avg(u[0].point,u[2].point)},{corners:[d[0],d[1],u[1],u[0]],center:a.avg(u[1].point,u[0].point)},{corners:[d[1],d[2],u[2],u[1]],center:a.avg(u[2].point,u[1].point)},{corners:[d[2],d[3],u[3],u[2]],center:a.avg(u[3].point,u[2].point)},{corners:[d[3],d[0],u[0],u[3]],center:a.avg(u[0].point,u[3].point)}];e.surfaces=p;for(let t=0;t<p.length;t++){r=p[t];const e=this._convertPointToTranslation(r.center);r.dist=this.showPerspective?e.length():-e.z}p.sort(function(t,e){const i=e.dist-t.dist;return i||(t.corners===d?1:e.corners===d?-1:0)}),t.lineWidth=this._getStrokeWidth(e),t.strokeStyle=s,t.fillStyle=n;for(let e=2;e<p.length;e++)r=p[e],this._polygon(t,r.corners)},B.prototype._polygon=function(t,e,i,o){if(!(e.length<2)){void 0!==i&&(t.fillStyle=i),void 0!==o&&(t.strokeStyle=o),t.beginPath(),t.moveTo(e[0].screen.x,e[0].screen.y);for(let i=1;i<e.length;++i){const o=e[i];t.lineTo(o.screen.x,o.screen.y)}t.closePath(),t.fill(),t.stroke()}},B.prototype._drawCircle=function(t,e,i,o,n){const s=this._calcRadius(e,n);t.lineWidth=this._getStrokeWidth(e),t.strokeStyle=o,t.fillStyle=i,t.beginPath(),t.arc(e.screen.x,e.screen.y,s,0,2*Math.PI,!0),t.fill(),t.stroke()},B.prototype._getColorsRegular=function(t){const e=(t.point.value-this.valueRange.min)*this.scale.value;return{fill:this._colormap(e,1),border:this._colormap(e,.8)}},B.prototype._getColorsColor=function(t){let e,i,o;if(t&&t.point&&t.point.data&&t.point.data.style&&(o=t.point.data.style),o&&"object"==typeof o&&o.fill&&o.stroke)return{fill:o.fill,border:o.stroke};if("string"==typeof t.point.value)e=t.point.value,i=t.point.value;else{const o=(t.point.value-this.valueRange.min)*this.scale.value;e=this._colormap(o,1),i=this._colormap(o,.8)}return{fill:e,border:i}},B.prototype._getColorsSize=function(){return{fill:this.dataColor.fill,border:this.dataColor.stroke}},B.prototype._colormap=function(t,e=1){let i,o,n,a;const r=this.colormap;if(Array.isArray(r)){const e=r.length-1,s=Math.max(Math.floor(t*e),0),a=Math.min(s+1,e),h=t*e-s,l=r[s],c=r[a];i=l.r+h*(c.r-l.r),o=l.g+h*(c.g-l.g),n=l.b+h*(c.b-l.b)}else if("function"==typeof r)({r:i,g:o,b:n,a:a}=r(t));else{const e=240*(1-t);({r:i,g:o,b:n}=s.HSVToRGB(e/360,1,1))}return"number"!=typeof a||Number.isNaN(a)?`RGB(${Math.round(i*e)}, ${Math.round(o*e)}, ${Math.round(n*e)})`:`RGBA(${Math.round(i*e)}, ${Math.round(o*e)}, ${Math.round(n*e)}, ${a})`},B.prototype._calcRadius=function(t,e){let i;return void 0===e&&(e=this._dotSize()),i=this.showPerspective?e/-t.trans.z:e*(-this.eye.z/this.camera.getArmLength()),i<0&&(i=0),i},B.prototype._redrawBarGraphPoint=function(t,e){const i=this.xBarWidth/2,o=this.yBarWidth/2,n=this._getColorsRegular(e);this._redrawBar(t,e,i,o,n.fill,n.border)},B.prototype._redrawBarColorGraphPoint=function(t,e){const i=this.xBarWidth/2,o=this.yBarWidth/2,n=this._getColorsColor(e);this._redrawBar(t,e,i,o,n.fill,n.border)},B.prototype._redrawBarSizeGraphPoint=function(t,e){const i=(e.point.value-this.valueRange.min)/this.valueRange.range(),o=this.xBarWidth/2*(.8*i+.2),n=this.yBarWidth/2*(.8*i+.2),s=this._getColorsSize();this._redrawBar(t,e,o,n,s.fill,s.border)},B.prototype._redrawDotGraphPoint=function(t,e){const i=this._getColorsRegular(e);this._drawCircle(t,e,i.fill,i.border)},B.prototype._redrawDotLineGraphPoint=function(t,e){const i=this._convert3Dto2D(e.bottom);t.lineWidth=1,this._line(t,i,e.screen,this.gridColor),this._redrawDotGraphPoint(t,e)},B.prototype._redrawDotColorGraphPoint=function(t,e){const i=this._getColorsColor(e);this._drawCircle(t,e,i.fill,i.border)},B.prototype._redrawDotSizeGraphPoint=function(t,e){const i=this._dotSize(),o=(e.point.value-this.valueRange.min)/this.valueRange.range(),n=i*this.dotSizeMinFraction,s=n+(i*this.dotSizeMaxFraction-n)*o,a=this._getColorsSize();this._drawCircle(t,e,a.fill,a.border,s)},B.prototype._redrawSurfaceGraphPoint=function(t,e){const i=e.pointRight,o=e.pointTop,n=e.pointCross;if(void 0===e||void 0===i||void 0===o||void 0===n)return;let s,r,h,l=!0;if(this.showGrayBottom||this.showShadow){const t=a.subtract(n.trans,e.trans),s=a.subtract(o.trans,i.trans),r=a.crossProduct(t,s);if(this.showPerspective){const t=a.avg(a.avg(e.trans,n.trans),a.avg(i.trans,o.trans));h=-a.dotProduct(r.normalize(),t.normalize())}else h=r.z/r.length();l=h>0}if(l||!this.showGrayBottom){const t=((e.point.value+i.point.value+o.point.value+n.point.value)/4-this.valueRange.min)*this.scale.value,a=this.showShadow?(1+h)/2:1;s=this._colormap(t,a)}else s="gray";r=this.showSurfaceGrid?this.axisColor:s,t.lineWidth=this._getStrokeWidth(e);const c=[e,i,n,o];this._polygon(t,c,s,r)},B.prototype._drawGridLine=function(t,e,i){if(void 0===e||void 0===i)return;const o=((e.point.value+i.point.value)/2-this.valueRange.min)*this.scale.value;t.lineWidth=2*this._getStrokeWidth(e),t.strokeStyle=this._colormap(o,1),this._line(t,e.screen,i.screen)},B.prototype._redrawGridGraphPoint=function(t,e){this._drawGridLine(t,e,e.pointRight),this._drawGridLine(t,e,e.pointTop)},B.prototype._redrawLineGraphPoint=function(t,e){void 0!==e.pointNext&&(t.lineWidth=this._getStrokeWidth(e),t.strokeStyle=this.dataColor.stroke,this._line(t,e.screen,e.pointNext.screen))},B.prototype._redrawDataGraph=function(){const t=this._getContext();let e;if(!(void 0===this.dataPoints||this.dataPoints.length<=0))for(this._calcTranslations(this.dataPoints),e=0;e<this.dataPoints.length;e++){const i=this.dataPoints[e];this._pointDrawingMethod.call(this,t,i)}},B.prototype._storeMousePosition=function(t){this.startMouseX=O(t),this.startMouseY=I(t),this._startCameraOffset=this.camera.getOffset()},B.prototype._onMouseDown=function(t){if(t=t||window.event,this.leftButtonDown&&this._onMouseUp(t),this.leftButtonDown=t.which?1===t.which:1===t.button,!this.leftButtonDown&&!this.touchDown)return;this._storeMousePosition(t),this.startStart=new Date(this.start),this.startEnd=new Date(this.end),this.startArmRotation=this.camera.getArmRotation(),this.frame.style.cursor="move";const e=this;this.onmousemove=function(t){e._onMouseMove(t)},this.onmouseup=function(t){e._onMouseUp(t)},document.addEventListener("mousemove",e.onmousemove),document.addEventListener("mouseup",e.onmouseup),s.preventDefault(t)},B.prototype._onMouseMove=function(t){this.moving=!0,t=t||window.event;const e=parseFloat(O(t))-this.sta