iobroker.ebus 2.4.2 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/admin/index_m.html +19 -12
- package/io-package.json +38 -2
- package/main.js +26 -12
- package/package.json +9 -9
- package/widgets/ebus/lib/js/flot/jquery.canvaswrapper.js +7 -8
- package/widgets/ebus/lib/js/flot/jquery.flot.axislabels.js +215 -0
- package/widgets/ebus/lib/js/flot/jquery.flot.drawSeries.js +3 -4
- package/widgets/ebus/lib/js/flot/jquery.flot.fillbetween.js +12 -12
- package/widgets/ebus/lib/js/flot/jquery.flot.hover.js +7 -8
- package/widgets/ebus/lib/js/flot/jquery.flot.js +49 -56
- package/widgets/ebus/lib/js/flot/jquery.flot.legend.js +2 -2
- package/widgets/ebus/lib/js/flot/jquery.flot.logaxis.js +3 -3
- package/widgets/ebus/lib/js/flot/jquery.flot.navigate.js +44 -8
- package/widgets/ebus/lib/js/flot/jquery.flot.resize.js +1 -1
- package/widgets/ebus/lib/js/flot/jquery.flot.selection.js +11 -1
- package/widgets/ebus/lib/js/flot/jquery.flot.stack.js +3 -3
- package/widgets/ebus/lib/js/flot/jquery.flot.time.js +110 -108
- package/widgets/ebus/lib/js/flot/jquery.flot.touchNavigate.js +1 -1
- package/widgets/ebus.html +106 -95
package/README.md
CHANGED
|
@@ -52,6 +52,20 @@ Attention: command in datapoint ebus.0.cmd is deleted after executing of command
|
|
|
52
52
|
|
|
53
53
|
## Changelog
|
|
54
54
|
|
|
55
|
+
### 2.5.0 (in progress)
|
|
56
|
+
* (René) see issue #62: support ebusd 21.3
|
|
57
|
+
|
|
58
|
+
### 2.4.5 (2021-11-07)
|
|
59
|
+
* (René) bug fix color of labels in widget
|
|
60
|
+
|
|
61
|
+
### 2.4.4 (2021-10-30)
|
|
62
|
+
* (René) see issue #59: avoid endless loop
|
|
63
|
+
* (René) update flot to 4.2.2
|
|
64
|
+
* (René) bug fix missing space in command when using circuit name
|
|
65
|
+
|
|
66
|
+
## 2.4.3 (2021-10-21)
|
|
67
|
+
* (René) see issue #58: bug fix for Warn: ignoring history value 1 (invalid)" when no history values set
|
|
68
|
+
|
|
55
69
|
## 2.4.2 (2021-10-19)
|
|
56
70
|
* (René) see issue #55: bug fix
|
|
57
71
|
|
package/admin/index_m.html
CHANGED
|
@@ -102,16 +102,18 @@
|
|
|
102
102
|
|
|
103
103
|
var newValues = [];
|
|
104
104
|
for (let i = 0; i < values.length; i++) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
if (values[i].length > 0) {
|
|
106
|
+
console.log('add ' + values[i]);
|
|
107
|
+
const value = {
|
|
108
|
+
circuit: "",
|
|
109
|
+
name: values[i],
|
|
110
|
+
parameter: "",
|
|
111
|
+
}
|
|
112
|
+
newValues.push(value);
|
|
110
113
|
}
|
|
111
|
-
newValues.push(value);
|
|
112
114
|
}
|
|
113
115
|
values2table('polledDP', newValues, OnChange, tablePolledDPOnReady);
|
|
114
|
-
console.log('using PolledValues from settings ' + JSON.stringify(settings.PolledValues) + " " + JSON.stringify(newValues));
|
|
116
|
+
console.log('using PolledValues from old settings ' + JSON.stringify(settings.PolledValues) + " " + JSON.stringify(newValues));
|
|
115
117
|
|
|
116
118
|
}
|
|
117
119
|
|
|
@@ -150,14 +152,16 @@
|
|
|
150
152
|
|
|
151
153
|
var newValues = [];
|
|
152
154
|
for (let i = 0; i < values.length; i++) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
155
|
+
if (values[i].length > 0) {
|
|
156
|
+
console.log('add ' + values[i]);
|
|
157
|
+
const value = {
|
|
158
|
+
name: values[i],
|
|
159
|
+
}
|
|
160
|
+
newValues.push(value);
|
|
156
161
|
}
|
|
157
|
-
newValues.push(value);
|
|
158
162
|
}
|
|
159
163
|
values2table('historyDP', newValues, OnChange, tableHistoryDPOnReady);
|
|
160
|
-
console.log('using HistoryValues from settings ' + JSON.stringify(settings.HistoryValues) + " " + JSON.stringify(newValues));
|
|
164
|
+
console.log('using HistoryValues from old settings ' + JSON.stringify(settings.HistoryValues) + " " + JSON.stringify(newValues));
|
|
161
165
|
|
|
162
166
|
}
|
|
163
167
|
}
|
|
@@ -184,7 +188,10 @@
|
|
|
184
188
|
});
|
|
185
189
|
|
|
186
190
|
obj.PolledDPs = table2values('polledDP');
|
|
191
|
+
console.log('saving polledDP ' + JSON.stringify(obj.PolledDPs));
|
|
192
|
+
|
|
187
193
|
obj.HistoryDPs = table2values('historyDP');
|
|
194
|
+
console.log('saving historyDP ' + JSON.stringify(obj.HistoryDPs));
|
|
188
195
|
|
|
189
196
|
obj.PolledValues = "";
|
|
190
197
|
obj.HistoryValues = "";
|
package/io-package.json
CHANGED
|
@@ -1,9 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "ebus",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.5.0",
|
|
5
5
|
"news": {
|
|
6
|
-
"2.
|
|
6
|
+
"2.5.0": {
|
|
7
|
+
"en": "support ebusd 21.3",
|
|
8
|
+
"de": "ebusd 21,3 . unterstützen",
|
|
9
|
+
"ru": "поддержка ebusd 21.3",
|
|
10
|
+
"pt": "suporte ebusd 21.3",
|
|
11
|
+
"nl": "ondersteuning ebusd 21.3",
|
|
12
|
+
"fr": "soutien ebusd 21.3",
|
|
13
|
+
"it": "supporto ebusd 21.3",
|
|
14
|
+
"es": "soporte ebusd 21.3",
|
|
15
|
+
"pl": "wsparcie ebusd 21.3",
|
|
16
|
+
"zh-cn": "支持 ebusd 21.3"
|
|
17
|
+
},
|
|
18
|
+
"2.4.5": {
|
|
19
|
+
"en": "bug fix color of labels in widget",
|
|
20
|
+
"de": "Fehlerkorrektur Farbe der Labels im Widget",
|
|
21
|
+
"ru": "исправлена ошибка цвета меток в виджете",
|
|
22
|
+
"pt": "correção de bug de cor de rótulos no widget",
|
|
23
|
+
"nl": "bug fix kleur van labels in widget",
|
|
24
|
+
"fr": "correction de bogues couleur des étiquettes dans le widget",
|
|
25
|
+
"it": "bug fix colore delle etichette nel widget",
|
|
26
|
+
"es": "corrección de errores de color de las etiquetas en el widget",
|
|
27
|
+
"pl": "naprawa błędu koloru etykiet w widżecie",
|
|
28
|
+
"zh-cn": "错误修复小部件中标签的颜色"
|
|
29
|
+
},
|
|
30
|
+
"2.4.4": {
|
|
31
|
+
"en": "avoid endles loops",
|
|
32
|
+
"de": "Endlosschleifen vermeiden",
|
|
33
|
+
"ru": "избегать петель endles",
|
|
34
|
+
"pt": "evite loops de endles",
|
|
35
|
+
"nl": "vermijd eindeloze lussen",
|
|
36
|
+
"fr": "éviter les boucles sans fin",
|
|
37
|
+
"it": "evita i loop infiniti",
|
|
38
|
+
"es": "evitar bucles endles",
|
|
39
|
+
"pl": "unikaj niekończących się pętli",
|
|
40
|
+
"zh-cn": "避免无限循环"
|
|
41
|
+
},
|
|
42
|
+
"2.4.3": {
|
|
7
43
|
"en": "small bugs solved",
|
|
8
44
|
"de": "kleine Fehler behoben",
|
|
9
45
|
"ru": "исправлены мелкие ошибки",
|
package/main.js
CHANGED
|
@@ -11,8 +11,11 @@
|
|
|
11
11
|
/*jslint node: true */
|
|
12
12
|
"use strict";
|
|
13
13
|
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
14
17
|
const utils = require("@iobroker/adapter-core");
|
|
15
|
-
const ebusdMinVersion = [21,
|
|
18
|
+
const ebusdMinVersion = [21, 3];
|
|
16
19
|
let ebusdVersion = [0, 0];
|
|
17
20
|
let ebusdUpdateVersion = [0, 0];
|
|
18
21
|
|
|
@@ -101,13 +104,15 @@ function FillPolledVars() {
|
|
|
101
104
|
if (oPolled.length > 0) {
|
|
102
105
|
|
|
103
106
|
for (let i = 0; i < oPolled.length; i++) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
if (oPolled[i].length > 0) {
|
|
108
|
+
console.log('add ' + oPolled[i]);
|
|
109
|
+
const value = {
|
|
110
|
+
circuit: "",
|
|
111
|
+
name: oPolled[i],
|
|
112
|
+
parameter: ""
|
|
113
|
+
}
|
|
114
|
+
oPolledVars.push(value);
|
|
109
115
|
}
|
|
110
|
-
oPolledVars.push(value);
|
|
111
116
|
}
|
|
112
117
|
}
|
|
113
118
|
}
|
|
@@ -128,11 +133,13 @@ function FillHistoryVars() {
|
|
|
128
133
|
if (oHistory.length > 0) {
|
|
129
134
|
|
|
130
135
|
for (let i = 0; i < oHistory.length; i++) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
136
|
+
if (oHistory[i].length > 0) {
|
|
137
|
+
console.log('add ' + oHistory[i]);
|
|
138
|
+
const value = {
|
|
139
|
+
name: oHistory[i],
|
|
140
|
+
}
|
|
141
|
+
oHistoryVars.push(value);
|
|
134
142
|
}
|
|
135
|
-
oHistoryVars.push(value);
|
|
136
143
|
}
|
|
137
144
|
}
|
|
138
145
|
}
|
|
@@ -858,7 +865,7 @@ async function ebusd_ReadValues() {
|
|
|
858
865
|
let circuit = "";
|
|
859
866
|
let params = "";
|
|
860
867
|
if (oPolledVars[nCtr].circuit != null && oPolledVars[nCtr].circuit.length > 0) {
|
|
861
|
-
circuit = "-c " + oPolledVars[nCtr].circuit;
|
|
868
|
+
circuit = "-c " + oPolledVars[nCtr].circuit + " ";
|
|
862
869
|
}
|
|
863
870
|
if (oPolledVars[nCtr].parameter != null && oPolledVars[nCtr].parameter.length > 0) {
|
|
864
871
|
params = " " + oPolledVars[nCtr].parameter;
|
|
@@ -875,6 +882,13 @@ async function ebusd_ReadValues() {
|
|
|
875
882
|
//received ERR: arbitration lost for YieldThisYear
|
|
876
883
|
if (data.includes("ERR")) {
|
|
877
884
|
adapter.log.error("sent " + cmd + ", received " + data + " for " + JSON.stringify(oPolledVars[nCtr]));
|
|
885
|
+
|
|
886
|
+
/*
|
|
887
|
+
* sent read -f YieldLastYear, received ERR: arbitration lost for {"circuit":"","name":"YieldLastYear","parameter":""}
|
|
888
|
+
* */
|
|
889
|
+
if (data.includes("arbitration lost")) {
|
|
890
|
+
nCtr--;
|
|
891
|
+
}
|
|
878
892
|
}
|
|
879
893
|
else {
|
|
880
894
|
adapter.log.debug("received " + data + " for " + JSON.stringify(oPolledVars[nCtr]));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.ebus",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "ioBroker ebus Adapter",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "René G.",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@iobroker/adapter-core": "2.5.1",
|
|
24
|
-
"@sentry/node": "6.
|
|
24
|
+
"@sentry/node": "6.16.1",
|
|
25
25
|
"bent": "7.3.12",
|
|
26
26
|
"flat": "5.0.2",
|
|
27
27
|
"net": "1.0.2",
|
|
@@ -29,23 +29,23 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@iobroker/testing": "2.5.2",
|
|
32
|
-
"@types/chai": "4.
|
|
32
|
+
"@types/chai": "4.3.0",
|
|
33
33
|
"@types/chai-as-promised": "7.1.4",
|
|
34
34
|
"@types/gulp": "4.0.9",
|
|
35
35
|
"@types/mocha": "9.0.0",
|
|
36
|
-
"@types/node": "
|
|
36
|
+
"@types/node": "16.11.14",
|
|
37
37
|
"@types/proxyquire": "1.3.28",
|
|
38
38
|
"@types/request-promise-native": "1.0.18",
|
|
39
|
-
"@types/sinon": "10.0.
|
|
40
|
-
"@types/sinon-chai": "3.2.
|
|
41
|
-
"axios": "0.
|
|
39
|
+
"@types/sinon": "10.0.6",
|
|
40
|
+
"@types/sinon-chai": "3.2.6",
|
|
41
|
+
"axios": "0.24.0",
|
|
42
42
|
"chai": "4.3.4",
|
|
43
43
|
"chai-as-promised": "7.1.1",
|
|
44
|
-
"eslint": "8.0
|
|
44
|
+
"eslint": "8.5.0",
|
|
45
45
|
"gulp": "4.0.2",
|
|
46
46
|
"mocha": "9.1.3",
|
|
47
47
|
"proxyquire": "2.1.3",
|
|
48
|
-
"sinon": "
|
|
48
|
+
"sinon": "12.0.1",
|
|
49
49
|
"sinon-chai": "3.7.0"
|
|
50
50
|
},
|
|
51
51
|
"main": "main.js",
|
|
@@ -175,7 +175,7 @@ don't work unless the canvas is attached to the DOM.
|
|
|
175
175
|
}
|
|
176
176
|
};
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
/**
|
|
179
179
|
- getSVGLayer(classes)
|
|
180
180
|
|
|
181
181
|
Creates (if necessary) and returns the SVG overlay container.
|
|
@@ -226,7 +226,7 @@ don't work unless the canvas is attached to the DOM.
|
|
|
226
226
|
return layer;
|
|
227
227
|
};
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
/**
|
|
230
230
|
- getTextInfo(layer, text, font, angle, width)
|
|
231
231
|
|
|
232
232
|
Creates (if necessary) and returns a text info object.
|
|
@@ -354,7 +354,7 @@ don't work unless the canvas is attached to the DOM.
|
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
-
|
|
357
|
+
/**
|
|
358
358
|
- addText (layer, x, y, text, font, angle, width, halign, valign, transforms)
|
|
359
359
|
|
|
360
360
|
Adds a text string to the canvas text overlay.
|
|
@@ -367,8 +367,8 @@ don't work unless the canvas is attached to the DOM.
|
|
|
367
367
|
and text is the string to draw
|
|
368
368
|
*/
|
|
369
369
|
Canvas.prototype.addText = function(layer, x, y, text, font, angle, width, halign, valign, transforms) {
|
|
370
|
-
var info = this.getTextInfo(layer, text, font, angle, width)
|
|
371
|
-
|
|
370
|
+
var info = this.getTextInfo(layer, text, font, angle, width),
|
|
371
|
+
positions = info.positions;
|
|
372
372
|
|
|
373
373
|
// Tweak the div's position to match the text's alignment
|
|
374
374
|
|
|
@@ -388,7 +388,6 @@ don't work unless the canvas is attached to the DOM.
|
|
|
388
388
|
|
|
389
389
|
y += 0.75 * info.height;
|
|
390
390
|
|
|
391
|
-
|
|
392
391
|
// Determine whether this text already exists at this position.
|
|
393
392
|
// If so, mark it for inclusion in the next render pass.
|
|
394
393
|
|
|
@@ -449,7 +448,7 @@ don't work unless the canvas is attached to the DOM.
|
|
|
449
448
|
position.element.style.textAlign = halign;
|
|
450
449
|
// update the transforms
|
|
451
450
|
updateTransforms(position.element, transforms);
|
|
452
|
-
|
|
451
|
+
};
|
|
453
452
|
|
|
454
453
|
var addTspanElements = function(text, element, x) {
|
|
455
454
|
var lines = text.split('<br>'),
|
|
@@ -463,7 +462,7 @@ don't work unless the canvas is attached to the DOM.
|
|
|
463
462
|
tspan = element.childNodes[i];
|
|
464
463
|
}
|
|
465
464
|
tspan.textContent = lines[i];
|
|
466
|
-
offset = i
|
|
465
|
+
offset = (i === 0 ? 0 : 1) + 'em';
|
|
467
466
|
tspan.setAttributeNS(null, 'dy', offset);
|
|
468
467
|
tspan.setAttributeNS(null, 'x', x);
|
|
469
468
|
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Axis label plugin for flot
|
|
3
|
+
|
|
4
|
+
Derived from:
|
|
5
|
+
Axis Labels Plugin for flot.
|
|
6
|
+
http://github.com/markrcote/flot-axislabels
|
|
7
|
+
|
|
8
|
+
Original code is Copyright (c) 2010 Xuan Luo.
|
|
9
|
+
Original code was released under the GPLv3 license by Xuan Luo, September 2010.
|
|
10
|
+
Original code was rereleased under the MIT license by Xuan Luo, April 2012.
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
13
|
+
a copy of this software and associated documentation files (the
|
|
14
|
+
"Software"), to deal in the Software without restriction, including
|
|
15
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
16
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
17
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
18
|
+
the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be
|
|
21
|
+
included in all copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
24
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
25
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
26
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
27
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
28
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
29
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
(function($) {
|
|
33
|
+
"use strict";
|
|
34
|
+
|
|
35
|
+
var options = {
|
|
36
|
+
axisLabels: {
|
|
37
|
+
show: true
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
function AxisLabel(axisName, position, padding, placeholder, axisLabel, surface) {
|
|
42
|
+
this.axisName = axisName;
|
|
43
|
+
this.position = position;
|
|
44
|
+
this.padding = padding;
|
|
45
|
+
this.placeholder = placeholder;
|
|
46
|
+
this.axisLabel = axisLabel;
|
|
47
|
+
this.surface = surface;
|
|
48
|
+
this.width = 0;
|
|
49
|
+
this.height = 0;
|
|
50
|
+
this.elem = null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
AxisLabel.prototype.calculateSize = function() {
|
|
54
|
+
var axisId = this.axisName + 'Label',
|
|
55
|
+
layerId = axisId + 'Layer',
|
|
56
|
+
className = axisId + ' axisLabels';
|
|
57
|
+
|
|
58
|
+
var info = this.surface.getTextInfo(layerId, this.axisLabel, className);
|
|
59
|
+
this.labelWidth = info.width;
|
|
60
|
+
this.labelHeight = info.height;
|
|
61
|
+
|
|
62
|
+
if (this.position === 'left' || this.position === 'right') {
|
|
63
|
+
this.width = this.labelHeight + this.padding;
|
|
64
|
+
this.height = 0;
|
|
65
|
+
} else {
|
|
66
|
+
this.width = 0;
|
|
67
|
+
this.height = this.labelHeight + this.padding;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
AxisLabel.prototype.transforms = function(degrees, x, y, svgLayer) {
|
|
72
|
+
var transforms = [], translate, rotate;
|
|
73
|
+
if (x !== 0 || y !== 0) {
|
|
74
|
+
translate = svgLayer.createSVGTransform();
|
|
75
|
+
translate.setTranslate(x, y);
|
|
76
|
+
transforms.push(translate);
|
|
77
|
+
}
|
|
78
|
+
if (degrees !== 0) {
|
|
79
|
+
rotate = svgLayer.createSVGTransform();
|
|
80
|
+
var centerX = Math.round(this.labelWidth / 2),
|
|
81
|
+
centerY = 0;
|
|
82
|
+
rotate.setRotate(degrees, centerX, centerY);
|
|
83
|
+
transforms.push(rotate);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return transforms;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
AxisLabel.prototype.calculateOffsets = function(box) {
|
|
90
|
+
var offsets = {
|
|
91
|
+
x: 0,
|
|
92
|
+
y: 0,
|
|
93
|
+
degrees: 0
|
|
94
|
+
};
|
|
95
|
+
if (this.position === 'bottom') {
|
|
96
|
+
offsets.x = box.left + box.width / 2 - this.labelWidth / 2;
|
|
97
|
+
offsets.y = box.top + box.height - this.labelHeight;
|
|
98
|
+
} else if (this.position === 'top') {
|
|
99
|
+
offsets.x = box.left + box.width / 2 - this.labelWidth / 2;
|
|
100
|
+
offsets.y = box.top;
|
|
101
|
+
} else if (this.position === 'left') {
|
|
102
|
+
offsets.degrees = -90;
|
|
103
|
+
offsets.x = box.left - this.labelWidth / 2;
|
|
104
|
+
offsets.y = box.height / 2 + box.top;
|
|
105
|
+
} else if (this.position === 'right') {
|
|
106
|
+
offsets.degrees = 90;
|
|
107
|
+
offsets.x = box.left + box.width - this.labelWidth / 2;
|
|
108
|
+
offsets.y = box.height / 2 + box.top;
|
|
109
|
+
}
|
|
110
|
+
offsets.x = Math.round(offsets.x);
|
|
111
|
+
offsets.y = Math.round(offsets.y);
|
|
112
|
+
|
|
113
|
+
return offsets;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
AxisLabel.prototype.cleanup = function() {
|
|
117
|
+
var axisId = this.axisName + 'Label',
|
|
118
|
+
layerId = axisId + 'Layer',
|
|
119
|
+
className = axisId + ' axisLabels';
|
|
120
|
+
this.surface.removeText(layerId, 0, 0, this.axisLabel, className);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
AxisLabel.prototype.draw = function(box) {
|
|
124
|
+
var axisId = this.axisName + 'Label',
|
|
125
|
+
layerId = axisId + 'Layer',
|
|
126
|
+
className = axisId + ' axisLabels',
|
|
127
|
+
offsets = this.calculateOffsets(box),
|
|
128
|
+
style = {
|
|
129
|
+
position: 'absolute',
|
|
130
|
+
bottom: '',
|
|
131
|
+
right: '',
|
|
132
|
+
display: 'inline-block',
|
|
133
|
+
'white-space': 'nowrap'
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
var layer = this.surface.getSVGLayer(layerId);
|
|
137
|
+
var transforms = this.transforms(offsets.degrees, offsets.x, offsets.y, layer.parentNode);
|
|
138
|
+
|
|
139
|
+
this.surface.addText(layerId, 0, 0, this.axisLabel, className, undefined, undefined, undefined, undefined, transforms);
|
|
140
|
+
this.surface.render();
|
|
141
|
+
Object.keys(style).forEach(function(key) {
|
|
142
|
+
layer.style[key] = style[key];
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
function init(plot) {
|
|
147
|
+
plot.hooks.processOptions.push(function (plot, options) {
|
|
148
|
+
|
|
149
|
+
console.log('??????? ');
|
|
150
|
+
|
|
151
|
+
if (!options.axisLabels.show) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
var axisLabels = {};
|
|
156
|
+
var defaultPadding = 2; // padding between axis and tick labels
|
|
157
|
+
|
|
158
|
+
plot.hooks.axisReserveSpace.push(function(plot, axis) {
|
|
159
|
+
var opts = axis.options;
|
|
160
|
+
var axisName = axis.direction + axis.n;
|
|
161
|
+
|
|
162
|
+
axis.labelHeight += axis.boxPosition.centerY;
|
|
163
|
+
axis.labelWidth += axis.boxPosition.centerX;
|
|
164
|
+
|
|
165
|
+
if (!opts || !opts.axisLabel || !axis.show) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
var padding = opts.axisLabelPadding === undefined
|
|
170
|
+
? defaultPadding
|
|
171
|
+
: opts.axisLabelPadding;
|
|
172
|
+
|
|
173
|
+
var axisLabel = axisLabels[axisName];
|
|
174
|
+
if (!axisLabel) {
|
|
175
|
+
axisLabel = new AxisLabel(axisName,
|
|
176
|
+
opts.position, padding,
|
|
177
|
+
plot.getPlaceholder()[0], opts.axisLabel, plot.getSurface());
|
|
178
|
+
axisLabels[axisName] = axisLabel;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
axisLabel.calculateSize();
|
|
182
|
+
|
|
183
|
+
// Incrementing the sizes of the tick labels.
|
|
184
|
+
axis.labelHeight += axisLabel.height;
|
|
185
|
+
axis.labelWidth += axisLabel.width;
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
// TODO - use the drawAxis hook
|
|
189
|
+
plot.hooks.draw.push(function(plot, ctx) {
|
|
190
|
+
$.each(plot.getAxes(), function(flotAxisName, axis) {
|
|
191
|
+
var opts = axis.options;
|
|
192
|
+
if (!opts || !opts.axisLabel || !axis.show) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
var axisName = axis.direction + axis.n;
|
|
197
|
+
axisLabels[axisName].draw(axis.box);
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
plot.hooks.shutdown.push(function(plot, eventHolder) {
|
|
202
|
+
for (var axisName in axisLabels) {
|
|
203
|
+
axisLabels[axisName].cleanup();
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
$.plot.plugins.push({
|
|
210
|
+
init: init,
|
|
211
|
+
options: options,
|
|
212
|
+
name: 'axisLabels',
|
|
213
|
+
version: '3.0'
|
|
214
|
+
});
|
|
215
|
+
})(jQuery);
|
|
@@ -42,7 +42,7 @@ This plugin is used by flot for drawing lines, plots, bars or area.
|
|
|
42
42
|
continue;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
if(steps){
|
|
45
|
+
if (steps) {
|
|
46
46
|
if (mx !== null && my !== null) {
|
|
47
47
|
// if middle point exists, transfer p2 -> p1 and p1 -> mp
|
|
48
48
|
x2 = x1;
|
|
@@ -202,7 +202,7 @@ This plugin is used by flot for drawing lines, plots, bars or area.
|
|
|
202
202
|
continue;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
if(steps){
|
|
205
|
+
if (steps) {
|
|
206
206
|
if (mx !== null && my !== null) {
|
|
207
207
|
// if middle point exists, transfer p2 -> p1 and p1 -> mp
|
|
208
208
|
x2 = x1;
|
|
@@ -482,8 +482,7 @@ This plugin is used by flot for drawing lines, plots, bars or area.
|
|
|
482
482
|
drawLeft = true;
|
|
483
483
|
drawRight = false;
|
|
484
484
|
}
|
|
485
|
-
}
|
|
486
|
-
else {
|
|
485
|
+
} else {
|
|
487
486
|
drawLeft = drawRight = drawTop = true;
|
|
488
487
|
drawBottom = false;
|
|
489
488
|
left = x + barLeft;
|
|
@@ -32,7 +32,7 @@ jquery.flot.stack.js plugin, possibly some code could be shared.
|
|
|
32
32
|
(function ($) {
|
|
33
33
|
var options = {
|
|
34
34
|
series: {
|
|
35
|
-
fillBetween: null
|
|
35
|
+
fillBetween: null // or number
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
|
|
@@ -60,11 +60,11 @@ jquery.flot.stack.js plugin, possibly some code could be shared.
|
|
|
60
60
|
if (s.fillBetween == null) {
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
format = datapoints.format;
|
|
63
|
+
|
|
64
|
+
var format = datapoints.format;
|
|
65
65
|
var plotHasId = function(id) {
|
|
66
66
|
var plotData = plot.getData();
|
|
67
|
-
for (i = 0; i < plotData.length; i++) {
|
|
67
|
+
for (var i = 0; i < plotData.length; i++) {
|
|
68
68
|
if (plotData[i].id === id) {
|
|
69
69
|
return true;
|
|
70
70
|
}
|
|
@@ -76,17 +76,17 @@ jquery.flot.stack.js plugin, possibly some code could be shared.
|
|
|
76
76
|
if (!format) {
|
|
77
77
|
format = [];
|
|
78
78
|
|
|
79
|
-
format.push({
|
|
80
|
-
x: true,
|
|
81
|
-
number: true,
|
|
79
|
+
format.push({
|
|
80
|
+
x: true,
|
|
81
|
+
number: true,
|
|
82
82
|
computeRange: s.xaxis.options.autoScale !== 'none',
|
|
83
|
-
required: true
|
|
83
|
+
required: true
|
|
84
84
|
});
|
|
85
|
-
format.push({
|
|
86
|
-
y: true,
|
|
87
|
-
number: true,
|
|
85
|
+
format.push({
|
|
86
|
+
y: true,
|
|
87
|
+
number: true,
|
|
88
88
|
computeRange: s.yaxis.options.autoScale !== 'none',
|
|
89
|
-
required: true
|
|
89
|
+
required: true
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
if (s.fillBetween !== undefined && s.fillBetween !== '' && plotHasId(s.fillBetween) && s.fillBetween !== s.id) {
|
|
@@ -79,7 +79,6 @@ the tooltip from webcharts).
|
|
|
79
79
|
highlights = [];
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
|
|
83
82
|
function generatePlothoverEvent(e) {
|
|
84
83
|
var o = plot.getOptions(),
|
|
85
84
|
newEvent = new CustomEvent('mouseevent');
|
|
@@ -98,10 +97,10 @@ the tooltip from webcharts).
|
|
|
98
97
|
|
|
99
98
|
function doTriggerClickHoverEvent(event, eventType, searchDistance) {
|
|
100
99
|
var series = plot.getData();
|
|
101
|
-
if (event !== undefined
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
if (event !== undefined &&
|
|
101
|
+
series.length > 0 &&
|
|
102
|
+
series[0].xaxis.c2p !== undefined &&
|
|
103
|
+
series[0].yaxis.c2p !== undefined) {
|
|
105
104
|
var eventToTrigger = "plot" + eventType;
|
|
106
105
|
var seriesFlag = eventType + "able";
|
|
107
106
|
triggerClickHoverEvent(eventToTrigger, event,
|
|
@@ -155,8 +154,8 @@ the tooltip from webcharts).
|
|
|
155
154
|
var items = plot.findNearbyItems(canvasX, canvasY, seriesFilter, distance);
|
|
156
155
|
var item = items[0];
|
|
157
156
|
|
|
158
|
-
for (
|
|
159
|
-
if (item.distance === undefined ||
|
|
157
|
+
for (let i = 1; i < items.length; ++i) {
|
|
158
|
+
if (item.distance === undefined ||
|
|
160
159
|
items[i].distance < item.distance) {
|
|
161
160
|
item = items[i];
|
|
162
161
|
}
|
|
@@ -172,7 +171,7 @@ the tooltip from webcharts).
|
|
|
172
171
|
|
|
173
172
|
if (options.grid.autoHighlight) {
|
|
174
173
|
// clear auto-highlights
|
|
175
|
-
for (
|
|
174
|
+
for (let i = 0; i < highlights.length; ++i) {
|
|
176
175
|
var h = highlights[i];
|
|
177
176
|
if ((h.auto === eventname &&
|
|
178
177
|
!(item && h.series === item.series &&
|