How to use min64 method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

jqxgauge.js

Source:jqxgauge.js Github

copy

Full Screen

1/*2jQWidgets v4.2.1 (2016-Aug)3Copyright (c) 2011-2016 jQWidgets.4License: http://jqwidgets.com/license/5*/6(function ($)7{8 /*9 * RadialGauge's functionality10 */11 var radialGauge = {12 defineInstance: function ()13 {14 var settings = {15 width: 350,16 height: 350,17 radius: '50%',18 endAngle: 270,19 startAngle: 30,20 int64: false,21 editableLabels: false,22 value: 0,23 min: 0,24 max: 220,25 disabled: false,26 ticksDistance: '20%',27 colorScheme: 'scheme01',28 animationDuration: 400,29 showRanges: true,30 easing: 'easeOutCubic',31 labels: null,32 pointer: null,33 cap: null,34 caption: null,35 border: null,36 ticksMinor: null,37 ticksMajor: null,38 tickMode: 'default', // possible values: 'default', 'tickNumber'39 niceInterval: false,40 style: null,41 ranges: [],42 _radius: 100,43 _border: null,44 _radiusDifference: 2,45 _pointer: null,46 _labels: [],47 _cap: null,48 _ticks: [],49 _ranges: [],50 _gauge: null,51 _caption: null,52 _animationTimeout: 10,53 renderer: null,54 _animations: [],55 aria:56 {57 "aria-valuenow": { name: "value", type: "number" },58 "aria-valuemin": { name: "min", type: "number" },59 "aria-valuemax": { name: "max", type: "number" },60 "aria-disabled": { name: "disabled", type: "boolean" }61 }62 };63 $.extend(true, this, settings);64 return settings;65 },66 createInstance: function (args)67 {68 var self = this;69 self.that = this;70 $.jqx.aria(self);71 self._radius = self.radius;72 self.endAngle = self.endAngle * Math.PI / 180 + Math.PI / 2;73 self.startAngle = self.startAngle * Math.PI / 180 + Math.PI / 2;74 if (self.int64 === 's')75 {76 if (!$.jqx.longInt)77 {78 throw new Error('jqxGauge: Missing reference to jqxmath.js');79 }80 // enables 64-bit number support81 $.jqx.longInt(self);82 self._value64 = new $.jqx.math().fromString(self.value.toString(), 10);83 self._min64 = new $.jqx.math().fromString(self.min.toString(), 10);84 self._max64 = new $.jqx.math().fromString(self.max.toString(), 10);85 } else if (self.int64 === 'u')86 {87 try88 {89 BigNumber;90 }91 catch (err)92 {93 throw new Error('jqxGauge: Missing reference to jqxmath.js');94 }95 self._value64 = new BigNumber(self.value);96 self._min64 = new BigNumber(self.min);97 self._max64 = new BigNumber(self.max);98 } else99 {100 self.value = new Number(self.value);101 }102 self._refresh();103 self.renderer.getContainer().css('overflow', 'hidden');104 if (self.int64 !== false)105 {106 self.setValue(self._value64, 0);107 } else108 {109 self.setValue(self.value, 0);110 }111 $.jqx.utilities.resize(self.host, function ()112 {113 self._refresh(true);114 });115 self.host.addClass(self.toThemeProperty('jqx-widget'));116 },117 _validateEasing: function ()118 {119 return !!$.easing[this.easing];120 },121 _validateProperties: function ()122 {123 if (this.startAngle === this.endAngle)124 {125 throw new Error('The end angle can not be equal to the start angle!');126 }127 if (!this._validateEasing())128 {129 this.easing = 'linear';130 }131 this.ticksDistance = this._validatePercentage(this.ticksDistance, '20%');132 this.border = this._borderConstructor(this.border, this);133 this.style = this.style || { fill: '#ffffff', stroke: '#E0E0E0' };134 this.ticksMinor = new this._tickConstructor(this.ticksMinor, this);135 this.ticksMajor = new this._tickConstructor(this.ticksMajor, this);136 this.cap = new this._capConstructor(this.cap, this);137 this.pointer = new this._pointerConstructor(this.pointer, this);138 this.labels = new this._labelsConstructor(this.labels, this);139 this.caption = new this._captionConstructor(this.caption, this);140 for (var i = 0; i < this.ranges.length; i += 1)141 {142 this.ranges[i] = new this._rangeConstructor(this.ranges[i], this);143 }144 },145 _hostInit: function (sizeChange)146 {147 var width = this._getScale(this.width, 'width', this.host.parent()),148 height = this._getScale(this.height, 'height', this.host.parent()),149 border = this._outerBorderOffset(),150 host = this.host,151 childSize;152 host.width(width);153 host.height(height);154 this.radius = childSize = 0;155 var s1 = (this._getScale(this._radius, 'width', this.host) || width / 2) - border;156 var s2 = (this._getScale(this._radius, 'height', this.host) || height / 2) - border;157 this.radius = childSize = Math.min(s1, s2);158 this._originalRadius = parseInt(this.radius, 10) - this._radiusDifference;159 this._innerRadius = this._originalRadius;160 if (this.border)161 {162 this._innerRadius -= this._getSize(this.border.size);163 }164 if (!sizeChange)165 {166 host[0].innerHTML = '<div />';167 }168 this._gaugeParent = host.children();169 this._gaugeParent.width(width);170 this._gaugeParent.height(height);171 if (!sizeChange)172 {173 this.renderer.init(this._gaugeParent);174 }175 else176 {177 var chartContainer = this.renderer.getContainer();178 chartContainer[0].style.width = width + 'px';179 chartContainer[0].style.height = height + 'px';180 }181 },182 _initRenderer: function (host)183 {184 if (!$.jqx.createRenderer)185 throw 'Please include a reference to jqxdraw.js';186 return $.jqx.createRenderer(this, host);187 },188 _refresh: function (sizeChange)189 {190 // sizeChange = false;191 var self = this;192 if (sizeChange)193 {194 self._ticksIterator = 0;195 self._labelsIterator = 0;196 if (self._ranges)197 $(self._ranges).remove();198 if (self._pointer)199 $(self._pointer).remove();200 self._pointer = null;201 self._ranges = [];202 if (self.niceInterval)203 {204 if (self._labels)205 $(self._labels).remove();206 self._labels = [];207 if (self._ticks)208 {209 $(self._ticks).remove();210 self._ticks = [];211 }212 }213 self._hostInit(sizeChange);214 self._render(sizeChange);215 return;216 }217 if (!self.renderer)218 {219 self._isVML = false;220 self.host.empty();221 self._initRenderer(self.host);222 }223 var renderer = self.renderer;224 if (!renderer)225 return;226 if (self._ranges)227 $(self._ranges).remove();228 if (self._pointer)229 $(self._pointer).remove();230 if (self._labels)231 $(self._labels).remove();232 if (self._cap)233 $(self._cap).remove();234 if (self._ticks)235 $(self._ticks).remove();236 if (self._border)237 $(self._border).remove();238 if (self._caption)239 $(self._caption).remove();240 self._caption = null;241 self._labels = [];242 self._cap = null;243 self._ticks = [];244 self._ranges = [];245 self._border = null;246 self._pointer = null;247 self._validateProperties();248 self._removeElements();249 self._hostInit();250 self._render();251 self.setValue(this.value, 0);252 self._editableLabels();253 },254 val: function (value)255 {256 if (arguments.length == 0 || typeof (value) == "object")257 {258 return this.value;259 }260 this.setValue(value, 0);261 },262 refresh: function (initialRefresh)263 {264 if (initialRefresh === true)265 return;266 this._refresh.apply(this, Array.prototype.slice(arguments));267 },268 _outerBorderOffset: function ()269 {270 var borderStroke = parseInt(this.border.style['stroke-width'], 10) || 1;271 return borderStroke / 2;272 },273 _removeCollection: function (collection)274 {275 for (var i = 0; i < collection.length; i += 1)276 {277 $(collection[i]).remove();278 }279 collection = [];280 },281 _render: function (sizeChange)282 {283 this._addBorder(sizeChange);284 this._addGauge(sizeChange);285 this._addRanges(sizeChange);286 if (!this.niceInterval)287 {288 this._addTicks(sizeChange);289 this._addLabels(sizeChange);290 }291 else292 {293 this._addTicks();294 }295 this._styleLabels();296 this._addCaption(sizeChange);297 this._addPointer(sizeChange);298 this._addCap(sizeChange);299 },300 _addBorder: function (sizeChange)301 {302 if (!this.border.visible)303 {304 return;305 }306 if (sizeChange)307 {308 var borderSize = this._outerBorderOffset();309 this._border.setAttribute('cx', this._originalRadius + borderSize);310 this._border.setAttribute('cy', this._originalRadius + borderSize);311 this._border.setAttribute('r', this._originalRadius);312 return;313 }314 var color = this.border.style.fill,315 borderSize = this._outerBorderOffset();316 if (!color)317 {318 color = '#BABABA';319 }320 if (this.border.showGradient)321 {322 if (color.indexOf('url') < 0 && color.indexOf('#grd') < 0)323 {324 this._originalColor = color;325 } else326 {327 color = this._originalColor;328 }329 color = this.renderer._toLinearGradient(color, true, [[0, 1], [25, 1.1], [50, 1.5], [100, 1]]);330 }331 this._border = this.renderer.circle(this._originalRadius + borderSize, this._originalRadius + borderSize, this._originalRadius);332 this.border.style.fill = color;333 this.renderer.attr(this._border, this.border.style);334 },335 _addGauge: function (sizeChange)336 {337 var r = this._originalRadius,338 url = this.renderer._toLinearGradient('#ffffff', [[3, 2], [100, 1]], true),339 borderSize = this._outerBorderOffset();340 if (sizeChange)341 {342 this._gauge.setAttribute('cx', r + borderSize);343 this._gauge.setAttribute('cy', r + borderSize);344 this._gauge.setAttribute('r', this._innerRadius);345 }346 else347 {348 this._gauge = this.renderer.circle(r + borderSize, r + borderSize, this._innerRadius);349 this.renderer.attr(this._gauge, this.style);350 }351 },352 _addCap: function (sizeChange)353 {354 var visibility = 'visible',355 borderSize = this._outerBorderOffset();356 if (!this.cap.visible)357 {358 visibility = 'hidden';359 }360 var r = this._originalRadius,361 size = this._getSize(this.cap.size),362 circle;363 if (sizeChange)364 {365 this._cap.setAttribute("cx", r + borderSize);366 this._cap.setAttribute("cy", r + borderSize);367 this._cap.setAttribute("r", size);368 this._capCenter = [r, r];369 }370 else371 {372 circle = this.renderer.circle(r + borderSize, r + borderSize, size);373 this._capCenter = [r, r];374 this.renderer.attr(circle, this.cap.style);375 $(circle).css('visibility', visibility);376 this._cap = circle;377 }378 },379 _addTicks: function (sizeChange)380 {381 var self = this;382 var ticksMinor = this.ticksMinor,383 ticksMajor = this.ticksMajor,384 minorStep,385 majorStep,386 oldVals = {};387 if (ticksMajor.visible === false && ticksMinor.visible === false && this.labels.visible === false)388 {389 return;390 }391 function drawMajor(j)392 {393 if (ticksMajor.visible)394 {395 self._drawTick({396 angle: self._getAngleByValue(j),397 distance: self._getDistance(self.ticksDistance),398 style: ticksMajor.style,399 size: self._getSize(ticksMajor.size),400 type: 'major'401 }, sizeChange);402 }403 }404 function drawMinor(i)405 {406 if (ticksMinor.visible)407 {408 self._drawTick({409 angle: self._getAngleByValue(i),410 distance: self._getDistance(self.ticksDistance),411 style: ticksMinor.style,412 size: self._getSize(ticksMinor.size),413 type: 'minor'414 }, sizeChange);415 }416 }417 function addLabel(currentLabel)418 {419 if (self.labels.visible)420 {421 self._addLabel({422 angle: self._getAngleByValue(currentLabel),423 value: majorStep >= 1 ? currentLabel : new Number(currentLabel).toFixed(2),424 distance: self._getDistance(self._getLabelsDistance()),425 style: self.labels.className426 }, sizeChange);427 }428 }429 var numberOfIterations = 0;430 if (self.int64 === 's')431 {432 if (this.tickMode === 'default')433 {434 if (this.niceInterval)435 {436 majorStep = this._getNiceInterval('radial');437 minorStep = this._getNiceInterval('radial', true);438 } else439 {440 majorStep = new $.jqx.math().fromString((ticksMajor.interval).toString(), 10);441 minorStep = new $.jqx.math().fromString((ticksMinor.interval).toString(), 10);442 }443 } else444 {445 startToEnd = this._max64.subtract(this._min64);446 minorStep = startToEnd.div(new $.jqx.math().fromString((ticksMinor.number).toString(), 10));447 majorStep = startToEnd.div(new $.jqx.math().fromString((ticksMajor.number).toString(), 10));448 }449 if (this.niceInterval)450 {451 drawMajor(this._min64);452 addLabel(this._min64);453 var second = this._min64.subtract(this._min64.modulo(majorStep)).add(majorStep),454 firstMinTick;455 for (var a = second; a.greaterThanOrEqual(this._min64) ; a = a.subtract(minorStep))456 {457 firstMinTick = a;458 }459 for (var i = firstMinTick, j = second; i.lessThan(this._max64) || j.lessThan(this._max64) ; i = i.add(minorStep), j = j.add(majorStep))460 {461 numberOfIterations += 1;462 if (numberOfIterations > 250)463 {464 break;465 }466 if (j.lessThanOrEqual(this._max64))467 {468 drawMajor(j);469 oldVals[j.toString()] = true;470 if (i.equals(second))471 {472 // second tick473 if (Math.abs(this._getAngleByValue(j) - this._getAngleByValue(this.min)) * this._innerRadius > this._getMaxLabelSize()['height'])474 {475 addLabel(j);476 }477 } else if ((j.add(majorStep)).lessThan(this._max64))478 {479 addLabel(j);480 } else481 {482 // second-to-last tick483 if (Math.abs(this._getAngleByValue(j) - this._getAngleByValue(this.max)) * this._innerRadius > this._getMaxLabelSize()['height'])484 {485 addLabel(j);486 }487 }488 }489 if (!oldVals[i.toString()] && i.lessThanOrEqual(self._max64))490 {491 drawMinor(i);492 }493 if (self._checkForOverflow(i, minorStep) || self._checkForOverflow(j, majorStep))494 {495 break;496 }497 }498 drawMajor(this._max64);499 addLabel(this._max64);500 } else501 {502 for (var i = new $.jqx.math().fromString((self.min).toString(), 10), j = new $.jqx.math().fromString((self.min).toString(), 10) ; i.lessThanOrEqual(self._max64) || j.lessThanOrEqual(self._max64) ; i = i.add(minorStep), j = j.add(majorStep))503 {504 numberOfIterations += 1;505 if (numberOfIterations > 250)506 {507 break;508 }509 if (j.lessThanOrEqual(self._max64) && ticksMajor.visible)510 {511 drawMajor(j);512 oldVals[j.toString()] = true;513 }514 if (!oldVals[i.toString()] && ticksMinor.visible && i.lessThanOrEqual(self._max64))515 {516 drawMinor(i);517 }518 }519 }520 } else if (self.int64 === 'u')521 {522 if (this.tickMode === 'default')523 {524 if (this.niceInterval)525 {526 majorStep = this._getNiceInterval('radial');527 minorStep = this._getNiceInterval('radial', true);528 } else529 {530 majorStep = new BigNumber(ticksMajor.interval);531 minorStep = new BigNumber(ticksMinor.interval);532 }533 } else534 {535 startToEnd = this._max64.subtract(this._min64);536 minorStep = startToEnd.divide(new BigNumber(ticksMinor.number));537 majorStep = startToEnd.divide(new BigNumber(ticksMajor.number));538 }539 if (this.niceInterval)540 {541 drawMajor(this._min64);542 addLabel(this._min64);543 var second = this._min64.subtract(this._min64.mod(majorStep)).add(majorStep),544 firstMinTick;545 for (var a = second; a.compare(this._min64) !== -1; a = a.subtract(minorStep))546 {547 firstMinTick = a;548 }549 for (var i = firstMinTick, j = second; i.compare(this._max64) === -1 || j.compare(this._max64) === -1; i = i.add(minorStep), j = j.add(majorStep))550 {551 numberOfIterations += 1;552 if (numberOfIterations > 250)553 {554 break;555 }556 if (j.compare(this._max64) !== 1)557 {558 drawMajor(j);559 oldVals[j.toString()] = true;560 if (i.compare(second) === 0)561 {562 // second tick563 if (Math.abs(this._getAngleByValue(j) - this._getAngleByValue(this.min)) * this._innerRadius > this._getMaxLabelSize()['height'])564 {565 addLabel(j);566 }567 } else if ((j.add(majorStep)).compare(this._max64) === -1)568 {569 addLabel(j);570 } else571 {572 // second-to-last tick573 if (Math.abs(this._getAngleByValue(j) - this._getAngleByValue(this.max)) * this._innerRadius > this._getMaxLabelSize()['height'])574 {575 addLabel(j);576 }577 }578 }579 if (!oldVals[i.toString()] && (i.compare(self._max64) !== 1))580 {581 drawMinor(i);582 }583 }584 drawMajor(this._max64);585 addLabel(this._max64);586 } else587 {588 for (var i = new BigNumber(self.min), j = new BigNumber(self.min) ; (i.compare(self._max64) !== 1) || (j.compare(self._max64) !== 1) ; i = i.add(minorStep), j = j.add(majorStep))589 {590 numberOfIterations += 1;591 if (numberOfIterations > 250)592 {593 break;594 }595 if ((j.compare(self._max64) !== 1) && ticksMajor.visible)596 {597 drawMajor(j);598 oldVals[j.toString()] = true;599 }600 if (!oldVals[i.toString()] && ticksMinor.visible && (i.compare(self._max64) !== 1))601 {602 drawMinor(i);603 }604 }605 }606 } else607 {608 if (this.tickMode === 'default')609 {610 if (this.niceInterval)611 {612 majorStep = this._getNiceInterval('radial');613 minorStep = this._getNiceInterval('radial', true);614 } else615 {616 majorStep = ticksMajor.interval;617 minorStep = ticksMinor.interval;618 }619 } else620 {621 startToEnd = this.max - this.min;622 minorStep = startToEnd / ticksMinor.number;623 majorStep = startToEnd / ticksMajor.number624 }625 if (this.niceInterval)626 {627 drawMajor(this.min);628 addLabel(this.min);629 var second = this.min - (this.min % majorStep) + majorStep,630 firstMinTick;631 for (var a = second; a >= this.min; a = a - minorStep)632 {633 firstMinTick = a;634 }635 for (var i = firstMinTick, j = second; i < this.max || j < this.max; i += minorStep, j += majorStep)636 {637 numberOfIterations += 1;638 if (numberOfIterations > 250)639 {640 break;641 }642 if (j <= this.max)643 {644 drawMajor(j);645 oldVals[j.toFixed(5)] = true;646 if (i === second)647 {648 // second tick649 if (Math.abs(this._getAngleByValue(j) - this._getAngleByValue(this.min)) * this._innerRadius > this._getMaxLabelSize()['height'])650 {651 addLabel(j);652 }653 } else if (j + majorStep < this.max)654 {655 addLabel(j);656 } else657 {658 // second-to-last tick659 if (Math.abs(this._getAngleByValue(j) - this._getAngleByValue(this.max)) * this._innerRadius > this._getMaxLabelSize()['height'])660 {661 addLabel(j);662 }663 }664 }665 if (!oldVals[i.toFixed(5)] && i <= this.max)666 {667 drawMinor(i);668 }669 }670 drawMajor(this.max);671 addLabel(this.max);672 } else673 {674 for (var i = this.min, j = this.min; i <= this.max || j <= this.max; i += minorStep, j += majorStep)675 {676 numberOfIterations += 1;677 if (numberOfIterations > 250)678 {679 break;680 }681 if (j <= this.max && ticksMajor.visible)682 {683 drawMajor(j);684 oldVals[j.toFixed(5)] = true;685 }686 if (!oldVals[i.toFixed(5)] && ticksMinor.visible && i <= this.max)687 {688 drawMinor(i);689 }690 }691 }692 }693 this._handleTicksVisibility();694 },695 _handleTicksVisibility: function ()696 {697 if (!this.ticksMinor.visible)698 {699 this.host.children('.jqx-gauge-tick-minor').css('visibility', 'hidden');700 } else701 {702 this.host.children('.jqx-gauge-tick-minor').css('visibility', 'visible');703 }704 if (!this.ticksMajor.visible)705 {706 this.host.children('.jqx-gauge-tick-major').css('visibility', 'hidden');707 } else708 {709 this.host.children('.jqx-gauge-tick-major').css('visibility', 'visible');710 }711 },712 /*713 * Calculates the size relatively to the inner gauge.714 * _innerRadius is equal to the inner part of the gauge (without border).715 * _originalRadius is the gauge + it's border.716 */717 _getSize: function (size)718 {719 if (size.toString().indexOf('%') >= 0)720 {721 size = (parseInt(size, 10) / 100) * this._innerRadius;722 }723 size = parseInt(size, 10);724 return size;725 },726 _getDistance: function (size)727 {728 return this._getSize(size) + (this._originalRadius - this._innerRadius);729 },730 _drawTick: function (options, sizeChange)731 {732 var that = this.that;733 var angle = options.angle,734 distance = options.distance,735 size = options.size,736 borderSize = that._outerBorderOffset(),737 r = that._originalRadius,738 width = r - distance,739 innerWidth = width - size,740 x1 = r + borderSize + width * Math.sin(angle),741 y1 = r + borderSize + width * Math.cos(angle),742 x2 = r + borderSize + innerWidth * Math.sin(angle),743 y2 = r + borderSize + innerWidth * Math.cos(angle),744 line;745 options.style['class'] = that.toThemeProperty('jqx-gauge-tick-' + options.type);746 if (that._isVML)747 {748 x1 = Math.round(x1);749 x2 = Math.round(x2);750 y1 = Math.round(y1);751 y2 = Math.round(y2);752 }753 if (sizeChange && !that.niceInterval)754 {755 var line = that._ticks[that._ticksIterator];756 line.setAttribute('x1', x1);757 line.setAttribute('x2', x2);758 line.setAttribute('y1', y1);759 line.setAttribute('y2', y2);760 that._ticksIterator++;761 }762 else763 {764 line = that.renderer.line(x1, y1, x2, y2, options.style);765 that._ticks.push(line);766 }767 },768 _addRanges: function (sizeChange)769 {770 var visibility = 'visible';771 if (!this.showRanges)772 {773 visibility = 'hidden';774 } else775 {776 var ranges = this.ranges;777 for (var i = 0; i < ranges.length; i += 1)778 {779 this._addRange(ranges[i], visibility, sizeChange);780 }781 }782 },783 _getMaxRangeSize: function ()784 {785 var range, size = -1, start, end;786 for (var i = 0; i < this.ranges.length; i += 1)787 {788 start = this.ranges[i].startWidth;789 end = this.ranges[i].endWidth;790 if (start > size)791 {792 size = start;793 }794 if (end > size)795 {796 size = end;797 }798 }799 return size;800 },801 _getRangeDistance: function (distance, width)802 {803 var labelsPosition = this._getLabelsDistance(),804 rangeDistance = this._getDistance(distance),805 maxRangeSize = this._getMaxRangeSize();806 if (this.labels.position === 'outside')807 {808 if (labelsPosition < rangeDistance + this._getMaxTickSize())809 {810 return this._getDistance(this.ticksDistance) + maxRangeSize / 2 + this._getSize(this.ticksMajor.size);811 }812 } else if (this.labels.position === 'inside')813 {814 if (labelsPosition + this._getMaxTickSize() < rangeDistance)815 {816 return this._getSize(this.border.size) + this._originalRadius / 20;817 }818 }819 return rangeDistance;820 },821 _addRange: function (range, visibility, sizeChange)822 {823 var that = this.that;824 if ((that.int64 === 's' && (range._startValue64.lessThan(that._min64) || range._endValue64.greaterThan(that._max64))) ||825 (that.int64 === 'u' && ((range._startValue64.compare(that._min64) === -1) || (range._endValue64.compare(that._max64) === 1))) ||826 (that.int64 === false && (range.startValue < that.min || range.endValue > that.max)))827 {828 return;829 }830 var startAngle = that.int64 ? that._getAngleByValue(range._startValue64) : that._getAngleByValue(range.startValue),831 endAngle = that.int64 ? that._getAngleByValue(range._endValue64) : that._getAngleByValue(range.endValue);832 var radius = that._originalRadius,833 startDistance = radius - that._getRangeDistance(range.startDistance, range.startWidth),834 endDistance = radius - that._getRangeDistance(range.endDistance, range.endWidth),835 startWidth = range.startWidth,836 endWidth = range.endWidth,837 borderSize = that._outerBorderOffset(),838 startPoint = {839 x: radius + borderSize + startDistance * Math.sin(startAngle),840 y: radius + borderSize + startDistance * Math.cos(startAngle)841 },842 endPoint = {843 x: radius + borderSize + endDistance * Math.sin(endAngle),844 y: radius + borderSize + endDistance * Math.cos(endAngle)845 },846 startProjectionPoint = that._getProjectionPoint(startAngle, radius + borderSize, startDistance, startWidth),847 endProjectionPoint = that._getProjectionPoint(endAngle, radius + borderSize, endDistance, endWidth),848 orientation = 'default',849 path, range;850 if (Math.abs(endAngle - startAngle) > Math.PI)851 {852 orientation = 'opposite';853 }854 if (that._isVML)855 {856 path = that._rangeVMLRender(startPoint, endPoint, radius, startProjectionPoint, endProjectionPoint, endWidth, startWidth, startDistance, endDistance, orientation);857 } else858 {859 path = that._rangeSVGRender(startPoint, endPoint, radius, startProjectionPoint, endProjectionPoint, endWidth, startWidth, startDistance, endDistance, orientation);860 }861 range.style.visibility = visibility;862 range.style['class'] = that.toThemeProperty('jqx-gauge-range');863 range = that.renderer.path(path, range.style);864 that._ranges.push(range);865 },866 _rangeSVGRender: function (startPoint, endPoint, radius, startProjectionPoint, endProjectionPoint, endWidth, startWidth, startDistance, endDistance, orientation)867 {868 var path = '',869 startDistance = radius - startDistance,870 endDistance = radius - endDistance,871 circle = ['0,1', '0,0'];872 if (orientation === 'opposite')873 {874 circle = ['1,1', '1,0'];875 }876 path = 'M' + startPoint.x + ',' + startPoint.y + ' ';877 path += 'A' + (radius - startDistance) + ',' + (radius - startDistance) + ' 100 ' + circle[0] + ' ' + endPoint.x + ',' + endPoint.y + ' ';878 path += 'L ' + (endProjectionPoint.x) + ',' + (endProjectionPoint.y) + ' ';879 path += 'A' + (radius - endWidth - startDistance) + ',' + (radius - endWidth - startDistance) + ' 100 ' + circle[1] + ' ' + (startProjectionPoint.x) + ',' + (startProjectionPoint.y) + ' ';880 path += 'L ' + (startPoint.x) + ',' + (startPoint.y) + ' ';881 path += 'z';882 return path;883 },884 _rangeVMLRender: function (startPoint, endPoint, radius, startProjectionPoint, endProjectionPoint, endWidth, startWidth, startDistance, endDistance, orientation)885 {886 radius -= radius - startDistance + 10;887 var path = '',888 outerRadius = Math.floor(radius + (startWidth + endWidth) / 2),889 startDistance = Math.floor(radius - startDistance),890 endDistance = Math.floor(endDistance),891 middleProjection = {892 x: (startProjectionPoint.x + endProjectionPoint.x) / 2,893 y: (startProjectionPoint.y + endProjectionPoint.y) / 2894 },895 projDistance = Math.sqrt((endProjectionPoint.x - startProjectionPoint.x) * (endProjectionPoint.x - startProjectionPoint.x) + (endProjectionPoint.y - startProjectionPoint.y) * (endProjectionPoint.y - startProjectionPoint.y)),896 projCenterX = Math.floor(middleProjection.x + Math.sqrt(radius * radius - (projDistance / 2) * (projDistance / 2)) * (startProjectionPoint.y - endProjectionPoint.y) / projDistance),897 projCenterY = Math.floor(middleProjection.y + Math.sqrt(radius * radius - (projDistance / 2) * (projDistance / 2)) * (endProjectionPoint.x - startProjectionPoint.x) / projDistance),898 middle = {899 x: (startPoint.x + endPoint.x) / 2,900 y: (startPoint.y + endPoint.y) / 2901 },902 distance = Math.sqrt((endPoint.x - startPoint.x) * (endPoint.x - startPoint.x) + (endPoint.y - startPoint.y) * (endPoint.y - startPoint.y)),903 centerX = Math.floor(middle.x + Math.sqrt(Math.abs(outerRadius * outerRadius - (distance / 2) * (distance / 2))) * (startPoint.y - endPoint.y) / distance),904 centerY = Math.floor(middle.y + Math.sqrt(Math.abs(outerRadius * outerRadius - (distance / 2) * (distance / 2))) * (endPoint.x - startPoint.x) / distance);905 if (orientation === 'opposite')906 {907 projCenterX = Math.floor(middleProjection.x - Math.sqrt(radius * radius - (projDistance / 2) * (projDistance / 2)) * (startProjectionPoint.y - endProjectionPoint.y) / projDistance);908 projCenterY = Math.floor(middleProjection.y - Math.sqrt(radius * radius - (projDistance / 2) * (projDistance / 2)) * (endProjectionPoint.x - startProjectionPoint.x) / projDistance);909 centerX = Math.floor(middle.x - Math.sqrt(Math.abs(outerRadius * outerRadius - (distance / 2) * (distance / 2))) * (startPoint.y - endPoint.y) / distance);910 centerY = Math.floor(middle.y - Math.sqrt(Math.abs(outerRadius * outerRadius - (distance / 2) * (distance / 2))) * (endPoint.x - startPoint.x) / distance);911 }912 radius = Math.floor(radius);913 endPoint = { x: Math.floor(endPoint.x), y: Math.floor(endPoint.y) };914 startPoint = { x: Math.floor(startPoint.x), y: Math.floor(startPoint.y) };915 startProjectionPoint = { x: Math.floor(startProjectionPoint.x), y: Math.floor(startProjectionPoint.y) };916 endProjectionPoint = { x: Math.floor(endProjectionPoint.x), y: Math.floor(endProjectionPoint.y) };917 path = 'm ' + endPoint.x + ',' + endPoint.y;918 path += 'at ' + (centerX - outerRadius) + ' ' + (centerY - outerRadius) + ' ' + (outerRadius + centerX) + ' ' + (outerRadius + centerY) + ' ' + endPoint.x + ',' + endPoint.y + ' ' + startPoint.x + ',' + startPoint.y;919 path += 'l ' + startProjectionPoint.x + ',' + startProjectionPoint.y;920 path += 'm ' + endPoint.x + ',' + endPoint.y;921 path += 'l ' + endProjectionPoint.x + ',' + endProjectionPoint.y;922 path += 'at ' + (projCenterX - radius) + ' ' + (projCenterY - radius) + ' ' + (radius + projCenterX) + ' ' + (radius + projCenterY) + ' ' + endProjectionPoint.x + ',' + endProjectionPoint.y + ' ' + startProjectionPoint.x + ',' + startProjectionPoint.y;923 path += 'qx ' + startProjectionPoint.x + ' ' + startProjectionPoint.y;924 return path;925 },926 _getProjectionPoint: function (angle, radius, ratio, displacement)927 {928 var point = { x: radius + (ratio - displacement) * Math.sin(angle), y: radius + (ratio - displacement) * Math.cos(angle) };929 return point;930 },931 _addLabels: function (sizeChange)932 {933 var self = this,934 interval = self._getLabelInterval();935 if (self.labels.visible && self.labels.interval.toString() !== '0')936 {937 var distance = this._getDistance(this._getLabelsDistance()),938 value;939 var numberOfIterations = 0;940 if (self.int64 === 's')941 {942 for (var currentLabel = new $.jqx.math().fromNumber(self.min.toString(), 10) ; currentLabel.lessThanOrEqual(self._max64) ; currentLabel = currentLabel.add(interval))943 {944 numberOfIterations += 1;945 if (numberOfIterations > 250)946 {947 break;948 }949 if (currentLabel.lessThan(self._min64) || currentLabel.greaterThan(self._max64))950 {951 break;952 }953 this._addLabel({954 angle: this._getAngleByValue(currentLabel),955 value: currentLabel.toString(),956 distance: distance,957 style: this.labels.className958 });959 }960 } else if (self.int64 === 'u')961 {962 for (var currentLabel = new BigNumber(self.min) ; currentLabel.compare(self._max64) !== 1; currentLabel = currentLabel.add(interval))963 {964 numberOfIterations += 1;965 if (numberOfIterations > 250)966 {967 break;968 }969 if ((currentLabel.compare(self._min64) === -1) || (currentLabel.compare(self._max64) === 1))970 {971 break;972 }973 this._addLabel({974 angle: this._getAngleByValue(currentLabel),975 value: currentLabel.toString(),976 distance: distance,977 style: this.labels.className978 });979 }980 } else981 {982 for (var currentLabel = this.min; currentLabel <= this.max; currentLabel += interval)983 {984 numberOfIterations += 1;985 if (numberOfIterations > 250)986 {987 break;988 }989 this._addLabel({990 angle: this._getAngleByValue(currentLabel),991 value: interval >= 1 ? currentLabel : new Number(currentLabel).toFixed(2),992 distance: distance,993 style: this.labels.className994 }, sizeChange);995 }996 }997 }998 },999 _getLabelsDistance: function ()1000 {1001 var maxSize = this._getMaxLabelSize(),1002 labelsDistance = this._getDistance(this.labels.distance),1003 ticksDistance = this._getDistance(this.ticksDistance);1004 maxSize = maxSize.width;1005 if (this.labels.position === 'inside')1006 {1007 return ticksDistance + maxSize - 5;1008 } else if (this.labels.position === 'outside')1009 {1010 if (labelsDistance < (ticksDistance - maxSize * 1.5))1011 {1012 return labelsDistance;1013 }1014 return Math.max(ticksDistance - maxSize * 1.5, 0.6 * maxSize);1015 }1016 return this.labels.distance;1017 },1018 _addLabel: function (options, sizeChange)1019 {1020 var that = this.that;1021 var angle = options.angle,1022 r = that._originalRadius,1023 w = r - options.distance,1024 offset = that.labels.offset,1025 borderSize = that._outerBorderOffset(),1026 x = r + borderSize + w * Math.sin(angle) + offset[0],1027 y = r + borderSize + w * Math.cos(angle) + offset[1],1028 value = options.value,1029 className = options.style || '',1030 textSize,1031 label,1032 fontSize = that.labels.fontSize;1033 value = that._formatLabel(value.toString());1034 var stylingObj = { 'class': className };1035 if (fontSize)1036 {1037 stylingObj['font-size'] = fontSize;1038 }1039 if (that.labels.fontFamily)1040 {1041 stylingObj['font-family'] = that.labels.fontFamily;1042 }1043 if (that.labels.fontWeight)1044 {1045 stylingObj['font-weight'] = that.labels.fontWeight;1046 }1047 if (that.labels.fontStyle)1048 {1049 stylingObj['font-style'] = that.labels.fontStyle;1050 }1051 if (sizeChange && !that.niceInterval)1052 {1053 var label = that._labels[that._labelsIterator];1054 var sz = that.renderer._measureText(value, 0, stylingObj, true);1055 var textPartsInfo = sz.textPartsInfo;1056 var textParts = textPartsInfo.parts;1057 var tw = textPartsInfo.width;1058 var th = textPartsInfo.height;1059 label.setAttribute("x", Math.round(x) - sz.width / 2 + (sz.width - textPartsInfo.width) / 2);1060 label.setAttribute("y", Math.round(y) + th + (sz.height - th) / 2);1061 that._labelsIterator++;1062 }1063 else1064 {1065 var textSize = that.renderer.measureText(value, 0, stylingObj);1066 var xCorrection = 0;1067 if (fontSize !== undefined && Math.PI > angle)1068 {1069 xCorrection = (-textSize.width / 2) * (parseInt(fontSize) / 25);1070 if (parseInt(fontSize) <= 10)1071 {1072 xCorrection *= -1;1073 }1074 }1075 // textSize = that.renderer.measureText(value, 0, { 'class': className });1076 label = that.renderer.text(value, Math.round(x) - textSize.width / 2 + xCorrection, Math.round(y), textSize.width, textSize.height, 0, stylingObj);1077 that._labels.push(label);1078 }1079 },1080 _addCaption: function (sizeChange)1081 {1082 if (this.caption.visible !== false)1083 {1084 var that = this.that;1085 var text = that.caption.value,1086 className = that.toThemeProperty('jqx-gauge-caption'),1087 offset = that.caption.offset,1088 size = that.renderer.measureText(text, 0, { 'class': className }),1089 position = that._getPosition(this.caption.position, size, offset),1090 style = that.caption.style,1091 border = that._outerBorderOffset();1092 if (!sizeChange)1093 {1094 var t = that.renderer.text(text, position.left + border, position.top + border, size.width, size.height, 0, { 'class': className });1095 this._caption = t;1096 }1097 else1098 {1099 this._caption.setAttribute("x", position.left + border);1100 this._caption.setAttribute("y", position.top + border);1101 }1102 }1103 },1104 _getPosition: function (position, size, offset)1105 {1106 var left = 0,1107 top = 0,1108 r = this._originalRadius;1109 switch (position)1110 {1111 case 'left':1112 left = (r - size.width) / 2;1113 top = r - size.height / 2;1114 break;1115 case 'right':1116 left = r + (r - size.width) / 2;1117 top = r - size.height / 2;1118 break;1119 case 'bottom':1120 left = (2 * r - size.width) / 2;1121 top = (r + 2 * r - size.height) / 2;1122 break;1123 default:1124 left = (2 * r - size.width) / 2;1125 top = (r + size.height) / 2;1126 break;1127 }1128 return { left: left + offset[0], top: top + offset[1] };1129 },1130 _addPointer: function (sizeChange)1131 {1132 var visibility = 'visible';1133 if (!this.pointer.visible)1134 {1135 visibility = 'hidden';1136 }1137 var radius = this._originalRadius,1138 length = this._getSize(this.pointer.length),1139 innerW = length * 0.9,1140 angle = this._getAngleByValue(this.value),1141 pointerType = this.pointer.pointerType,1142 points;1143 points = this._computePointerPoints(this._getSize(this.pointer.width), angle, length, pointerType !== 'default');1144 this._pointer = this.renderer.path(points, this.pointer.style);1145 $(this._pointer).css('visibility', visibility);1146 },1147 _computePointerPoints: function (pointerWidth, angle, pointerLength, rect)1148 {1149 if (!rect)1150 {1151 return this._computeArrowPoints(pointerWidth, angle, pointerLength);1152 } else1153 {1154 return this._computeRectPoints(pointerWidth, angle, pointerLength);1155 }1156 },1157 _computeArrowPoints: function (pointerWidth, angle, pointerLength)1158 {1159 var r = this._originalRadius - 0.5,1160 sin = Math.sin(angle),1161 cos = Math.cos(angle),1162 borderSize = this._outerBorderOffset(),1163 x = r + borderSize + pointerLength * sin,1164 y = r + borderSize + pointerLength * cos,1165 startX1 = r + borderSize + pointerWidth * cos,1166 startY1 = r + borderSize - pointerWidth * sin,1167 startX2 = r + borderSize - pointerWidth * cos,1168 startY2 = r + borderSize + pointerWidth * sin,1169 points;1170 if (this._isVML)1171 {1172 startX1 = Math.round(startX1);1173 startX2 = Math.round(startX2);1174 startY1 = Math.round(startY1);1175 startY2 = Math.round(startY2);1176 x = Math.round(x);1177 y = Math.round(y);1178 }1179 points = 'M ' + startX1 + ',' + startY1 + ' L ' + startX2 + ',' + startY2 + ' L ' + x + ',' + y + '';1180 return points;1181 },1182 _computeRectPoints: function (pointerWidth, angle, pointerLength)1183 {1184 var r = this._originalRadius,1185 sin = Math.sin(angle),1186 cos = Math.cos(angle),1187 arrowDistance = pointerLength,1188 borderSize = this._outerBorderOffset(),1189 endX1 = r + borderSize - pointerWidth * cos + pointerLength * sin,1190 endY1 = r + borderSize + pointerWidth * sin + pointerLength * cos,1191 endX2 = r + borderSize + pointerWidth * cos + pointerLength * sin,1192 endY2 = r + borderSize - pointerWidth * sin + pointerLength * cos,1193 startX1 = r + borderSize + pointerWidth * cos,1194 startY1 = r + borderSize - pointerWidth * sin,1195 startX2 = r + borderSize - pointerWidth * cos,1196 startY2 = r + borderSize + pointerWidth * sin,1197 points;1198 if (this._isVML)1199 {1200 startX1 = Math.round(startX1);1201 startX2 = Math.round(startX2);1202 startY1 = Math.round(startY1);1203 startY2 = Math.round(startY2);1204 endX1 = Math.round(endX1);1205 endY1 = Math.round(endY1);1206 endX2 = Math.round(endX2);1207 endY2 = Math.round(endY2);1208 }1209 points = 'M ' + startX1 + ',' + startY1 + ' L ' + startX2 + ',' + startY2 + ' L ' + endX1 + ',' + endY1 + ' ' + endX2 + ',' + endY2;1210 return points;1211 },1212 _getAngleByValue: function (value)1213 {1214 var self = this,1215 startAngle = self.startAngle,1216 angleDifference = startAngle - self.endAngle,1217 start,1218 end,1219 endStartDifference,1220 valueStartDifference,1221 angle;1222 if (self.int64 !== false)1223 {1224 if (self.int64 === 's')1225 {1226 value = new $.jqx.math().fromString(value.toString(), 10);1227 } else1228 {1229 value = new BigNumber(value);1230 }1231 start = self._min64;1232 end = self._max64;1233 endStartDifference = end.subtract(start);1234 valueStartDifference = value.subtract(start);1235 if (self.int64 === 'u')1236 {1237 valueStartDifference = valueStartDifference.intPart();1238 }1239 var endStartString = endStartDifference.toString(),1240 endStartFloat,1241 valueStartString = valueStartDifference.toString(),1242 valueStartFloat;1243 if (endStartString.length > 15)1244 {1245 var floatOffset = endStartString.length - 15;1246 endStartString = endStartString.slice(0, 15) + '.' + endStartString.slice(15);1247 endStartFloat = parseFloat(endStartString);1248 if (valueStartString.length > floatOffset)1249 {1250 var valueStartOffset = valueStartString.length - floatOffset;1251 valueStartString = valueStartString.slice(0, valueStartOffset) + '.' + valueStartString.slice(valueStartOffset);1252 } else if (valueStartString.length === floatOffset)1253 {1254 valueStartString = '0.' + valueStartString;1255 } else1256 {1257 var prefix = '0.';1258 for (var i = 0; i < floatOffset - valueStartString.length; i++)1259 {1260 prefix += '0';1261 }1262 valueStartString = prefix + '' + valueStartString;1263 }1264 valueStartFloat = parseFloat(valueStartString);1265 } else1266 {1267 endStartFloat = parseFloat(endStartDifference.toString());1268 valueStartFloat = parseFloat(valueStartDifference.toString());1269 }1270 angle = angleDifference * valueStartFloat / endStartFloat + startAngle + Math.PI;1271 } else1272 {1273 start = self.min;1274 end = self.max;1275 endStartDifference = end - start;1276 valueStartDifference = value - start;1277 angle = angleDifference * valueStartDifference / endStartDifference + startAngle + Math.PI;1278 }1279 return angle;1280 },1281 _setValue: function (value)1282 {1283 var self = this;1284 if ((self.int64 === 's' && value.lessThanOrEqual(self._max64) && value.greaterThanOrEqual(self._min64)) ||1285 (self.int64 === 'u' && value.compare(self._max64) !== 1 && value.compare(self._min64) !== -1) ||1286 (self.int64 === false && value <= self.max && value >= self.min))1287 {1288 var angle = self._getAngleByValue(value),1289 pointerType = self.pointer.pointerType,1290 points = self._computePointerPoints(self._getSize(self.pointer.width), angle, self._getSize(self.pointer.length), pointerType !== 'default');1291 if (self._isVML)1292 {1293 if (self._pointer) $(self._pointer).remove();1294 self._pointer = self.renderer.path(points, self.pointer.style);1295 } else1296 {1297 self.renderer.attr(self._pointer, { d: points });1298 }1299 if (self.int64 !== false)1300 {1301 self.value = value.toString();1302 if (self.int64 === 's')1303 {1304 self._value64 = new $.jqx.math().fromString(self.value, 10);1305 } else1306 {1307 self._value64 = new BigNumber(self.value);1308 }1309 } else1310 {1311 self.value = value;1312 }1313 $.jqx.aria(self, 'aria-valuenow', value.toString());1314 }1315 },1316 resize: function (width, height)1317 {1318 this.width = width;1319 this.height = height;1320 this.refresh();1321 },1322 propertiesChangedHandler: function (object, key, value)1323 {1324 if (value.width && value.height && Object.keys(value).length == 2)1325 {1326 object._refresh(true);1327 }1328 },1329 propertyChangedHandler: function (object, key, oldvalue, value)1330 {1331 if (value == oldvalue)1332 return;1333 if (object.batchUpdate && object.batchUpdate.width && object.batchUpdate.height && Object.keys(object.batchUpdate).length == 2)1334 {1335 return;1336 }1337 if (key == 'min')1338 {1339 if (object.int64 === true)1340 {1341 object._min64 = new $.jqx.math().fromString(value.toString(), 10);1342 } else1343 {1344 this.min = parseInt(value);1345 }1346 $.jqx.aria(object, 'aria-valuemin', value);1347 }1348 if (key == 'max')1349 {1350 if (object.int64 === true)1351 {1352 object._max64 = new $.jqx.math().fromString(value.toString(), 10);1353 } else1354 {1355 this.max = parseInt(value);1356 }1357 $.jqx.aria(object, 'aria-valuemax', value);1358 }1359 if (key === 'disabled')1360 {1361 if (value)1362 {1363 this.disable();1364 } else1365 {1366 this.enable();1367 }1368 $.jqx.aria(this, 'aria-disabled', value);1369 } else if (key === 'value')1370 {1371 this.value = oldvalue;1372 this.setValue(value);1373 } else1374 {1375 if (key === 'startAngle')1376 {1377 this.startAngle = this.startAngle * Math.PI / 180 + Math.PI / 2;1378 } else if (key === 'endAngle')1379 {1380 this.endAngle = this.endAngle * Math.PI / 180 + Math.PI / 2;1381 } else if (key === 'colorScheme')1382 {1383 this.pointer.style = null;1384 this.cap.style = null;1385 } else if (key === 'radius')1386 {1387 this._radius = value;1388 }1389 if (key !== 'animationDuration' && key !== 'easing')1390 {1391 this._refresh();1392 }1393 }1394 if (this.renderer instanceof $.jqx.HTML5Renderer)1395 this.renderer.refresh();1396 },1397 _tickConstructor: function (data, jqx)1398 {1399 if (this.host)1400 {1401 return new this._tickConstructor(data, jqx);1402 }1403 data = data || {};1404 this.size = jqx._validatePercentage(data.size, '10%');1405 function intervalOrNumber(that, property)1406 {1407 if (jqx.int64 === false)1408 {1409 that[property] = parseFloat(data[property]);1410 } else1411 {1412 that[property] = data[property];1413 }1414 if (!that[property])1415 {1416 that[property] = 5;1417 }1418 }1419 intervalOrNumber(this, 'interval');1420 intervalOrNumber(this, 'number');1421 this.style = data.style || { stroke: '#898989', 'stroke-width': 1 };1422 if (typeof data.visible === 'undefined')1423 {1424 this.visible = true;1425 } else1426 {1427 this.visible = data.visible;1428 }1429 },1430 _capConstructor: function (data, jqx)1431 {1432 var color = jqx._getColorScheme(jqx.colorScheme)[0];1433 if (this.host)1434 {1435 return new this._capConstructor(data, jqx);1436 }1437 data = data || {};1438 if (typeof data.visible === 'undefined')1439 {1440 this.visible = true;1441 } else1442 {1443 this.visible = data.visible;1444 }1445 this.size = jqx._validatePercentage(data.size, '4%');1446 this.style = data.style || { fill: color, 'stroke-width': '1px', stroke: color, 'z-index': 30 };1447 },1448 _pointerConstructor: function (data, jqx)1449 {1450 var color = jqx._getColorScheme(jqx.colorScheme)[0];1451 if (this.host)1452 {1453 return new this._pointerConstructor(data, jqx);1454 }1455 data = data || {};1456 if (typeof data.visible === 'undefined')1457 {1458 this.visible = true;1459 } else1460 {1461 this.visible = data.visible;1462 }1463 this.pointerType = data.pointerType;1464 if (this.pointerType !== 'default' && this.pointerType !== 'rectangle')1465 {1466 this.pointerType = 'default';1467 }1468 this.style = data.style || { 'z-index': 0, stroke: color, fill: color, 'stroke-width': 1 };1469 this.length = jqx._validatePercentage(data.length, '70%');1470 this.width = jqx._validatePercentage(data.width, '2%');1471 },1472 _labelsConstructor: function (data, jqx)1473 {1474 if (this.host)1475 {1476 return new this._labelsConstructor(data, jqx);1477 }1478 data = data || {};1479 if (typeof data.visible === 'undefined')1480 {1481 this.visible = true;1482 } else1483 {1484 this.visible = data.visible;1485 }1486 this.offset = data.offset;1487 if (!(this.offset instanceof Array))1488 {1489 this.offset = [0, -10];1490 }1491 if (!data.interval)1492 {1493 data.interval = 20;1494 }1495 if (jqx.int64 !== false)1496 {1497 this.interval = data.interval;1498 if (jqx.int64 === 's')1499 {1500 this._interval64 = new $.jqx.math().fromString(data.interval.toString(), 10);1501 } else1502 {1503 this._interval64 = new BigNumber(data.interval);1504 }1505 } else1506 {1507 this.interval = parseFloat(data.interval);1508 }1509 if (!data.number)1510 {1511 data.number = 5;1512 }1513 this.number = data.number;1514 this.distance = jqx._validatePercentage(data.distance, '38%');1515 this.position = data.position;1516 if (this.position !== 'inside' && this.position !== 'outside')1517 {1518 this.position = 'none';1519 }1520 this.formatValue = data.formatValue;1521 this.formatSettings = data.formatSettings;1522 this.fontSize = data.fontSize;1523 this.fontFamily = data.fontFamily;1524 this.fontWeight = data.fontWeight;1525 this.fontStyle = data.fontStyle;1526 },1527 _captionConstructor: function (data, jqx)1528 {1529 if (this.host)1530 {1531 return new this._captionConstructor(data, jqx);1532 }1533 data = data || {};1534 if (typeof data.visible === 'undefined')1535 {1536 this.visible = true;1537 } else1538 {1539 this.visible = data.visible;1540 }1541 this.value = data.value || '';1542 this.position = data.position;1543 if (this.position !== 'bottom' && this.position !== 'top' &&1544 this.position !== 'left' && this.position !== 'right')1545 {1546 this.position = 'bottom';1547 }1548 this.offset = data.offset;1549 if (!(this.offset instanceof Array))1550 {1551 this.offset = [0, 0];1552 }1553 },1554 _rangeConstructor: function (data, jqx)1555 {1556 if (this.host)1557 {1558 return new this._rangeConstructor(data, jqx);1559 }1560 data = data || {};1561 this.startDistance = jqx._validatePercentage(data.startDistance, '5%');1562 this.endDistance = jqx._validatePercentage(data.endDistance, '5%');1563 this.style = data.style || { fill: '#000000', stroke: '#111111' };1564 this.startWidth = parseFloat(data.startWidth, 10);1565 if (!this.startWidth)1566 {1567 this.startWidth = 10;1568 }1569 this.startWidth = Math.max(this.startWidth, 2);1570 this.endWidth = parseFloat(data.endWidth, 10);1571 if (!this.endWidth)1572 {1573 this.endWidth = 10;1574 }1575 this.endWidth = Math.max(this.endWidth, 2);1576 if (data.startValue === undefined)1577 {1578 data.startValue = 0;1579 }1580 if (data.endValue === undefined)1581 {1582 data.endValue = 100;1583 }1584 if (jqx.int64 !== false)1585 {1586 this.startValue = data.startValue;1587 this.endValue = data.endValue;1588 if (jqx.int64 === 's')1589 {1590 this._startValue64 = new $.jqx.math().fromString(data.startValue.toString(), 10);1591 this._endValue64 = new $.jqx.math().fromString(data.endValue.toString(), 10);1592 } else1593 {1594 this._startValue64 = new BigNumber(data.startValue);1595 this._endValue64 = new BigNumber(data.endValue);1596 }1597 } else1598 {1599 this.startValue = parseFloat(data.startValue, 10);1600 this.endValue = parseFloat(data.endValue, 10);1601 }1602 },1603 _borderConstructor: function (data, jqx)1604 {1605 if (this.host)1606 {1607 return new this._borderConstructor(data, jqx);1608 }1609 data = data || {};1610 this.size = jqx._validatePercentage(data.size, '10%');1611 this.style = data.style || { stroke: '#cccccc' };1612 if (typeof data.showGradient === 'undefined')1613 {1614 this.showGradient = true;1615 } else1616 {1617 this.showGradient = data.showGradient;1618 }1619 if (typeof data.visible === 'undefined')1620 {1621 this.visible = true;1622 } else1623 {1624 this.visible = data.visible;1625 }1626 }1627 };1628 // Common functions for linear and radial gauge1629 var common = {1630 _events: ['valueChanging', 'valueChanged'],1631 _animationTimeout: 10,1632 _schemes: [1633 { name: 'scheme01', colors: ['#307DD7', '#AA4643', '#89A54E', '#71588F', '#4198AF'] },1634 { name: 'scheme02', colors: ['#7FD13B', '#EA157A', '#FEB80A', '#00ADDC', '#738AC8'] },1635 { name: 'scheme03', colors: ['#E8601A', '#FF9639', '#F5BD6A', '#599994', '#115D6E'] },1636 { name: 'scheme04', colors: ['#D02841', '#FF7C41', '#FFC051', '#5B5F4D', '#364651'] },1637 { name: 'scheme05', colors: ['#25A0DA', '#309B46', '#8EBC00', '#FF7515', '#FFAE00'] },1638 { name: 'scheme06', colors: ['#0A3A4A', '#196674', '#33A6B2', '#9AC836', '#D0E64B'] },1639 { name: 'scheme07', colors: ['#CC6B32', '#FFAB48', '#FFE7AD', '#A7C9AE', '#888A63'] },1640 { name: 'scheme08', colors: ['#3F3943', '#01A2A6', '#29D9C2', '#BDF271', '#FFFFA6'] },1641 { name: 'scheme09', colors: ['#1B2B32', '#37646F', '#A3ABAF', '#E1E7E8', '#B22E2F'] },1642 { name: 'scheme10', colors: ['#5A4B53', '#9C3C58', '#DE2B5B', '#D86A41', '#D2A825'] },1643 { name: 'scheme11', colors: ['#993144', '#FFA257', '#CCA56A', '#ADA072', '#949681'] },1644 { name: 'scheme12', colors: ['#105B63', '#EEEAC5', '#FFD34E', '#DB9E36', '#BD4932'] },1645 { name: 'scheme13', colors: ['#BBEBBC', '#F0EE94', '#F5C465', '#FA7642', '#FF1E54'] },1646 { name: 'scheme14', colors: ['#60573E', '#F2EEAC', '#BFA575', '#A63841', '#BFB8A3'] },1647 { name: 'scheme15', colors: ['#444546', '#FFBB6E', '#F28D00', '#D94F00', '#7F203B'] },1648 { name: 'scheme16', colors: ['#583C39', '#674E49', '#948658', '#F0E99A', '#564E49'] },1649 { name: 'scheme17', colors: ['#142D58', '#447F6E', '#E1B65B', '#C8782A', '#9E3E17'] },1650 { name: 'scheme18', colors: ['#4D2B1F', '#635D61', '#7992A2', '#97BFD5', '#BFDCF5'] },1651 { name: 'scheme19', colors: ['#844341', '#D5CC92', '#BBA146', '#897B26', '#55591C'] },1652 { name: 'scheme20', colors: ['#56626B', '#6C9380', '#C0CA55', '#F07C6C', '#AD5472'] },1653 { name: 'scheme21', colors: ['#96003A', '#FF7347', '#FFBC7B', '#FF4154', '#642223'] },1654 { name: 'scheme22', colors: ['#5D7359', '#E0D697', '#D6AA5C', '#8C5430', '#661C0E'] },1655 { name: 'scheme23', colors: ['#16193B', '#35478C', '#4E7AC7', '#7FB2F0', '#ADD5F7'] },1656 { name: 'scheme24', colors: ['#7B1A25', '#BF5322', '#9DA860', '#CEA457', '#B67818'] },1657 { name: 'scheme25', colors: ['#0081DA', '#3AAFFF', '#99C900', '#FFEB3D', '#309B46'] },1658 { name: 'scheme26', colors: ['#0069A5', '#0098EE', '#7BD2F6', '#FFB800', '#FF6800'] },1659 { name: 'scheme27', colors: ['#FF6800', '#A0A700', '#FF8D00', '#678900', '#0069A5'] }1660 ],1661 _getScale: function (size, dim, parent)1662 {1663 if (size && size.toString().indexOf('%') >= 0)1664 {1665 size = parseInt(size, 10) / 100;1666 return parent[dim]() * size;1667 }1668 return parseInt(size, 10);1669 },1670 _removeElements: function ()1671 {1672 this.host.children('.chartContainer').remove();1673 this.host.children('#tblChart').remove();1674 },1675 _getLabelInterval: function ()1676 {1677 var that = this,1678 labels = that.labels,1679 interval;1680 if (that.tickMode === 'default')1681 {1682 if (that.niceInterval)1683 {1684 interval = that._getNiceInterval(that.widgetName === 'jqxGauge' ? 'radial' : 'linear');1685 } else1686 {1687 if (that.int64 === false)1688 {1689 interval = labels.interval;1690 } else1691 {1692 if (!labels._interval64)1693 {1694 labels._interval64 = that.int64 === 's' ? new $.jqx.math().fromNumber(labels.interval) : new BigNumber(labels.interval);1695 }1696 interval = labels._interval64;1697 }1698 }1699 } else1700 {1701 if (that.int64 === false)1702 {1703 var startToEnd = that.max - that.min;1704 interval = startToEnd / labels.number;1705 } else1706 {1707 var startToEnd = that._max64.subtract(that._min64);1708 if (that.int64 === 's')1709 {1710 interval = startToEnd.div(new $.jqx.math().fromNumber(labels.number));1711 } else1712 {1713 interval = startToEnd.divide(new BigNumber(labels.number));1714 }1715 }1716 }1717 return interval;1718 },1719 _getMaxLabelSize: function ()1720 {1721 var that = this,1722 maxVal = this.max,1723 minVal = this.min;1724 minVal = that._formatLabel(minVal);1725 maxVal = that._formatLabel(maxVal);1726 var dummy = $('<div style="position: absolute; visibility: hidden;" class="' + that.toThemeProperty('jqx-gauge-label') + '"></div>');1727 dummy.css({ 'font-size': that.labels.fontSize, 'font-family': that.labels.fontFamily, 'font-weight': that.labels.fontWeight, 'font-style': that.labels.fontStyle });1728 $('body').append(dummy);1729 dummy.html(minVal);1730 var minSize = { width: dummy.width(), height: dummy.height() };1731 dummy.html(maxVal);1732 var maxSize = { width: dummy.width(), height: dummy.height() };1733 dummy.remove();1734 // var maxSize = this.renderer.measureText(maxVal, 0, { 'class': this.toThemeProperty('jqx-gauge-label') }),1735 // minSize = this.renderer.measureText(minVal, 0, { 'class': this.toThemeProperty('jqx-gauge-label') });1736 if (minSize.width > maxSize.width)1737 {1738 return minSize;1739 }1740 return maxSize;1741 },1742 disable: function ()1743 {1744 this.disabled = true;1745 this.host.addClass(this.toThemeProperty('jqx-fill-state-disabled'));1746 },1747 enable: function ()1748 {1749 this.disabled = false;1750 this.host.removeClass(this.toThemeProperty('jqx-fill-state-disabled'));1751 },1752 destroy: function ()1753 {1754 var self = this;1755 if (self._timeout)1756 clearTimeout(this._timeout);1757 self._timeout = null;1758 $.jqx.utilities.resize(self.host, null, true);1759 self._removeElements();1760 self.renderer.clear();1761 self.renderer = null;1762 var vars = $.data(self.element, "jqxGauge");1763 if (vars)1764 delete vars.instance;1765 self.host.children().remove();1766 self._caption = null;1767 self._caption = null;1768 self._pointer = null;1769 self._labels = [];1770 self._cap = null;1771 self._ticks = [];1772 self._ranges = [];1773 self._border = null;1774 self._gauge = null;1775 self._caption = null;1776 self.renderer = null;1777 self._animations = [];1778 self.host.removeData();1779 self.host.removeClass();1780 self.host.remove();1781 self.that = null;1782 self.element = null;1783 self._gaugeParent = null;1784 delete self._gaugeParent;1785 delete self.element;1786 delete self.host;1787 },1788 _validatePercentage: function (data, def)1789 {1790 if (parseFloat(data) !== 0 && (!data || !parseInt(data, 10)))1791 {1792 data = def;1793 }1794 return data;1795 },1796 _getColorScheme: function (name)1797 {1798 var scheme;1799 for (var i = 0; i < this._schemes.length; i += 1)1800 {1801 scheme = this._schemes[i];1802 if (scheme.name === name)1803 {1804 return scheme.colors;1805 }1806 }1807 return null;1808 },1809 setValue: function (value, duration)1810 {1811 var self = this;1812 if (!self.disabled)1813 {1814 duration = duration || self.animationDuration || 0;1815 if (self.int64 === 's')1816 {1817 if (typeof value === 'number')1818 {1819 value = new $.jqx.math().fromNumber(value, 10);1820 } else if (typeof value === 'string')1821 {1822 value = new $.jqx.math().fromString(value, 10);1823 }1824 if (value.greaterThan(self._max64))1825 {1826 value = new $.jqx.math().fromString(self._max64.toString(), 10);1827 }1828 if (value.lessThan(self._min64))1829 {1830 value = new $.jqx.math().fromString(self._min64.toString(), 10);1831 }1832 self._animate(self._value64, value, duration);1833 } else if (self.int64 === 'u')1834 {1835 value = new BigNumber(value);1836 if (value.compare(self._max64) === 1)1837 {1838 value = new BigNumber(self._max64);1839 }1840 if (value.compare(self._min64) === -1)1841 {1842 value = new BigNumber(self._min64);1843 }1844 self._animate(self._value64, value, duration);1845 } else1846 {1847 if (value > self.max)1848 {1849 value = self.max;1850 }1851 if (value < self.min)1852 {1853 value = self.min;1854 }1855 self._animate(self.value, value, duration);1856 }1857 $.jqx.aria(self, 'aria-valuenow', value.toString());1858 }1859 },1860 _animate: function (start, end, duration)1861 {1862 var self = this;1863 if (self._timeout)1864 {1865 self._endAnimation(self.int64 ? self._value64 : self.value, false);1866 }1867 if (!duration)1868 {1869 self._endAnimation(end, true);1870 return;1871 }1872 self._animateHandler(start, end, 0, duration);1873 },1874 _animateHandler: function (start, end, current, duration)1875 {1876 var self = this;1877 if (current <= duration)1878 {1879 this._timeout = setTimeout(function ()1880 {1881 if (self.int64 !== false)1882 {1883 var difference = end.subtract(start);1884 if (self.int64 === 's')1885 {1886 var easing = new $.jqx.math().fromNumber(($.easing[self.easing](current / duration, current, 0, 1, duration)) * 100, 10);1887 self._value64 = start.add(difference.multiply(easing).div(new $.jqx.math().fromNumber(100, 10)));1888 } else1889 {1890 var easing = new BigNumber(($.easing[self.easing](current / duration, current, 0, 1, duration)) * 100);1891 self._value64 = start.add(difference.multiply(easing).divide(100));1892 }1893 self.value = self._value64.toString();1894 self._setValue(self._value64);1895 } else1896 {1897 self.value = start + (end - start) * $.easing[self.easing](current / duration, current, 0, 1, duration);1898 self._setValue(self.value);1899 }1900 self._raiseEvent(0, {1901 value: self.value.toString()1902 });1903 self._animateHandler(start, end, current + self._animationTimeout, duration);1904 }, this._animationTimeout);1905 } else1906 {1907 this._endAnimation(end, true);1908 }1909 },1910 _endAnimation: function (end, toRaiseEvent)1911 {1912 clearTimeout(this._timeout);1913 this._timeout = null;1914 this._setValue(end);1915 if (toRaiseEvent)1916 {1917 this._raiseEvent(1, {1918 value: end.toString()1919 });1920 }1921 },1922 _getMaxTickSize: function ()1923 {1924 return Math.max(this._getSize(this.ticksMajor.size), this._getSize(this.ticksMinor.size));1925 },1926 _raiseEvent: function (eventId, args)1927 {1928 var event = $.Event(this._events[eventId]),1929 result;1930 event.args = args || {};1931 result = this.host.trigger(event);1932 return result;1933 },1934 _getNiceInterval: function (type, minorTicks)1935 {1936 function log10(val)1937 {1938 return Math.log(parseFloat(val)) / Math.LN10;1939 }1940 function getSectorArcLength()1941 {1942 var arcLength = Math.abs(that.startAngle - that.endAngle) * that._innerRadius;1943 return Math.round(arcLength);1944 }1945 var that = this,1946 dimension = 'width';1947 if (type === 'linear' && that.orientation === 'vertical')1948 {1949 dimension = 'height';1950 }1951 var browserRoundingFix = $.jqx.browser.msie ? 0 : 1; // algorithm adjustment (for browsers other than Internet Explorer)1952 var largestLabelSize;1953 var labelDummy = $('<span class="' + that.toThemeProperty('jqx-gauge-label') + '" style="position: absolute; visibility: hidden;"></span>'),1954 min = that._formatLabel(that.min),1955 max = that._formatLabel(that.max);1956 labelDummy.css({ 'font-size': that.labels.fontSize, 'font-family': that.labels.fontFamily, 'font-weight': that.labels.fontWeight, 'font-style': that.labels.fontStyle });1957 $('body').append(labelDummy);1958 labelDummy.text(min);1959 var minLabelDimension = labelDummy[dimension]() + browserRoundingFix;1960 labelDummy.text(max);1961 var maxLabelDimension = labelDummy[dimension]() + browserRoundingFix;1962 labelDummy.remove();1963 var largestLabelSize = Math.max(maxLabelDimension, minLabelDimension);1964 var multiplier = 1;1965 if (type === 'radial')1966 {1967 var adjustment;1968 if (that._innerRadius < 50)1969 {1970 adjustment = 0.3;1971 } else if (that._innerRadius < 150)1972 {1973 adjustment = 0.6;1974 } else if (that._innerRadius < 250)1975 {1976 adjustment = 0.7;1977 } else1978 {1979 adjustment = 1;1980 }1981 multiplier = 8 / Math.max(1, log10(that._innerRadius)) * adjustment;1982 } else1983 {1984 var largeLabelsAdjustment = 0;1985 if (largestLabelSize > 105)1986 {1987 largeLabelsAdjustment = (largestLabelSize - 105) / 100;1988 }1989 multiplier = 1.5 + largeLabelsAdjustment;1990 }1991 largestLabelSize *= multiplier;1992 var trackDimension;1993 if (type === 'radial')1994 {1995 trackDimension = getSectorArcLength();1996 } else1997 {1998 trackDimension = that._getScaleLength();1999 }2000 var divisionCountEstimate = Math.ceil(trackDimension / largestLabelSize),2001 rangeDelta, exponent, nearestPowerOfTen, factor, niceFactor, niceInterval;2002 if (minorTicks === true)2003 {2004 if (type === 'radial')2005 {2006 divisionCountEstimate *= 4;2007 } else2008 {2009 divisionCountEstimate *= 3;2010 }2011 }2012 if (that.int64 === false)2013 {2014 rangeDelta = that.max - that.min;2015 exponent = Math.floor(log10(rangeDelta) - log10(divisionCountEstimate));2016 nearestPowerOfTen = Math.pow(10, exponent);2017 factor = divisionCountEstimate * nearestPowerOfTen;2018 niceFactor;2019 if (rangeDelta < 2 * factor)2020 {2021 niceFactor = 1;2022 } else if (rangeDelta < 3 * factor)2023 {2024 niceFactor = 2;2025 } else if (rangeDelta < 7 * factor)2026 {2027 niceFactor = 5;2028 } else2029 {2030 niceFactor = 10;2031 }2032 niceInterval = niceFactor * nearestPowerOfTen;2033 // if (that.labels.formatSettings) {2034 // var radix = that.labels.formatSettings.radix;2035 // if (radix !== undefined && radix !== 10 && minorTicks === undefined && niceInterval < 1) {2036 // niceInterval = 1;2037 // }2038 // }2039 } else2040 {2041 rangeDelta = new BigNumber(that.max).subtract(new BigNumber(that.min));2042 exponent = Math.floor(log10(rangeDelta.toString()) - log10(divisionCountEstimate));2043 nearestPowerOfTen = new BigNumber(10).pow(new BigNumber(exponent));2044 factor = new BigNumber(divisionCountEstimate).multiply(nearestPowerOfTen);2045 niceFactor;2046 if (rangeDelta.compare(new BigNumber(2 * factor)) === -1)2047 {2048 niceFactor = 1;2049 } else if (rangeDelta.compare(new BigNumber(3 * factor)) === -1)2050 {2051 niceFactor = 2;2052 } else if (rangeDelta.compare(new BigNumber(7 * factor)) === -1)2053 {2054 niceFactor = 5;2055 } else2056 {2057 niceFactor = 10;2058 }2059 niceInterval = new BigNumber(niceFactor).multiply(nearestPowerOfTen);2060 if (niceInterval.compare(1) === -1)2061 {2062 niceInterval = new BigNumber(1);2063 }2064 if (that.int64 === 's')2065 {2066 niceInterval = new $.jqx.math().fromString(niceInterval.toString());2067 }2068 }2069 return niceInterval;2070 },2071 _styleLabels: function ()2072 {2073 return;2074 var that = this,2075 options = that.labels,2076 labels = that.host.find('.jqx-gauge-label');2077 labels.css({ 'font-size': options.fontSize, 'font-family': options.fontFamily, 'font-weight': options.fontWeight, 'font-style': options.fontStyle });2078 },2079 _checkForOverflow: function (first, second)2080 {2081 var maxInt64 = new BigNumber('9223372036854775807'),2082 bigFirst = new BigNumber(first.toString()),2083 bigSecond = new BigNumber(second.toString());2084 if (bigFirst.add(bigSecond).compare(maxInt64) === 1)2085 {2086 return true;2087 } else2088 {2089 return false;2090 }2091 },2092 _formatLabel: function (value, position)2093 {2094 var that = this,2095 formatFunction = that.labels.formatValue,2096 formatSettings = that.labels.formatSettings,2097 formattedValue;2098 if (formatFunction)2099 {2100 formattedValue = formatFunction(value, position);2101 } else if (formatSettings)2102 {2103 if (formatSettings.radix !== undefined)2104 {2105 formattedValue = new $.jqx.math().getRadixValue(value, that.int64, formatSettings.radix);2106 } else2107 {2108 if (formatSettings.outputNotation !== undefined && formatSettings.outputNotation !== 'default' && formatSettings.outputNotation !== 'decimal')2109 {2110 formattedValue = new $.jqx.math().getDecimalNotation(value, formatSettings.outputNotation, formatSettings.decimalDigits, formatSettings.digits);2111 } else2112 {2113 if (formatSettings.decimalDigits !== undefined)2114 {2115 formattedValue = Number(value).toFixed(formatSettings.decimalDigits);2116 } else if (formatSettings.digits !== undefined)2117 {2118 formattedValue = Number(value).toPrecision(formatSettings.digits);2119 }2120 }2121 }2122 } else2123 {2124 formattedValue = value;2125 }2126 return formattedValue;2127 },2128 _editableLabels: function (skipInputCreation)2129 {2130 var that = this;2131 function handleDblclick(label, value)2132 {2133 var labelDimensions = that.renderer.measureText(that._formatLabel(value), 0, { 'class': that.toThemeProperty('jqx-gauge-label') });2134 inputObject.offset($(label).offset());2135 input.style.width = (labelDimensions.width + 10) + 'px';2136 input.style.height = labelDimensions.height + 'px';2137 input.style.visibility = 'visible';2138 input.value = value;2139 inputObject.select();2140 }2141 if (that.editableLabels)2142 {2143 var labels = that._labels;2144 if (labels.length === 0)2145 {2146 return;2147 }2148 var firstLabel = labels[0],2149 lastLabel = labels[labels.length - 1],2150 input, inputObject;2151 if (skipInputCreation !== true)2152 {2153 input = document.createElement('input');2154 inputObject = $(input);2155 input.className = 'jqx-gauge-label-input';2156 that.element.appendChild(input);2157 } else2158 {2159 inputObject = that.host.children('input');2160 input = inputObject[0];2161 }2162 firstLabel.style.cursor = 'text';2163 lastLabel.style.cursor = 'text';2164 that.addHandler($(firstLabel), 'dblclick.jqxGauge' + that.element.id, function (event)2165 {2166 handleDblclick(this, that.min);2167 that._editedProperty = 'min';2168 });2169 that.addHandler($(lastLabel), 'dblclick.jqxGauge' + that.element.id, function (event)2170 {2171 handleDblclick(this, that.max);2172 that._editedProperty = 'max';2173 });2174 var numericRegExp = /^-?\d+\.?\d*$/;2175 function updateExtreme(value, name, nameInt64, otherName)2176 {2177 if (value === that[name].toString())2178 {2179 return false;2180 }2181 if (that.int64 === 's')2182 {2183 var valueInt64S = new $.jqx.math().fromString(value, 10);2184 if ((name === 'min' && valueInt64S.compare(that['_' + otherName + '64']) !== -1) || (name === 'max' && valueInt64S.compare(that['_' + otherName + '64']) !== 1))2185 {2186 return false;2187 }2188 that[nameInt64] = valueInt64S;2189 that[name] = value;2190 } else if (that.int64 === 'u')2191 {2192 var valueInt64U = new BigNumber(value);2193 if (valueInt64U.compare(0) === -1 || (name === 'min' && valueInt64U.compare(that['_' + otherName + '64']) !== -1) || (name === 'max' && valueInt64U.compare(that['_' + otherName + '64']) !== 1))2194 {2195 return false;2196 }2197 that[nameInt64] = valueInt64U;2198 that[name] = value;2199 } else2200 {2201 if ((name === 'min' && value >= that[otherName]) || (name === 'max' && value <= that[otherName]))2202 {2203 return false;2204 }2205 that[name] = parseFloat(value);2206 }2207 }2208 if (skipInputCreation !== true)2209 {2210 that.addHandler(inputObject, 'blur.jqxGauge' + that.element.id, function (event)2211 {2212 var value = this.value,2213 valid;2214 input.style.visibility = 'hidden';2215 if (!numericRegExp.test(value))2216 {2217 return;2218 }2219 if (that._editedProperty === 'min')2220 {2221 valid = updateExtreme(value, 'min', '_min64', 'max');2222 if (valid === false)2223 {2224 return;2225 }2226 $.jqx.aria(that, 'aria-valuemin', value);2227 } else2228 {2229 valid = updateExtreme(value, 'max', '_max64', 'min');2230 if (valid === false)2231 {2232 return;2233 }2234 $.jqx.aria(that, 'aria-valuemax', value);2235 }2236 that.refresh();2237 if (that.renderer instanceof $.jqx.HTML5Renderer)2238 {2239 that.renderer.refresh();2240 }2241 });2242 }2243 }2244 }2245 },2246 // LinearGauge's functionality2247 linearGauge = {2248 defineInstance: function ()2249 {2250 var settings =2251 {2252 int64: false,2253 editableLabels: false,2254 value: -50,2255 max: 40,2256 min: -60,2257 width: 100,2258 height: 300,2259 pointer: {},2260 labels: {},2261 animationDuration: 1000,2262 showRanges: {},2263 ticksMajor: { size: '15%', interval: 5 },2264 ticksMinor: { size: '10%', interval: 2.5 },2265 tickMode: 'default', // possible values: 'default', 'tickNumber'2266 niceInterval: false,2267 ranges: [],2268 easing: 'easeOutCubic',2269 colorScheme: 'scheme01',2270 disabled: false,2271 rangesOffset: 0,2272 background: {},2273 ticksPosition: 'both',2274 rangeSize: '5%',2275 scaleStyle: null,2276 ticksOffset: null,2277 scaleLength: '90%',2278 orientation: 'vertical',2279 aria:2280 {2281 "aria-valuenow": { name: "value", type: "number" },2282 "aria-valuemin": { name: "min", type: "number" },2283 "aria-valuemax": { name: "max", type: "number" },2284 "aria-disabled": { name: "disabled", type: "boolean" }2285 },2286 displayTank: false,2287 tankStyle: null,2288 //Used for saving the solid background color when a gradient is used2289 _originalColor: '',2290 _width: null,2291 _height: null,2292 renderer: null2293 };2294 $.extend(true, this, settings);2295 return settings;2296 },2297 createInstance: function ()2298 {2299 $.jqx.aria(this);2300 this.host.css('overflow', 'hidden');2301 this.host.addClass(this.toThemeProperty('jqx-widget'));2302 this.host.append('<input class="jqx-gauge-label-input"/>');2303 var self = this;2304 if (self.int64 === 's')2305 {2306 if (!$.jqx.longInt)2307 {2308 throw new Error('jqxLinearGauge: Missing reference to jqxmath.js');2309 }2310 // enables 64-bit number support2311 $.jqx.longInt(self);2312 self._value64 = new $.jqx.math().fromString(self.value.toString(), 10);2313 self._min64 = new $.jqx.math().fromString(self.min.toString(), 10);2314 self._max64 = new $.jqx.math().fromString(self.max.toString(), 10);2315 } else if (self.int64 === 'u')2316 {2317 try2318 {2319 BigNumber;2320 }2321 catch (err)2322 {2323 throw new Error('jqxLinearGauge: Missing reference to jqxmath.js');2324 }2325 self._value64 = new BigNumber(self.value);2326 self._min64 = new BigNumber(self.min);2327 self._max64 = new BigNumber(self.max);2328 }2329 $.jqx.utilities.resize(this.host, function ()2330 {2331 self.refresh(false, false);2332 });2333 },2334 val: function (value)2335 {2336 if (arguments.length == 0 || typeof (value) == "object")2337 {2338 return this.value;2339 }2340 this.setValue(value, 0);2341 },2342 _initRenderer: function (host)2343 {2344 if (!$.jqx.createRenderer)2345 throw 'Please include a reference to jqxdraw.js';2346 return $.jqx.createRenderer(this, host);2347 },2348 refresh: function (init, applyValue)2349 {2350 var self = this;2351 self._nearLabels = [];2352 self._farLabels = [];2353 if (!self.renderer)2354 {2355 self._isVML = false;2356 self.host.empty();2357 self._initRenderer(self.host);2358 }2359 var renderer = self.renderer;2360 if (!renderer)2361 return;2362 self._validateProperties();2363 self._reset();2364 self._init();2365 self._performLayout();2366 self._render();2367 if (applyValue !== false)2368 {2369 self.setValue(self.value, 1);2370 }2371 if (!init)2372 {2373 var position = self.labels.position;2374 if (position === 'both' || position === 'near')2375 {2376 self._labels = self._nearLabels;2377 self._editableLabels();2378 }2379 if (position === 'both' || position === 'far')2380 {2381 self._labels = self._farLabels;2382 self._editableLabels(position === 'both' ? true : undefined);2383 }2384 }2385 },2386 _getBorderSize: function ()2387 {2388 var def = 1,2389 size;2390 if (this._isVML)2391 {2392 def = 0;2393 }2394 if (this.background)2395 {2396 size = (parseInt(this.background.style['stroke-width'], 10) || def) / 2;2397 if (this._isVML)2398 {2399 return Math.round(size);2400 }2401 return size;2402 }2403 return def;2404 },2405 _validateProperties: function ()2406 {2407 this.background = this._backgroundConstructor(this.background, this);2408 this.ticksOffset = this.ticksOffset || this._getDefaultTicksOffset();2409 this.rangesOffset = this.rangesOffset || 0;2410 this.rangeSize = this._validatePercentage(this.rangeSize, 5);2411 this.ticksOffset[0] = this._validatePercentage(this.ticksOffset[0], '5%');2412 this.ticksOffset[1] = this._validatePercentage(this.ticksOffset[1], '5%');2413 this.ticksMinor = this._tickConstructor(this.ticksMinor, this);2414 this.ticksMajor = this._tickConstructor(this.ticksMajor, this);2415 this.scaleStyle = this.scaleStyle || this.ticksMajor.style;2416 this.labels = this._labelsConstructor(this.labels, this);2417 this.pointer = this._pointerConstructor(this.pointer, this);2418 for (var i = 0; i < this.ranges.length; i += 1)2419 {2420 this.ranges[i] = this._rangeConstructor(this.ranges[i], this);2421 }2422 },2423 _getDefaultTicksOffset: function ()2424 {2425 if (this.orientation === 'horizontal')2426 {2427 return ['5%', '36%'];2428 }2429 return ['36%', '5%'];2430 },2431 _handleOrientation: function ()2432 {2433 if (this.orientation === 'vertical')2434 {2435 $.extend(this, linearVerticalGauge);2436 } else2437 {2438 $.extend(this, linearHorizontalGauge);2439 }2440 },2441 _reset: function ()2442 {2443 this.host.empty();2444 },2445 _performLayout: function ()2446 {2447 var borderStroke = parseInt(this.background.style['stroke-width'], 10) || 1;2448 this._width -= borderStroke;2449 this._height -= borderStroke;2450 this.host.css('padding', borderStroke / 2);2451 },2452 _init: function ()2453 {2454 var border = this._getBorderSize(),2455 chartContainer;2456 this._width = this._getScale(this.width, 'width', this.host.parent()) - 3;2457 this._height = this._getScale(this.height, 'height', this.host.parent()) - 3;2458 this.element.innerHTML = '<div/>';2459 this.host.width(this._width);2460 this.host.height(this._height);2461 this.host.children().width(this._width);2462 this.host.children().height(this._height);2463 this.renderer.init(this.host.children());2464 chartContainer = this.renderer.getContainer();2465 chartContainer.width(this._width);2466 chartContainer.height(this._height);2467 },2468 _render: function ()2469 {2470 this._renderBackground();2471 this._renderTicks();2472 if (!this.niceInterval)2473 {2474 this._renderLabels();2475 }2476 this._styleLabels();2477 this._renderRanges();2478 this._renderPointer();2479 },2480 _renderBackground: function ()2481 {2482 if (!this.background.visible)2483 {2484 return;2485 }2486 var options = this.background.style,2487 border = $.jqx._rup(this._getBorderSize()),2488 shape = 'rect',2489 rect;2490 options = this._handleShapeOptions(options);2491 if (this.background.backgroundType === 'roundedRectangle' && this._isVML)2492 {2493 shape = 'roundrect';2494 }2495 if (!this._Vml)2496 {2497 options.x = border;2498 options.y = border;2499 }2500 rect = this.renderer.shape(shape, options);2501 if (this._isVML)2502 {2503 this._fixVmlRoundrect(rect, options);2504 }2505 },2506 _handleShapeOptions: function (options)2507 {2508 var color = this.background.style.fill,2509 border = this._getBorderSize();2510 if (!color)2511 {2512 color = '#cccccc';2513 }2514 if (this.background.showGradient)2515 {2516 if (color.indexOf('url') < 0 && color.indexOf('#grd') < 0)2517 {2518 this._originalColor = color;2519 } else2520 {2521 color = this._originalColor;2522 }2523 color = this.renderer._toLinearGradient(color, this.orientation === 'horizontal', [[1, 1.1], [90, 1.5]]);2524 }2525 this.background.style.fill = color;2526 if (this.background.backgroundType === 'roundedRectangle')2527 {2528 if (this._isVML)2529 {2530 options.arcsize = this.background.borderRadius + '%';2531 } else2532 {2533 options.rx = this.background.borderRadius;2534 options.ry = this.background.borderRadius;2535 }2536 }2537 options.width = this._width - 1;2538 options.height = this._height - 1;2539 return options;2540 },2541 _fixVmlRoundrect: function (rect, options)2542 {2543 var border = this._getBorderSize();2544 rect.style.position = 'absolute';2545 rect.style.left = border;2546 rect.style.top = border;2547 rect.style.width = this._width - 1;2548 rect.style.height = this._height - 1;2549 rect.strokeweight = 0;2550 delete options.width;2551 delete options.height;2552 delete options.arcsize;2553 this.renderer.attr(rect, options);2554 },2555 _renderTicks: function ()2556 {2557 var minor = this.ticksMinor,2558 major = this.ticksMajor,2559 distance, majorInterval, minorInterval, majorCount, minorCount, majorOptions, minorOptions;2560 if (this.int64 === 's')2561 {2562 distance = this._max64.subtract(this._min64);2563 if (distance.isNegative())2564 {2565 distance = distance.negate();2566 }2567 if (this.tickMode === 'default')2568 {2569 if (this.niceInterval)2570 {2571 majorInterval = this._getNiceInterval('linear');2572 minorInterval = this._getNiceInterval('linear', true);2573 } else2574 {2575 majorInterval = major._interval64;2576 minorInterval = minor._interval64;2577 }2578 } else2579 {2580 majorInterval = distance.div(new $.jqx.math().fromNumber(major.number));2581 minorInterval = distance.div(new $.jqx.math().fromNumber(minor.number));2582 }2583 } else if (this.int64 === 'u')2584 {2585 distance = this._max64.subtract(this._min64).abs();2586 if (this.tickMode === 'default')2587 {2588 if (this.niceInterval)2589 {2590 majorInterval = this._getNiceInterval('linear');2591 minorInterval = this._getNiceInterval('linear', true);2592 } else2593 {2594 majorInterval = major._interval64;2595 minorInterval = minor._interval64;2596 }2597 } else2598 {2599 majorInterval = distance.divide(new BigNumber(major.number));2600 minorInterval = distance.divide(new BigNumber(minor.number));2601 }2602 } else2603 {2604 distance = Math.abs(this.max - this.min);2605 if (this.tickMode === 'default')2606 {2607 if (this.niceInterval)2608 {2609 majorInterval = this._getNiceInterval('linear');2610 minorInterval = this._getNiceInterval('linear', true);2611 } else2612 {2613 majorInterval = major.interval;2614 minorInterval = minor.interval;2615 }2616 } else2617 {2618 majorInterval = distance / major.number;2619 minorInterval = distance / minor.number;2620 }2621 }2622 majorOptions = { size: this._getSize(major.size), style: major.style, visible: major.visible, interval: majorInterval, type: 'major' };2623 minorOptions = { size: this._getSize(minor.size), style: minor.style, visible: minor.visible, interval: minorInterval, checkOverlap: true, type: 'minor' };2624 if (this.ticksPosition === 'near' || this.ticksPosition === 'both')2625 {2626 this._ticksRenderHandler(majorOptions);2627 this._ticksRenderHandler(minorOptions);2628 }2629 if (this.ticksPosition === 'far' || this.ticksPosition === 'both')2630 {2631 majorOptions.isFar = true;2632 minorOptions.isFar = true;2633 this._ticksRenderHandler(majorOptions);2634 this._ticksRenderHandler(minorOptions);2635 }2636 this._renderConnectionLine();2637 },2638 _ticksRenderHandler: function (options)2639 {2640 if (!options.visible && options.type === 'minor')2641 {2642 return;2643 }2644 var offsetLeft = this._getSize(this.ticksOffset[0], 'width'),2645 offsetTop = this._getSize(this.ticksOffset[1], 'height'),2646 border = this._getBorderSize(),2647 inactiveOffset = this._calculateTickOffset() + this._getMaxTickSize();2648 if (options.isFar)2649 {2650 inactiveOffset += options.size;2651 }2652 this._drawTicks(options, border, inactiveOffset + border);2653 },2654 _drawTicks: function (options, border, inactiveOffset)2655 {2656 var self = this,2657 interval = options.interval,2658 position,2659 dimension = self.orientation === 'vertical' ? 'width' : 'height',2660 counterDimension = self.orientation === 'vertical' ? 'height' : 'width',2661 maxLabelSize = self._getMaxLabelSize()[dimension],2662 maxLabelCounterDimension = self._getMaxLabelSize()[counterDimension],2663 majorInterval = self._getInterval('ticksMajor'),2664 minorInterval = self._getInterval('ticksMinor');2665 function loop(i)2666 {2667 position = self._valueToCoordinates(i);2668 if (!options.checkOverlap || !self._overlapTick(i, majorInterval, minorInterval))2669 {2670 if (options.visible)2671 {2672 self._renderTick(options.size, position, options.style, inactiveOffset);2673 }2674 if (self.niceInterval && self.labels.visible)2675 {2676 var dimension, counterDimension, distance;2677 if (self.orientation === 'vertical')2678 {2679 distance = self._getSize(self.ticksOffset[1], 'height');2680 } else2681 {2682 distance = self._getSize(self.ticksOffset[0], 'width');2683 }2684 distance += border;2685 var side = options.isFar ? 'far' : 'near',2686 offset;2687 if (side === 'near')2688 {2689 offset = self._calculateTickOffset() - maxLabelSize + border + self._getSize(self.labels.offset);2690 } else2691 {2692 offset = self._calculateTickOffset() + 2 * self._getMaxTickSize() + maxLabelSize + border + self._getSize(self.labels.offset);2693 }2694 if (self.int64 === false)2695 {2696 if (i !== self.min && Math.abs(self._valueToCoordinates(self.min) - position) < maxLabelCounterDimension)2697 {2698 return;2699 }2700 if (i !== self.max && Math.abs(self._valueToCoordinates(self.max) - position) < maxLabelCounterDimension)2701 {2702 return;2703 }2704 } else if (self.int64 === 's')2705 {2706 if (i.equals(self._min64) === false && Math.abs(self._valueToCoordinates(self._min64) - position) < maxLabelCounterDimension)2707 {2708 return false;2709 }2710 if (i.equals(self._max64) === false && Math.abs(self._valueToCoordinates(self._max64) - position) < maxLabelCounterDimension)2711 {2712 return;2713 }2714 } else if (self.int64 === 'u')2715 {2716 if (i.compare(self._min64) !== 0 && Math.abs(self._valueToCoordinates(self._min64) - position) < maxLabelCounterDimension)2717 {2718 return false;2719 }2720 if (i.compare(self._max64) !== 0 && Math.abs(self._valueToCoordinates(self._max64) - position) < maxLabelCounterDimension)2721 {2722 return;2723 }2724 }2725 var labelsPosition = self.labels.position;2726 if (options.type === 'major' && (labelsPosition === 'both' || labelsPosition === 'near' && options.isFar !== true || labelsPosition === 'far' && options.isFar))2727 {2728 self._renderLabel(position, side, offset, maxLabelSize, i);2729 }2730 }2731 }2732 }2733 if (self.niceInterval)2734 {2735 var second;2736 if (self.int64 === 's')2737 {2738 loop(self._min64);2739 second = self._min64.subtract(self._min64.modulo(interval)).add(interval);2740 if (options.type === 'minor')2741 {2742 for (var a = second; a.greaterThanOrEqual(self._min64) ; a = a.subtract(interval))2743 {2744 second = a;2745 }2746 }2747 for (var i = second; i.lessThan(self._max64) ; i = i.add(interval))2748 {2749 if (self._checkForOverflow(i, interval))2750 {2751 break;2752 }2753 loop(i);2754 }2755 loop(self._max64);2756 } else if (self.int64 === 'u')2757 {2758 loop(self._min64);2759 second = self._min64.subtract(self._min64.mod(interval)).add(interval);2760 if (options.type === 'minor')2761 {2762 for (var a = second; a.compare(self._min64) !== -1; a = a.subtract(interval))2763 {2764 second = a;2765 }2766 }2767 for (var i = second; i.compare(self._max64) === -1; i = i.add(interval))2768 {2769 loop(i);2770 }2771 loop(self._max64);2772 } else2773 {2774 loop(self.min);2775 second = self.min - (self.min % interval) + interval;2776 if (options.type === 'minor')2777 {2778 for (var a = second; a >= self.min; a = a - interval)2779 {2780 second = a;2781 }2782 }2783 for (var i = second; i <= self.max; i += interval)2784 {2785 loop(i);2786 }2787 loop(self.max);2788 }2789 } else2790 {2791 if (self.int64 === 's')2792 {2793 for (var i = new $.jqx.math().fromString(self._min64.toString(), 10) ; i.lessThanOrEqual(self._max64) ; i = i.add(interval))2794 {2795 loop(i);2796 }2797 } else if (self.int64 === 'u')2798 {2799 for (var i = new BigNumber(self._min64) ; i.compare(self._max64) !== 1; i = i.add(interval))2800 {2801 loop(i);2802 }2803 } else2804 {2805 for (var i = self.min; i <= self.max; i += interval)2806 {2807 loop(i);2808 }2809 }2810 }2811 },2812 _calculateTickOffset: function ()2813 {2814 var offsetLeft = this._getSize(this.ticksOffset[0], 'width'),2815 offsetTop = this._getSize(this.ticksOffset[1], 'height'),2816 offset = offsetTop;2817 if (this.orientation === 'vertical')2818 {2819 offset = offsetLeft;2820 }2821 return offset;2822 },2823 _getInterval: function (object)2824 {2825 var that = this,2826 interval;2827 if (that.tickMode === 'default')2828 {2829 if (that.niceInterval === true)2830 {2831 interval = that._getNiceInterval('linear', object === 'ticksMinor');2832 } else2833 {2834 if (that.int64 !== false)2835 {2836 interval = that[object]._interval64;2837 } else2838 {2839 interval = that[object].interval;2840 }2841 }2842 } else2843 {2844 var count = that[object].number,2845 range;2846 if (that.int64 !== false)2847 {2848 range = that._max64.subtract(that._min64);2849 if (that.int64 === 's')2850 {2851 interval = range.div(new $.jqx.math().fromNumber(count));2852 } else2853 {2854 interval = range.divide(new BigNumber(count));2855 }2856 } else2857 {2858 range = that.max - that.min;2859 interval = range / that[object].number;2860 }2861 }2862 return interval;2863 },2864 _overlapTick: function (value, majorInterval, minorInterval)2865 {2866 if (this.int64 === 's')2867 {2868 value = value.add(this._min64);2869 if ((value.modulo(minorInterval)).equals(value.modulo(majorInterval)))2870 {2871 return true;2872 } else2873 {2874 return false;2875 }2876 } else if (this.int64 === 'u')2877 {2878 value = value.add(this._min64);2879 if ((value.mod(minorInterval)).compare(value.mod(majorInterval)) === 0)2880 {2881 return true;2882 } else2883 {2884 return false;2885 }2886 } else2887 {2888 value += this.min;2889 if (value % minorInterval === value % majorInterval)2890 {2891 return true;2892 }2893 return false;2894 }2895 },2896 _renderConnectionLine: function ()2897 {2898 if (!this.ticksMajor.visible && !this.ticksMinor.visible)2899 {2900 return;2901 }2902 var scaleLength = this._getScaleLength(),2903 border = this._getBorderSize(),2904 maxPosition,2905 minPosition,2906 maxSize = this._getMaxTickSize(),2907 offset = maxSize + border;2908 if (this.int64 !== false)2909 {2910 maxPosition = this._valueToCoordinates(this._max64)2911 minPosition = this._valueToCoordinates(this._min64);2912 } else2913 {2914 maxPosition = this._valueToCoordinates(this.max);2915 minPosition = this._valueToCoordinates(this.min);2916 }2917 if (this.orientation === 'vertical')2918 {2919 offset += this._getSize(this.ticksOffset[0], 'width');2920 this.renderer.line(offset, maxPosition, offset, minPosition, this.scaleStyle);2921 } else2922 {2923 offset += this._getSize(this.ticksOffset[1], 'height');2924 var end = this._getSize(this.ticksOffset[0], 'width');2925 this.renderer.line(end + maxPosition - minPosition, offset, end, offset, this.scaleStyle);2926 }2927 },2928 _getScaleLength: function ()2929 {2930 return this._getSize(this.scaleLength, (this.orientation === 'vertical' ? 'height' : 'width'));2931 },2932 _renderTick: function (size, distance, style, offset)2933 {2934 var coordinates = this._handleTickCoordinates(size, distance, offset);2935 this.renderer.line(Math.round(coordinates.x1), Math.round(coordinates.y1), Math.round(coordinates.x2), Math.round(coordinates.y2), style);2936 },2937 _handleTickCoordinates: function (size, distance, offset)2938 {2939 if (this.orientation === 'vertical')2940 {2941 return {2942 x1: offset - size,2943 x2: offset,2944 y1: distance,2945 y2: distance2946 };2947 }2948 return {2949 x1: distance,2950 x2: distance,2951 y1: offset - size,2952 y2: offset2953 };2954 },2955 _getTickCoordinates: function (tickSize, offset)2956 {2957 var ticksCoordinates = this._handleTickCoordinates(tickSize, 0, this._calculateTickOffset());2958 if (this.orientation === 'vertical')2959 {2960 ticksCoordinates = ticksCoordinates.x1;2961 } else2962 {2963 ticksCoordinates = ticksCoordinates.y1;2964 }2965 ticksCoordinates += tickSize;2966 return ticksCoordinates;2967 },2968 _renderLabels: function ()2969 {2970 if (!this.labels.visible)2971 {2972 return;2973 }2974 var startPosition = this._getSize(this.ticksOffset[0], 'width'),2975 tickSize = this._getMaxTickSize(),2976 labelsPosition = this.labels.position,2977 dimension = 'height',2978 border = this._getBorderSize(),2979 ticksCoordinates = this._calculateTickOffset() + tickSize,2980 maxLabelSize;2981 if (this.orientation === 'vertical')2982 {2983 startPosition = this._getSize(this.ticksOffset[1], 'height');2984 dimension = 'width';2985 }2986 maxLabelSize = this._getMaxLabelSize()[dimension];2987 if (labelsPosition === 'near' || labelsPosition === 'both')2988 {2989 this._labelListRender(ticksCoordinates - tickSize - maxLabelSize + border, startPosition + border, maxLabelSize, 'near');2990 }2991 if (labelsPosition === 'far' || labelsPosition === 'both')2992 {2993 this._labelListRender(ticksCoordinates + tickSize + maxLabelSize + border, startPosition + border, maxLabelSize, 'far');2994 }2995 },2996 _labelListRender: function (offset, distance, maxLabelSize, position)2997 {2998 var interval, count, step, currentValue, range, number,2999 length = this._getScaleLength();3000 offset += this._getSize(this.labels.offset);3001 if (this.int64 !== false)3002 {3003 range = this._max64.subtract(this._min64)3004 if (this.tickMode === 'default')3005 {3006 interval = this.labels._interval64;3007 if (this.int64 === 's')3008 {3009 count = range.div(interval).toNumber();3010 } else3011 {3012 count = parseFloat((range).divide(interval).toString());3013 }3014 } else3015 {3016 count = this.labels.number;3017 if (this.int64 === 's')3018 {3019 interval = range.div(new $.jqx.math().fromNumber(count));3020 } else3021 {3022 interval = range.divide(count);3023 }3024 }3025 currentValue = (this.orientation === 'vertical') ? this._max64 : this._min64;3026 } else3027 {3028 range = Math.abs(this.max - this.min);3029 if (this.tickMode === 'default')3030 {3031 interval = this.labels.interval;3032 count = range / interval;3033 } else3034 {3035 count = this.labels.number;3036 interval = range / count;3037 }3038 currentValue = (this.orientation === 'vertical') ? this.max : this.min;3039 }3040 step = length / count;3041 for (var i = 0; i <= count; i += 1)3042 {3043 this._renderLabel(distance, position, offset, maxLabelSize, currentValue);3044 if (this.int64 !== false)3045 {3046 currentValue = (this.orientation === 'vertical') ? currentValue.subtract(interval) : currentValue.add(interval);3047 } else3048 {3049 currentValue += (this.orientation === 'vertical') ? -interval : interval;3050 }3051 distance += step;3052 }3053 },3054 _renderLabel: function (distance, position, offset, maxLabelSize, currentValue)3055 {3056 var that = this,3057 labelSettings = that.labels,3058 param = { 'class': this.toThemeProperty('jqx-gauge-label') },3059 interval = this.labels.interval,3060 widthDiff, textSize, formatedValue, currentLabel;3061 var style = '';3062 if (labelSettings.fontSize)3063 {3064 style += 'font-size: ' + labelSettings.fontSize + ';';3065 }3066 if (labelSettings.fontFamily)3067 {3068 style += 'font-family: ' + labelSettings.fontFamily;3069 }3070 if (labelSettings.fontWeight)3071 {3072 style += 'font-weight: ' + labelSettings.fontWeight;3073 }3074 if (labelSettings.fontStyle)3075 {3076 style += 'font-style: ' + labelSettings.fontStyle;3077 }3078 if (style !== '')3079 {3080 param.style = style;3081 }3082 formatedValue = this._formatLabel(currentValue.toString(), position);3083 textSize = this.renderer.measureText(formatedValue, 0, param);3084 if (this.orientation === 'vertical')3085 {3086 widthDiff = (position === 'near') ? maxLabelSize - textSize.width : 0;3087 currentLabel = this.renderer.text(formatedValue, Math.round(offset) + widthDiff - maxLabelSize / 2,3088 Math.round(distance - textSize.height / 2), textSize.width, textSize.height, 0, param);3089 } else3090 {3091 widthDiff = (position === 'near') ? maxLabelSize - textSize.height : 0;3092 currentLabel = this.renderer.text(formatedValue, Math.round(distance - textSize.width / 2),3093 Math.round(offset) + widthDiff - maxLabelSize / 2, textSize.width, textSize.height, 0, param);3094 }3095 if (position === 'near')3096 {3097 if (this.niceInterval || this.orientation === 'horizontal')3098 {3099 this._nearLabels.push(currentLabel);3100 } else3101 {3102 this._nearLabels.unshift(currentLabel);3103 }3104 } else3105 {3106 if (this.niceInterval || this.orientation === 'horizontal')3107 {3108 this._farLabels.push(currentLabel);3109 } else3110 {3111 this._farLabels.unshift(currentLabel);3112 }3113 }3114 },3115 _renderRanges: function ()3116 {3117 if (!this.showRanges)3118 {3119 return;3120 }3121 var dim = (this.orientation === 'vertical') ? 'width' : 'height',3122 offset = this._getSize(this.rangesOffset, dim),3123 size = this._getSize(this.rangeSize, dim),3124 options;3125 for (var i = 0; i < this.ranges.length; i += 1)3126 {3127 options = this.ranges[i];3128 options.size = size;3129 this._renderRange(options, offset);3130 }3131 },3132 _renderRange: function (options, offset)3133 {3134 var scaleLength = this._getScaleLength(),3135 border = this._getBorderSize(),3136 offsetLeft = this._getSize(this.ticksOffset[0], 'width'),3137 offsetTop = this._getSize(this.ticksOffset[1], 'height'),3138 maxSize = this._getMaxTickSize(),3139 size = this._getSize(options.size),3140 top, startValue;3141 if (this.int64 !== false)3142 {3143 top = this._valueToCoordinates(options._endValue64);3144 startValue = options._startValue64;3145 if (this.int64 === 's' && startValue.lessThan(this._min64))3146 {3147 startValue = new $.jqx.math().fromString(this._min64.toString(), 10);3148 } else if (this.int64 === 'u' && startValue.compare(this._min64) === -1)3149 {3150 startValue = new BigNumber(this._min64);3151 }3152 } else3153 {3154 top = this._valueToCoordinates(options.endValue);3155 startValue = options.startValue;3156 if (startValue < this.min) startValue = this.min;3157 }3158 var height = Math.abs(this._valueToCoordinates(startValue) - top),3159 rect, width;3160 if (this.orientation === 'vertical')3161 {3162 rect = this.renderer.rect(offsetLeft + maxSize + offset - size + border, top, options.size, height, options.style);3163 } else3164 {3165 width = height;3166 rect = this.renderer.rect(this._valueToCoordinates(startValue), offsetTop + maxSize + border, width, options.size, options.style);3167 }3168 this.renderer.attr(rect, options.style);3169 },3170 _renderPointer: function ()3171 {3172 if (!this.pointer.visible)3173 {3174 return;3175 }3176 if (this.pointer.pointerType === 'default')3177 {3178 this._renderColumnPointer();3179 } else3180 {3181 this._renderArrowPointer();3182 }3183 },3184 _renderColumnPointer: function ()3185 {3186 if (this.displayTank)3187 {3188 var tankStyle = { fill: '#FFFFFF' };3189 tankStyle['fill-opacity'] = 0;3190 if (this.tankStyle)3191 {3192 tankStyle.stroke = this.tankStyle.stroke;3193 tankStyle['stroke-width'] = this.tankStyle.strokeWidth;3194 } else3195 {3196 tankStyle.stroke = '#A1A1A1';3197 tankStyle['stroke-width'] = '1px';3198 }3199 this._tank = this.renderer.rect(0, 0, 0, 0, tankStyle);3200 this._performTankLayout();3201 }3202 this._pointer = this.renderer.rect(0, 0, 0, 0, this.pointer.style);3203 this.renderer.attr(this._pointer, this.pointer.style);3204 if (this.int64 !== false)3205 {3206 this._setValue(this._value64);3207 } else3208 {3209 this._setValue(this.value);3210 }3211 },3212 _performTankLayout: function ()3213 {3214 var bottom, left, height,3215 top = this._valueToCoordinates(),3216 border = this._getBorderSize(),3217 offsetLeft = this._getSize(this.ticksOffset[0], 'width'),3218 offsetTop = this._getSize(this.ticksOffset[1], 'height'),3219 maxSize = this._getMaxTickSize(),3220 width = this._getSize(this.pointer.size),3221 offset = this._getSize(this.pointer.offset),3222 attrs = {};3223 if (this.int64 !== false)3224 {3225 top = this._valueToCoordinates(this._max64);3226 bottom = this._valueToCoordinates(this._min64);3227 } else3228 {3229 top = this._valueToCoordinates(this.max);3230 bottom = this._valueToCoordinates(this.min);3231 }3232 height = Math.abs(bottom - top);3233 if (this.orientation === 'vertical')3234 {3235 left = offsetLeft + maxSize;3236 attrs = { left: left + offset + 1 + border, top: top, height: height, width: width };3237 } else3238 {3239 left = offsetTop + maxSize;3240 attrs = { left: bottom, top: left + offset - width - 1 + border, height: width, width: height };3241 }3242 if (!this._isVML)3243 {3244 this.renderer.attr(this._tank, { x: attrs.left });3245 this.renderer.attr(this._tank, { y: attrs.top });3246 this.renderer.attr(this._tank, { width: attrs.width });3247 this.renderer.attr(this._tank, { height: attrs.height });3248 } else3249 {3250 this._tank.style.top = attrs.top;3251 this._tank.style.left = attrs.left;3252 this._tank.style.width = attrs.width;3253 this._tank.style.height = attrs.height;3254 }3255 },3256 _renderArrowPointer: function ()3257 {3258 var path = this._getArrowPathByValue(0);3259 this._pointer = this.renderer.path(path, this.pointer.style);3260 },3261 _renderArrowPointerByValue: function (value)3262 {3263 var path = this._getArrowPathByValue(value);3264 this._pointer = this.renderer.path(path, this.pointer.style);3265 },3266 _getArrowPathByValue: function (value)3267 {3268 var border = this._getBorderSize(),3269 top = Math.ceil(this._valueToCoordinates(value)) + border,3270 left = border,3271 offsetLeft = Math.ceil(this._getSize(this.ticksOffset[0], 'width')),3272 offsetTop = Math.ceil(this._getSize(this.ticksOffset[1], 'height')),3273 offset = Math.ceil(this._getSize(this.pointer.offset)),3274 maxSize = Math.ceil(this._getMaxTickSize()),3275 size = Math.ceil(this._getSize(this.pointer.size)),3276 side = Math.ceil(Math.sqrt((size * size) / 3)),3277 path, topProjection, temp;3278 if (this.orientation === 'vertical')3279 {3280 left += offsetLeft + maxSize + offset;3281 topProjection = (offset >= 0) ? left + size : left - size;3282 path = 'M ' + left + ' ' + top + ' L ' + topProjection + ' ' + (top - side) + ' L ' + topProjection + ' ' + (top + side);3283 } else3284 {3285 var maxLabelSize = this._getMaxLabelSize()["height"];3286 left += offsetLeft + maxSize + offset + maxLabelSize;3287 if (this._isVML)3288 {3289 left -= 2;3290 }3291 temp = top;3292 top = left;3293 left = temp;3294 topProjection = top - size;3295 path = 'M ' + left + ' ' + top + ' L ' + (left - side) + ' ' + topProjection + ' L ' + (left + side) + ' ' + topProjection;3296 }3297 return path;3298 },3299 _setValue: function (val)3300 {3301 if (this.pointer.pointerType === 'default')3302 {3303 this._performColumnPointerLayout(val);3304 } else3305 {3306 this._performArrowPointerLayout(val);3307 }3308 this.value = val;3309 },3310 _performColumnPointerLayout: function (val)3311 {3312 var bottom, left, height,3313 top = this._valueToCoordinates(val),3314 border = this._getBorderSize(),3315 offsetLeft = this._getSize(this.ticksOffset[0], 'width'),3316 offsetTop = this._getSize(this.ticksOffset[1], 'height'),3317 maxSize = this._getMaxTickSize(),3318 width = this._getSize(this.pointer.size),3319 offset = this._getSize(this.pointer.offset),3320 attrs = {};3321 if (this.int64 !== false)3322 {3323 bottom = this._valueToCoordinates(this._min64);3324 } else3325 {3326 bottom = this._valueToCoordinates(this.min);3327 }3328 height = Math.abs(bottom - top);3329 if (this.orientation === 'vertical')3330 {3331 left = offsetLeft + maxSize;3332 attrs = { left: left + offset + 1 + border, top: top, height: height, width: width };3333 } else3334 {3335 left = offsetTop + maxSize;3336 attrs = { left: bottom, top: left + offset - width - 1 + border, height: width, width: height };3337 }3338 this._setRectAttrs(attrs);3339 },3340 _performArrowPointerLayout: function (val)3341 {3342 var attr = this._getArrowPathByValue(val);3343 if (this._isVML)3344 {3345 if (this._pointer)3346 {3347 $(this._pointer).remove();3348 }3349 this._renderArrowPointerByValue(val);3350 } else3351 {3352 this.renderer.attr(this._pointer, { d: attr });3353 }3354 },3355 _setRectAttrs: function (attrs)3356 {3357 if (!this._isVML)3358 {3359 this.renderer.attr(this._pointer, { x: attrs.left });3360 this.renderer.attr(this._pointer, { y: attrs.top });3361 this.renderer.attr(this._pointer, { width: attrs.width });3362 this.renderer.attr(this._pointer, { height: attrs.height });3363 } else3364 {3365 this._pointer.style.top = attrs.top;3366 this._pointer.style.left = attrs.left;3367 this._pointer.style.width = attrs.width;3368 this._pointer.style.height = attrs.height;3369 }3370 },3371 _valueToCoordinates: function (value)3372 {3373 var border = this._getBorderSize(),3374 scaleLength = this._getScaleLength(),3375 offsetLeft = this._getSize(this.ticksOffset[0], 'width'),3376 offsetTop = this._getSize(this.ticksOffset[1], 'height'),3377 current,3378 distance,3379 length;3380 if (this.int64 !== false)3381 {3382 current = value.subtract(this._min64);3383 distance = this._max64.subtract(this._min64);3384 if (this.int64 === 's')3385 {3386 if (current.isNegative())3387 {3388 current.negate();3389 }3390 if (distance.isNegative())3391 {3392 distance.negate();3393 }3394 } else3395 {3396 current = current.intPart().abs();3397 distance = distance.abs();3398 }3399 var currentString = current.toString(),3400 distanceString = distance.toString(),3401 currentFloat, distanceFloat;3402 if (distanceString.length > 15)3403 {3404 var floatOffset = distanceString.length - 15;3405 distanceString = distanceString.slice(0, 15) + '.' + distanceString.slice(15);3406 distanceFloat = parseFloat(distanceString);3407 if (currentString.length > floatOffset)3408 {3409 var currentOffset = currentString.length - floatOffset;3410 currentString = currentString.slice(0, currentOffset) + '.' + currentString.slice(currentOffset);3411 } else if (currentString.length === floatOffset)3412 {3413 currentString = '0.' + currentString;3414 } else3415 {3416 var prefix = '0.';3417 for (var i = 0; i < floatOffset - currentString.length; i++)3418 {3419 prefix += '0';3420 }3421 currentString = prefix + '' + currentString;3422 }3423 currentFloat = parseFloat(currentString);3424 } else3425 {3426 if (this.int64 === 's')3427 {3428 currentFloat = current.toNumber();3429 distanceFloat = distance.toNumber();3430 } else3431 {3432 currentFloat = parseFloat(current.toString());3433 distanceFloat = parseFloat(distance.toString());3434 }3435 }3436 length = (currentFloat / distanceFloat) * scaleLength;3437 } else3438 {3439 current = Math.abs(this.min - value);3440 distance = Math.abs(this.max - this.min);3441 length = (current / distance) * scaleLength;3442 }3443 if (this.orientation === 'vertical')3444 {3445 return this._height - length - (this._height - offsetTop - scaleLength) + border;3446 }3447 return length + offsetLeft;3448 },3449 _getSize: function (size, dim)3450 {3451 dim = dim || (this.orientation === 'vertical' ? 'width' : 'height');3452 if (size.toString().indexOf('%') >= 0)3453 {3454 size = (parseInt(size, 10) / 100) * this['_' + dim];3455 }3456 size = parseInt(size, 10);3457 return size;3458 },3459 propertiesChangedHandler: function (object, key, value)3460 {3461 if (value.width && value.height && Object.keys(value).length == 2)3462 {3463 object.refresh();3464 }3465 },3466 propertyChangedHandler: function (object, key, oldvalue, value)3467 {3468 if (value == oldvalue)3469 return;3470 if (object.batchUpdate && object.batchUpdate.width && object.batchUpdate.height && Object.keys(object.batchUpdate).length == 2)3471 {3472 return;3473 }3474 if (key === 'tankStyle' && object.pointer.pointerType === 'arrow')3475 {3476 return;3477 }3478 if (key == 'min')3479 {3480 if (object.int64 === 's')3481 {3482 object._min64 = new $.jqx.math().fromString(value.toString(), 10);3483 } else if (object.int64 === 'u')3484 {3485 object._min64 = new BigNumber(value);3486 } else3487 {3488 this.min = parseFloat(value);3489 }3490 $.jqx.aria(this, 'aria-valuemin', value);3491 }3492 if (key == 'max')3493 {3494 if (object.int64 === 's')3495 {3496 object._max64 = new $.jqx.math().fromString(value.toString(), 10);3497 } else if (object.int64 === 'u')3498 {3499 object._max64 = new BigNumber(value);3500 } else3501 {3502 this.max = parseFloat(value);3503 }3504 $.jqx.aria(this, 'aria-valuemax', value);3505 }3506 if (key === 'disabled')3507 {3508 if (value)3509 {3510 this.disable();3511 } else3512 {3513 this.enable();3514 }3515 $.jqx.aria(this, 'aria-disabled', value);3516 } else if (key === 'value')3517 {3518 if (this._timeout != undefined)3519 {3520 clearTimeout(this._timeout);3521 this._timeout = null;3522 }3523 this.value = oldvalue;3524 this.setValue(value);3525 } else3526 {3527 if (key === 'colorScheme')3528 {3529 this.pointer.style = null;3530 } else if (key === 'orientation' && oldvalue !== value)3531 {3532 var temp = this.ticksOffset[0];3533 this.ticksOffset[0] = this.ticksOffset[1];3534 this.ticksOffset[1] = temp;3535 }3536 if (key !== 'animationDuration' && key !== 'easing')3537 {3538 this.refresh();3539 }3540 }3541 if (this.renderer instanceof $.jqx.HTML5Renderer)3542 this.renderer.refresh();3543 },3544 //Constructor functions for property validation3545 _backgroundConstructor: function (background, jqx)3546 {3547 if (this.host)3548 {3549 return new this._backgroundConstructor(background, jqx);3550 }3551 var validBackgroundTypes = { rectangle: true, roundedRectangle: true };3552 background = background || {};3553 this.style = background.style || { stroke: '#cccccc', fill: null };3554 if (background.visible || typeof background.visible === 'undefined')3555 {3556 this.visible = true;3557 } else3558 {3559 this.visible = false;3560 }3561 if (validBackgroundTypes[background.backgroundType])3562 {3563 this.backgroundType = background.backgroundType;3564 } else3565 {3566 this.backgroundType = 'roundedRectangle';3567 }3568 if (this.backgroundType === 'roundedRectangle')3569 {3570 if (typeof background.borderRadius === 'number')3571 {3572 this.borderRadius = background.borderRadius;3573 } else3574 {3575 this.borderRadius = 15;3576 }3577 }3578 if (typeof background.showGradient === 'undefined')3579 {3580 this.showGradient = true;3581 } else3582 {3583 this.showGradient = background.showGradient;3584 }3585 },3586 resize: function (width, height)3587 {3588 this.width = width;3589 this.height = height;3590 this.refresh();3591 },3592 _tickConstructor: function (tick, jqx)3593 {3594 if (this.host)3595 {3596 return new this._tickConstructor(tick, jqx);3597 }3598 this.size = jqx._validatePercentage(tick.size, '10%');3599 if (tick.interval)3600 {3601 this.interval = tick.interval;3602 } else3603 {3604 this.interval = 5;3605 }3606 if (jqx.int64 === 's')3607 {3608 this._interval64 = new $.jqx.math().fromString(this.interval.toString(), 10);3609 } else if (jqx.int64 === 'u')3610 {3611 this._interval64 = new BigNumber(this.interval);3612 } else3613 {3614 this.interval = parseFloat(this.interval);3615 }3616 if (tick.number)3617 {3618 this.number = tick.number;3619 } else3620 {3621 this.number = 5;3622 }3623 this.style = tick.style || { stroke: '#A1A1A1', 'stroke-width': '1px' };3624 if (typeof tick.visible === 'undefined')3625 {3626 this.visible = true;3627 } else3628 {3629 this.visible = tick.visible;3630 }3631 },3632 _labelsConstructor: function (label, jqx)3633 {3634 if (this.host)3635 {3636 return new this._labelsConstructor(label, jqx);3637 }3638 this.position = label.position;3639 if (this.position !== 'far' && this.position !== 'near' && this.position !== 'both')3640 {3641 this.position = 'both';3642 }3643 this.formatValue = label.formatValue;3644 this.formatSettings = label.formatSettings;3645 this.visible = label.visible;3646 if (this.visible !== false && this.visible !== true)3647 {3648 this.visible = true;3649 }3650 if (label.interval)3651 {3652 this.interval = label.interval;3653 } else3654 {3655 this.interval = 10;3656 }3657 if (jqx.int64 === 's')3658 {3659 this._interval64 = new $.jqx.math().fromString(this.interval.toString(), 10);3660 } else if (jqx.int64 === 'u')3661 {3662 this._interval64 = new BigNumber(this.interval);3663 } else3664 {3665 this.interval = parseFloat(this.interval);3666 }3667 if (label.number)3668 {3669 this.number = label.number;3670 } else3671 {3672 this.number = 10;3673 }3674 this.fontSize = label.fontSize;3675 this.fontFamily = label.fontFamily;3676 this.fontWeight = label.fontWeight;3677 this.fontStyle = label.fontStyle;3678 this.offset = jqx._validatePercentage(label.offset, 0);3679 },3680 _rangeConstructor: function (range, jqx)3681 {3682 if (this.host)3683 {3684 return new this._rangeConstructor(range, jqx);3685 }3686 if (range.startValue)3687 {3688 this.startValue = range.startValue;3689 } else3690 {3691 this.startValue = jqx.min;3692 }3693 if (range.endValue)3694 {3695 this.endValue = range.endValue;3696 } else3697 {3698 this.endValue = jqx.max;3699 }3700 if (jqx.int64 === 's')3701 {3702 this._startValue64 = new $.jqx.math().fromString(this.startValue.toString(), 10);3703 this._endValue64 = new $.jqx.math().fromString(this.endValue.toString(), 10);3704 if (this._endValue64.lessThanOrEqual(this._startValue64))3705 {3706 this._endValue64 = this._startValue64.add(new $.jqx.math().fromNumber(1, 10));3707 this.endValue = this._endValue64.toString();3708 }3709 } else if (jqx.int64 === 'u')3710 {3711 this._startValue64 = new BigNumber(this.startValue);3712 this._endValue64 = new BigNumber(this.endValue);3713 if (this._endValue64.compare(this._startValue64) !== 1)3714 {3715 this._endValue64 = this._startValue64.add(1);3716 this.endValue = this._endValue64.toString();3717 }3718 } else3719 {3720 this.startValue = parseFloat(this.startValue);3721 this.endValue = parseFloat(this.endValue);3722 if (this.endValue <= this.startValue)3723 {3724 this.endValue = this.startValue + 1;3725 }3726 }3727 this.style = range.style || { fill: '#dddddd', stroke: '#dddddd' };3728 },3729 _pointerConstructor: function (pointer, jqx)3730 {3731 if (this.host)3732 {3733 return new this._pointerConstructor(pointer, jqx);3734 }3735 var color = jqx._getColorScheme(jqx.colorScheme)[0];3736 this.pointerType = pointer.pointerType;3737 if (this.pointerType !== 'default' && this.pointerType !== 'arrow')3738 {3739 this.pointerType = 'default';3740 }3741 this.style = pointer.style || { fill: color, stroke: color, 'stroke-width': 1 };3742 this.size = jqx._validatePercentage(pointer.size, '7%');3743 this.visible = pointer.visible;3744 if (this.visible !== true && this.visible !== false)3745 {3746 this.visible = true;3747 }3748 this.offset = jqx._validatePercentage(pointer.offset, 0);3749 }3750 };3751 //Extending with the common functionality3752 $.extend(radialGauge, common);3753 $.extend(linearGauge, common);3754 //Initializing jqxWidgets3755 $.jqx.jqxWidget("jqxLinearGauge", "", {});3756 $.jqx.jqxWidget("jqxGauge", "", {});3757 //Extending the widgets' prototypes3758 $.extend($.jqx._jqxGauge.prototype, radialGauge);3759 $.extend($.jqx._jqxLinearGauge.prototype, linearGauge);...

Full Screen

Full Screen

dump.js

Source:dump.js Github

copy

Full Screen

1let bitcoin = require('bitcoinjs-lib')2let leveldown = require('leveldown')3let Indexd = require('indexd')4let rpc = require('../rpc')5let { types: scriptTypes } = require('indexd/indexes/script')6let db = leveldown(process.env.INDEXDB)7let indexd = new Indexd(db, rpc)8function debug () {9 if (arguments[0] instanceof Error) console.error.apply(null, arguments)10 else console.log.apply(null, arguments)11}12let MIN64 = '0000000000000000000000000000000000000000000000000000000000000000'13let MAX64 = 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'14db.open({}, (err) => {15 if (err) return debug(err)16 let i = 017 indexd.db.iterator(scriptTypes.data, {18 gte: { scId: MIN64, height: 0, txId: MIN64, vout: 0 },19 lte: { scId: MAX64, height: 0xffffffff, txId: MAX64, vout: 0xffffffff }20 }, (key, value) => {21 let y = i22 indexd.txoByTxo(key, (err, txo) => {23 if (err) return24 let extra = {}25 try {26 extra.address = bitcoin.address.fromOutputScript(txo.script, bitcoin.networks.testnet)27 } catch (e) { extra.asm = bitcoin.script.toASM(txo.script) }28 extra.script = txo.script.toString('hex')29 debug('ST', y, Object.assign(key, value, txo, extra))30 })31 ++i32 }, (err) => {33 if (err) debug(err)34 debug('FIN')35 })...

Full Screen

Full Screen

Math.test.js

Source:Math.test.js Github

copy

Full Screen

...13 });14 it('returns min64 correctly', async function () {15 let a = 5678;16 let b = 1234;17 await math.min64(a, b);18 let result = await math.result64();19 assert.equal(result, b);20 });21 it('returns max256 correctly', async function () {22 let a = 5678;23 let b = 1234;24 await math.max256(a, b);25 let result = await math.result256();26 assert.equal(result, a);27 });28 it('returns min256 correctly', async function () {29 let a = 5678;30 let b = 1234;31 await math.min256(a, b);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require("fast-check");2const min64 = require("fast-check-monorepo").min64;3fc.assert(4 fc.property(fc.integer(), fc.integer(), (a, b) => {5 return min64(a, b) <= Math.min(a, b);6 })7);8const fc = require("fast-check");9const min64 = require("fast-check-monorepo").min64;10fc.assert(11 fc.property(fc.integer(), fc.integer(), (a, b) => {12 return min64(a, b) <= Math.min(a, b);13 })14);15const fc = require("fast-check");16const min64 = require("fast-check-monorepo").min64;17fc.assert(18 fc.property(fc.integer(), fc.integer(), (a, b) => {19 return min64(a, b) <= Math.min(a, b);20 })21);22const fc = require("fast-check");23const min64 = require("fast-check-monorepo").min64;24fc.assert(25 fc.property(fc.integer(), fc.integer(), (a, b) => {26 return min64(a, b) <= Math.min(a, b);27 })28);29const fc = require("fast-check");30const min64 = require("fast-check-monorepo").min64;31fc.assert(32 fc.property(fc.integer(), fc.integer(), (a, b) => {33 return min64(a, b) <= Math.min(a, b);34 })35);36const fc = require("fast-check");37const min64 = require("fast-check-monorepo").min64;38fc.assert(39 fc.property(fc.integer(), fc.integer(), (a, b) => {40 return min64(a, b) <= Math.min(a, b);41 })42);43const fc = require("fast-check");

Full Screen

Using AI Code Generation

copy

Full Screen

1const { min64 } = require('fast-check-monorepo');2console.log(min64(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));3console.log(min64(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11));4const { min64 } = require('fast-check-monorepo');5console.log(min64(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));6console.log(min64(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11));7const { min64 } = require('fast-check-monorepo');8console.log(min64(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));9console.log(min64(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11));10const { min64 } = require('fast-check-monorepo');11console.log(min64(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));12console.log(min64(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11));13const { min64 } = require('fast-check-monorepo');14console.log(min64(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));15console.log(min64(1, 2, 3, 4, 5, 6, 7,

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require("fast-check");2const { min64 } = require("fast-check/lib/check/arbitrary/IntegerArbitrary");3const { integer } = require("fast-check/lib/check/arbitrary/IntegerArbitrary");4const { convertFromNext, convertToNext } = require("fast-check/lib/check/arbitrary/definition/Converters");5const { Random } = require("fast-check/lib/random/generator/Random");6const { Stream } = require("fast-check/lib/stream/Stream");7const { Arbitrary } = require("fast-check/lib/check/arbitrary/definition/Arbitrary");8const { NextValue } = require("fast-check/lib/check/arbitrary/definition/NextValue");9const { NextArbitrary } = require("fast-check/lib/check/arbitrary/definition/NextArbitrary");10const { cloneMethod } = require("fast-check/lib/utils/symbols");11const { cloneMethod$ } = require("fast-check/lib/utils/symbols");12const { cloneMethod$1 } = require("fast-check/lib/utils/symbols");13const { cloneMethod$2 } = require("fast-check/lib/utils/symbols");14const { cloneMethod$3 } = require("fast-check/lib/utils/symbols");15const { cloneMethod$4 } = require("fast-check/lib/utils/symbols");16const { cloneMethod$5 } = require("fast-check/lib/utils/symbols");17const { cloneMethod$6 } = require("fast-check/lib/utils/symbols");18const { cloneMethod$7 } = require("fast-check/lib/utils/symbols");19const { cloneMethod$8 } = require("fast-check/lib/utils/symbols");20const { cloneMethod$9 } = require("fast-check/lib/utils/symbols");21const { cloneMethod$10 } = require("fast-check/lib/utils/symbols");22const { cloneMethod$11 } = require("fast-check/lib/utils/symbols");23const { cloneMethod$12 } = require("fast-check/lib/utils/symbols");24const { cloneMethod$13 } = require("fast-check/lib/utils/symbols");25const { cloneMethod$14 } = require("fast-check/lib/utils/symbols");26const { cloneMethod$15 } = require("fast-check/lib/utils/symbols");27const { cloneMethod$16 } = require("fast-check/lib/utils/symbols");28const { cloneMethod$17 } = require("fast-check/lib/utils/symbols");29const { cloneMethod$18 } = require("fast-check/lib/utils/symbols");

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const min64 = require('fast-check/lib/arbitrary/min64');3const max64 = require('fast-check/lib/arbitrary/max64');4const { min64: min64_2, max64: max64_2 } = require('fast-check/lib/arbitrary/min64');5const { min64: min64_3, max64: max64_3 } = require('fast-check/lib/arbitrary/min64');6fc.assert(7 fc.property(fc.integer(), fc.integer(), (a, b) => {8 console.log('a:', a);9 console.log('b:', b);10 console.log('min64(a, b):', min64(a, b));11 console.log('min64_2(a, b):', min64_2(a, b));12 console.log('min64_3(a, b):', min64_3(a, b));13 console.log('max64(a, b):', max64(a, b));14 console.log('max64_2(a, b):', max64_2(a, b));15 console.log('max64_3(a, b):', max64_3(a, b));16 return true;17 })18);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { check } = require('fast-check')2const { min64 } = require('fast-check-monorepo')3const min64Arb = min64({ min: 0, max: 100 })4console.log(min64Arb)5check(min64Arb, (n) => {6 console.log(n)7})8const { check } = require('fast-check')9const { min64 } = require('fast-check-monorepo')10const min64Arb = min64({ min: 0, max: 100 })11console.log(min64Arb)12check(min64Arb, (n) => {13 console.log(n)14})15const { check } = require('fast-check')16const { min64 } = require('fast-check-monorepo')17const min64Arb = min64({ min: 0, max: 100 })18console.log(min64Arb)19check(min64Arb, (n) => {20 console.log(n)21})22const { check } = require('fast-check')23const { min64 } = require('fast-check-monorepo')24const min64Arb = min64({ min: 0, max: 100 })25console.log(min64Arb)26check(min64Arb, (n) => {27 console.log(n)28})29const { check } = require('fast-check')30const { min64 } = require('fast-check-monorepo')31const min64Arb = min64({ min: 0, max: 100 })32console.log(min64Arb)33check(min64Arb, (n) => {34 console.log(n)35})36const { check } = require('fast-check')37const { min64 } = require('fast-check-monorepo')38const min64Arb = min64({ min: 0,

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const { min64 } = require('fast-check-monorepo');3const { min64: min64_1 } = require('fast-check-monorepo');4console.log(min64([1n, 2n, 3n]));5console.log(min64_1([1n, 2n, 3n]));6const fc = require('fast-check');7const { min64 } = require('fast-check-monorepo');8const { min64: min64_1 } = require('fast-check-monorepo');9console.log(min64([1n, 2n, 3n]));10console.log(min64_1([1n, 2n, 3n]));

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const assert = require('assert');3const min64 = require('fast-check-monorepo').min64;4const max64 = require('fast-check-monorepo').max64;5const test3 = require('./test3');6describe('test3', () => {7 it('should return a 64 bit int', () => {8 fc.assert(9 fc.property(fc.integer(), fc.integer(), (x, y) => {10 const z = test3(x, y);11 assert(min64 <= z && z <= max64);12 })13 );14 });15});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { min64 } = require("fast-check");2const { min64 } = require("./test2.js");3min64(1, 2);4min64(1, 2);5const { min64 } = require("fast-check");6min64(1, 2);7const { min64 } = require("fast-check");8min64(1, 2);9const { min64 } = require("./test2.js");10const { min64 } = require("../test2.js");11const { min64 } = require("../test2");12const { min64 } = require("./test2");13const { min64 } = require("test2.js");14const { min64 } = require("test2");15const { min64 } = require("./test2/index.js");16const { min64 } = require

Full Screen

Using AI Code Generation

copy

Full Screen

1const { check } = require("fast-check");2const { min64 } = require("@fast-check/arbitrary-integer");3const test = check(4 min64(0),5 (i) => i >= 0 && i <= 2 ** 646);7test.then(() => {8 console.log("test passed");9});10const { check } = require("fast-check");11const { min64 } = require("@fast-check/arbitrary-integer");12const test = check(13 min64(0),14 (i) => i >= 0 && i <= 2 ** 6415);16test.then(() => {17 console.log("test passed");18});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful