📄 gauge.ie.js
字号:
_p.setOpacity = function(n){ this._opacity = n; this._stroke.setHtmlProperty("opacity", n);};function BiGaugePlate(oGauge){ BiComponent.call(this); this._gauge = oGauge; this.setZIndex(0); this.setLocation(3, 3); this.setSize(994, 994); this.setStrokeColor("windowtext"); this.setFillColor("window");};var _p = BiGaugePlate.prototype = new BiComponent;_p._className = "BiGaugePlate";_p._tagName = "v:oval";BiGaugePlate.prototype.getGauge = function(){ return this._gauge;} ;_p.layoutComponent = function(){ BiComponent.prototype.layoutComponent.call(this); this._resizeNonScalable();};_p.layoutComponentX = function(){ BiComponent.prototype.layoutComponentX.call(this); this._resizeNonScalable();};_p.layoutComponentY = function(){ BiComponent.prototype.layoutComponentY.call(this); this._resizeNonScalable();};_p._resizeNonScalable = function(){ if (!this.getCreated()) return; var cw = this.getGauge().getClientWidth(); var ch = this.getGauge().getClientHeight(); var s = Math.min(cw, ch); this.setHtmlProperty("strokeweight", s / 200);};BiGaugePlate.prototype.getFillColor = function(){ return this._fillColor;} ;BiGaugePlate.prototype.getStrokeColor = function(){ return this._strokeColor;} ;_p.setFillColor = function(s){ this._fillColor = s; this.setHtmlProperty("fillcolor", s);};_p.setStrokeColor = function(s){ this._strokeColor = s; this.setHtmlProperty("strokecolor", s);};function BiGaugeNeedle(oGauge){ BiComponent.call(this); this._gauge = oGauge; this.setHtmlProperty("coordsize", "1000,1000"); this.setHtmlProperty("coordorigin", "0,0"); this.setLocation(0, 0); this.setSize(1000, 1000); this.setZIndex(3); this._needle = new BiComponent; this._needle._tagName = "v:polyline"; this.add(this._needle); this._knob = new BiComponent; this._knob._tagName = "v:oval"; this._knob.setLocation(460, 460); this._knob.setSize(80, 80); this.add(this._knob); this.setStrokeColor("windowtext"); this.setFillColor("windowtext"); this.setValue(0);};var _p = BiGaugeNeedle.prototype = new BiComponent;_p._className = "BiGaugeNeedle";_p._value = 0;_p.setValue = function(n){ this._value = n; var v = this.getGauge()._valueToAngle(n); var vr = v / 180 * Math.PI var r = 330; var r2 = 20 var p1x = r * Math.sin(vr); var p1y = r * Math.cos(vr); var p2x = r2 * Math.cos(vr); var p2y = -r2 * Math.sin(vr); var p3x = -p2x; var p3y = -p2y; p1x = 500 + p1x; p1y = 500 - p1y; p2x = 500 + p2x; p2y = 500 - p2y; p3x = 500 + p3x; p3y = 500 - p3y; var pointsValue = p3x + "," + p3y + " " + p1x + "," + p1y + " " + p2x + "," + p2y + " " + p3x + "," + p3y; try { this._needle._element.points.value = pointsValue; } catch (ex) { this._needle.setHtmlProperty("points", pointsValue); } this._knob.setLocation(460, 460); this._knob.setSize(80, 80);};BiGaugeNeedle.prototype.getValue = function(){ return this._value;} ;BiGaugeNeedle.prototype.getGauge = function(){ return this._gauge;} ;BiGaugeNeedle.prototype.getFillColor = function(){ return this._fillColor;} ;BiGaugeNeedle.prototype.getStrokeColor = function(){ return this._strokeColor;} ;_p.setFillColor = function(s){ this._fillColor = s; this._needle.setHtmlProperty("fillcolor", s); this._knob.setHtmlProperty("fillcolor", s);};_p.setStrokeColor = function(s){ this._strokeColor = s; this._needle.setHtmlProperty("strokecolor", s); this._knob.setHtmlProperty("strokecolor", s);};function BiGaugeMinorTicks(oGauge){ BiComponent.call(this); this._gauge = oGauge; this.setZIndex(1); this.setHtmlProperty("strokeweight", 1); this.setHtmlProperty("strokecolor", "windowtext"); this.setVisible(oGauge.getShowMinorTicks()); this.setLocation(0, 0); this.setSize(1000, 1000); this._update();};var _p = BiGaugeMinorTicks.prototype = new BiComponent;_p._className = "BiGaugeMinorTicks";_p._tagName = "v:shape";BiGaugeMinorTicks.prototype.getGauge = function(){ return this._gauge;} ;_p._update = function(){ var g = this.getGauge(); var max = g.getMaximum(); var min = g.getMinimum(); var minTick = g.getMinorTickInterval(); var majTick = g.getMajorTickInterval(); var sb = []; for (var i = min + 1; i < max; i++) { if (i % minTick == 0 && i % majTick != 0) { sb.push(g._getTickPath(i, 440, 435)); } } this.setHtmlProperty("path", sb.join("") + "e");};_p.layoutComponent = function(){ BiComponent.prototype.layoutComponent.call(this); this._resizeNonScalable();};_p.layoutComponentX = function(){ BiComponent.prototype.layoutComponentX.call(this); this._resizeNonScalable();};_p.layoutComponentY = function(){ BiComponent.prototype.layoutComponentY.call(this); this._resizeNonScalable();};_p._resizeNonScalable = function(){ if (!this.getCreated()) return; var cw = this.getGauge().getClientWidth(); var ch = this.getGauge().getClientHeight(); var s = Math.min(cw, ch); this.setHtmlProperty("strokeweight", s / 300);};function BiGaugeMajorTicks(oGauge){ BiComponent.call(this); this._gauge = oGauge; this.setZIndex(2); this.setHtmlProperty("strokeweight", 1); this.setHtmlProperty("strokecolor", "windowtext"); this.setVisible(oGauge.getShowMajorTicks()); this.setLocation(0, 0); this.setSize(1000, 1000); this._update();};var _p = BiGaugeMajorTicks.prototype = new BiComponent;_p._className = "BiGaugeMajorTicks";_p._tagName = "v:shape";BiGaugeMajorTicks.prototype.getGauge = function(){ return this._gauge;} ;_p._update = function(){ var g = this.getGauge(); var max = g.getMaximum(); var min = g.getMinimum(); var majTick = g.getMajorTickInterval(); var sb = []; sb.push(g._getTickPath(min, 440, 410)); for (var i = min + 1; i < max; i++) { if (i % majTick == 0) { sb.push(g._getTickPath(i, 440, 410)); } } sb.push(g._getTickPath(max, 440, 410)); this.setHtmlProperty("path", sb.join("") + "e");};_p.layoutComponent = function(){ BiComponent.prototype.layoutComponent.call(this); this._resizeNonScalable();};_p.layoutComponentX = function(){ BiComponent.prototype.layoutComponentX.call(this); this._resizeNonScalable();};_p.layoutComponentY = function(){ BiComponent.prototype.layoutComponentY.call(this); this._resizeNonScalable();};_p._resizeNonScalable = function(){ if (!this.getCreated()) return; var cw = this.getGauge().getClientWidth(); var ch = this.getGauge().getClientHeight(); var s = Math.min(cw, ch); this.setHtmlProperty("strokeweight", s / 200);};function BiGaugeLabels(oGauge){ BiComponent.call(this); this._gauge = oGauge; this.setLocation(0, 0); this.setRight(0); this.setBottom(0);}var _p = BiGaugeLabels.prototype = new BiComponent;_p._className = "BiGaugeLabels";BiGaugeLabels.prototype.getGauge = function(){ return this._gauge;} ;_p.layoutComponent = function(){ BiComponent.prototype.layoutComponent.call(this); this._resizeNonScalable();};_p.layoutComponentX = function(){ BiComponent.prototype.layoutComponentX.call(this); this._resizeNonScalable();};_p.layoutComponentY = function(){ BiComponent.prototype.layoutComponentY.call(this); this._resizeNonScalable();};_p._resizeNonScalable = function(){ if (!this.getCreated()) return; var g = this.getGauge(); var cw = g.getClientWidth(); var ch = g.getClientHeight(); var s = Math.min(cw, ch); try { for (var i = 0; i < this._labels.length; i++) this._labels[i].style.fontSize = s / 22 + "px"; } catch (ex) { for (var i = 0; i < this._labels.length; i++) this._labels[i].style.fontSize = s / 22 + "px"; }};_p._createLabels = function(){ var g = this.getGauge(); var labels = []; labels[0] = this._createLabel(g.getMinimum()); for (var i = g.getMinimum() + 1; i < g.getMaximum(); i++) { if (i % g.getLabelInterval() == 0) labels.push(this._createLabel(i)); } labels.push(this._createLabel(g.getMaximum(), true)); this._labels = labels;};_p._createLabel = function(nValue){ var g = this.getGauge(); var v = g._valueToAngle(nValue); var vr = v / 180 * Math.PI var r = 365; var el = this._document.createElement("v:shape"); var x = r * Math.sin(vr); var y = r * Math.cos(vr); x = 500 + x; y = 500 - y; el.style.left = Math.max(0, x - 50); el.style.top = Math.max(0, y - 25); el.style.width = 100; el.style.height = 50; el.style.textAlign = "center"; this._element.appendChild(el); el.innerText = nValue; return el;};_p._removeLabels = function(){ if (!this.getCreated()) return; for (var i = 0; i < this._labels.length; i++) { this._element.removeChild(this._labels[i]); this._labels[i] = null; } this._labels = [];};_p._create = function(oDoc){ BiComponent.prototype._create.call(this, oDoc); this._createLabels();};_p.dispose = function(){ if (this._disposed) return; BiComponent.prototype.dispose.call(this); if (this._labels) { for (var i = 0; i < this._labels.length; i++) this._labels[i] = null; this._labels = null; }};_p._update = function(){ if (this.getCreated()) { this._removeLabels(); this._createLabels(); this._resizeNonScalable(); }};function BiGaugeTitle(oGauge, sText){ BiLabel.call(this, sText); this._gauge = oGauge; this.setZIndex(1); this.setVisible(oGauge.getShowTitle());};var _p = BiGaugeTitle.prototype = new BiLabel;_p._className = "BiGaugeTitle";BiGaugeTitle.prototype.getGauge = function(){ return this._gauge;} ;_p.layoutComponent = function(){ BiComponent.prototype.layoutComponent.call(this); this._resizeNonScalable();};_p.layoutComponentX = function(){ BiComponent.prototype.layoutComponentX.call(this); this._resizeNonScalable();};_p.layoutComponentY = function(){ BiComponent.prototype.layoutComponentY.call(this); this._resizeNonScalable();};_p._resizeNonScalable = function(){ if (!this.getCreated()) return; var cw = this.getGauge().getClientWidth(); var ch = this.getGauge().getClientHeight(); var s = Math.min(cw, ch); var f = this.getFont(); f.setSize(s / 22); this.setFont(f); var w = this.getWidth(); this.setLeft((cw - w) / 2); this.setTop(ch * 0.70);};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -