@gisce/ooui 0.2.13 → 0.3.1
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/dist/Graph/Graph.d.ts +8 -0
- package/dist/Graph/Graph.js +23 -0
- package/dist/Graph/Graph.js.map +1 -0
- package/dist/Graph/GraphAxis.d.ts +15 -0
- package/dist/Graph/GraphAxis.js +32 -0
- package/dist/Graph/GraphAxis.js.map +1 -0
- package/dist/Graph/GraphFactory.d.ts +3 -0
- package/dist/Graph/GraphFactory.js +20 -0
- package/dist/Graph/GraphFactory.js.map +1 -0
- package/dist/{Graph.d.ts → Graph/GraphIndicator.d.ts} +5 -10
- package/dist/Graph/GraphIndicator.js +75 -0
- package/dist/Graph/GraphIndicator.js.map +1 -0
- package/dist/Graph/GraphLine.d.ts +9 -0
- package/dist/Graph/GraphLine.js +43 -0
- package/dist/Graph/GraphLine.js.map +1 -0
- package/dist/Graph/graphHelper.d.ts +6 -0
- package/dist/Graph/graphHelper.js +32 -0
- package/dist/Graph/graphHelper.js.map +1 -0
- package/dist/Graph/index.d.ts +5 -0
- package/dist/Graph/index.js +6 -0
- package/dist/Graph/index.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/Graph/Graph.ts +17 -0
- package/src/Graph/GraphAxis.ts +33 -0
- package/src/Graph/GraphFactory.ts +26 -0
- package/src/Graph/GraphIndicator.ts +47 -0
- package/src/Graph/GraphLine.ts +24 -0
- package/src/Graph/graphHelper.ts +42 -0
- package/src/Graph/index.ts +5 -0
- package/src/index.ts +14 -2
- package/src/spec/Graph.spec.ts +21 -2
- package/dist/Graph.js +0 -79
- package/dist/Graph.js.map +0 -1
- package/src/Graph.ts +0 -65
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var Graph = /** @class */ (function () {
|
|
2
|
+
function Graph(element) {
|
|
3
|
+
this._string = null;
|
|
4
|
+
this._string = element.getAttribute("string");
|
|
5
|
+
}
|
|
6
|
+
Object.defineProperty(Graph.prototype, "string", {
|
|
7
|
+
get: function () {
|
|
8
|
+
return this._string;
|
|
9
|
+
},
|
|
10
|
+
enumerable: false,
|
|
11
|
+
configurable: true
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(Graph.prototype, "type", {
|
|
14
|
+
get: function () {
|
|
15
|
+
return this._type;
|
|
16
|
+
},
|
|
17
|
+
enumerable: false,
|
|
18
|
+
configurable: true
|
|
19
|
+
});
|
|
20
|
+
return Graph;
|
|
21
|
+
}());
|
|
22
|
+
export { Graph };
|
|
23
|
+
//# sourceMappingURL=Graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Graph.js","sourceRoot":"","sources":["../../src/Graph/Graph.ts"],"names":[],"mappings":"AAEA;IAWE,eAAY,OAAoB;QAVhC,YAAO,GAAkB,IAAI,CAAC;QAW5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAXD,sBAAI,yBAAM;aAAV;YACE,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;;;OAAA;IAGD,sBAAI,uBAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;;;OAAA;IAKH,YAAC;AAAD,CAAC,AAdD,IAcC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare type Axis = "x" | "y";
|
|
2
|
+
export declare type Operator = "+";
|
|
3
|
+
export declare class GraphAxis {
|
|
4
|
+
_name: string | undefined;
|
|
5
|
+
get name(): string | undefined;
|
|
6
|
+
_axis: Axis | undefined;
|
|
7
|
+
get axis(): Axis | undefined;
|
|
8
|
+
_operator: Operator | undefined;
|
|
9
|
+
get operator(): Operator | undefined;
|
|
10
|
+
constructor({ name, axis, operator, }: {
|
|
11
|
+
name: string;
|
|
12
|
+
axis: Axis;
|
|
13
|
+
operator?: Operator;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var GraphAxis = /** @class */ (function () {
|
|
2
|
+
function GraphAxis(_a) {
|
|
3
|
+
var name = _a.name, axis = _a.axis, operator = _a.operator;
|
|
4
|
+
this._name = name;
|
|
5
|
+
this._axis = axis;
|
|
6
|
+
this._operator = operator;
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(GraphAxis.prototype, "name", {
|
|
9
|
+
get: function () {
|
|
10
|
+
return this._name;
|
|
11
|
+
},
|
|
12
|
+
enumerable: false,
|
|
13
|
+
configurable: true
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(GraphAxis.prototype, "axis", {
|
|
16
|
+
get: function () {
|
|
17
|
+
return this._axis;
|
|
18
|
+
},
|
|
19
|
+
enumerable: false,
|
|
20
|
+
configurable: true
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(GraphAxis.prototype, "operator", {
|
|
23
|
+
get: function () {
|
|
24
|
+
return this._operator;
|
|
25
|
+
},
|
|
26
|
+
enumerable: false,
|
|
27
|
+
configurable: true
|
|
28
|
+
});
|
|
29
|
+
return GraphAxis;
|
|
30
|
+
}());
|
|
31
|
+
export { GraphAxis };
|
|
32
|
+
//# sourceMappingURL=GraphAxis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphAxis.js","sourceRoot":"","sources":["../../src/Graph/GraphAxis.ts"],"names":[],"mappings":"AAGA;IAgBE,mBAAY,EAQX;YAPC,IAAI,UAAA,EACJ,IAAI,UAAA,EACJ,QAAQ,cAAA;QAMR,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IA1BD,sBAAI,2BAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;;;OAAA;IAGD,sBAAI,2BAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;;;OAAA;IAGD,sBAAI,+BAAQ;aAAZ;YACE,OAAO,IAAI,CAAC,SAAS,CAAC;QACxB,CAAC;;;OAAA;IAeH,gBAAC;AAAD,CAAC,AA7BD,IA6BC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GraphIndicator } from "./GraphIndicator";
|
|
2
|
+
import { GraphLine } from "./GraphLine";
|
|
3
|
+
var GraphTypes = {
|
|
4
|
+
indicator: GraphIndicator,
|
|
5
|
+
line: GraphLine,
|
|
6
|
+
};
|
|
7
|
+
export var parseGraph = function (xml) {
|
|
8
|
+
var parser = new DOMParser();
|
|
9
|
+
var view = parser.parseFromString(xml, "text/xml");
|
|
10
|
+
var type = view.documentElement.getAttribute("type");
|
|
11
|
+
if (!type) {
|
|
12
|
+
throw new Error(type + " is not a valid graph");
|
|
13
|
+
}
|
|
14
|
+
var graphModel = GraphTypes[type];
|
|
15
|
+
if (!graphModel) {
|
|
16
|
+
throw new Error(type + " not found as a GraphModel");
|
|
17
|
+
}
|
|
18
|
+
return new graphModel(view.documentElement);
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=GraphFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphFactory.js","sourceRoot":"","sources":["../../src/Graph/GraphFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,IAAM,UAAU,GAA2B;IACzC,SAAS,EAAE,cAAc;IACzB,IAAI,EAAE,SAAS;CAChB,CAAC;AAEF,MAAM,CAAC,IAAM,UAAU,GAAG,UAAC,GAAW;IACpC,IAAM,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;IAC/B,IAAM,IAAI,GAAa,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAE/D,IAAM,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAEvD,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CAAI,IAAI,0BAAuB,CAAC,CAAC;KACjD;IAED,IAAM,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAEpC,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,IAAI,KAAK,CAAI,IAAI,+BAA4B,CAAC,CAAC;KACtD;IAED,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAC9C,CAAC,CAAC"}
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
declare class Graph {
|
|
3
|
-
_string: string | null;
|
|
4
|
-
get string(): string | null;
|
|
5
|
-
_type?: GraphType;
|
|
6
|
-
get type(): GraphType | undefined;
|
|
1
|
+
import { Graph } from "./Graph";
|
|
2
|
+
export declare class GraphIndicator extends Graph {
|
|
7
3
|
_color: string | null;
|
|
8
4
|
get color(): string | null;
|
|
9
5
|
_icon: string | null;
|
|
10
6
|
get icon(): string | null;
|
|
11
|
-
_suffix: string | null;
|
|
12
|
-
get suffix(): string | null;
|
|
13
7
|
_totalDomain: string | null;
|
|
14
8
|
get totalDomain(): string | null;
|
|
15
9
|
_showPercent: boolean;
|
|
16
10
|
get showPercent(): boolean;
|
|
17
|
-
|
|
11
|
+
_suffix: string | null;
|
|
12
|
+
get suffix(): string | null;
|
|
13
|
+
constructor(element: HTMLElement);
|
|
18
14
|
}
|
|
19
|
-
export default Graph;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
extendStatics(d, b);
|
|
10
|
+
function __() { this.constructor = d; }
|
|
11
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
|
+
};
|
|
13
|
+
})();
|
|
14
|
+
import { Graph } from "./Graph";
|
|
15
|
+
var GraphIndicator = /** @class */ (function (_super) {
|
|
16
|
+
__extends(GraphIndicator, _super);
|
|
17
|
+
function GraphIndicator(element) {
|
|
18
|
+
var _this = _super.call(this, element) || this;
|
|
19
|
+
_this._color = null;
|
|
20
|
+
_this._icon = null;
|
|
21
|
+
_this._totalDomain = null;
|
|
22
|
+
_this._showPercent = false;
|
|
23
|
+
_this._suffix = null;
|
|
24
|
+
_this._type = "indicator";
|
|
25
|
+
_this._color = element.getAttribute("color");
|
|
26
|
+
_this._icon = element.getAttribute("icon");
|
|
27
|
+
_this._suffix = element.getAttribute("suffix");
|
|
28
|
+
_this._totalDomain = element.getAttribute("totalDomain");
|
|
29
|
+
var showPercent = element.getAttribute("showPercent");
|
|
30
|
+
if (showPercent &&
|
|
31
|
+
(showPercent === "1" ||
|
|
32
|
+
(typeof showPercent === "boolean" && showPercent === true))) {
|
|
33
|
+
_this._showPercent = true;
|
|
34
|
+
}
|
|
35
|
+
return _this;
|
|
36
|
+
}
|
|
37
|
+
Object.defineProperty(GraphIndicator.prototype, "color", {
|
|
38
|
+
get: function () {
|
|
39
|
+
return this._color;
|
|
40
|
+
},
|
|
41
|
+
enumerable: false,
|
|
42
|
+
configurable: true
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(GraphIndicator.prototype, "icon", {
|
|
45
|
+
get: function () {
|
|
46
|
+
return this._icon;
|
|
47
|
+
},
|
|
48
|
+
enumerable: false,
|
|
49
|
+
configurable: true
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(GraphIndicator.prototype, "totalDomain", {
|
|
52
|
+
get: function () {
|
|
53
|
+
return this._totalDomain;
|
|
54
|
+
},
|
|
55
|
+
enumerable: false,
|
|
56
|
+
configurable: true
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(GraphIndicator.prototype, "showPercent", {
|
|
59
|
+
get: function () {
|
|
60
|
+
return this._showPercent;
|
|
61
|
+
},
|
|
62
|
+
enumerable: false,
|
|
63
|
+
configurable: true
|
|
64
|
+
});
|
|
65
|
+
Object.defineProperty(GraphIndicator.prototype, "suffix", {
|
|
66
|
+
get: function () {
|
|
67
|
+
return this._suffix;
|
|
68
|
+
},
|
|
69
|
+
enumerable: false,
|
|
70
|
+
configurable: true
|
|
71
|
+
});
|
|
72
|
+
return GraphIndicator;
|
|
73
|
+
}(Graph));
|
|
74
|
+
export { GraphIndicator };
|
|
75
|
+
//# sourceMappingURL=GraphIndicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphIndicator.js","sourceRoot":"","sources":["../../src/Graph/GraphIndicator.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC;IAAoC,kCAAK;IA0BvC,wBAAY,OAAoB;QAAhC,YACE,kBAAM,OAAO,CAAC,SAgBf;QA1CD,YAAM,GAAkB,IAAI,CAAC;QAK7B,WAAK,GAAkB,IAAI,CAAC;QAK5B,kBAAY,GAAkB,IAAI,CAAC;QAKnC,kBAAY,GAAY,KAAK,CAAC;QAK9B,aAAO,GAAkB,IAAI,CAAC;QAQ5B,KAAI,CAAC,KAAK,GAAG,WAAW,CAAC;QACzB,KAAI,CAAC,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAC5C,KAAI,CAAC,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAC1C,KAAI,CAAC,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC9C,KAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QACxD,IAAM,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QAExD,IACE,WAAW;YACX,CAAC,WAAW,KAAK,GAAG;gBAClB,CAAC,OAAO,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,IAAI,CAAC,CAAC,EAC7D;YACA,KAAI,CAAC,YAAY,GAAG,IAAI,CAAC;SAC1B;;IACH,CAAC;IAzCD,sBAAI,iCAAK;aAAT;YACE,OAAO,IAAI,CAAC,MAAM,CAAC;QACrB,CAAC;;;OAAA;IAGD,sBAAI,gCAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;;;OAAA;IAGD,sBAAI,uCAAW;aAAf;YACE,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;;;OAAA;IAGD,sBAAI,uCAAW;aAAf;YACE,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;;;OAAA;IAGD,sBAAI,kCAAM;aAAV;YACE,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;;;OAAA;IAoBH,qBAAC;AAAD,CAAC,AA5CD,CAAoC,KAAK,GA4CxC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GraphAxis } from ".";
|
|
2
|
+
import { Graph } from "./Graph";
|
|
3
|
+
export declare class GraphLine extends Graph {
|
|
4
|
+
_x: GraphAxis | undefined;
|
|
5
|
+
get x(): GraphAxis | undefined;
|
|
6
|
+
_y: GraphAxis | undefined;
|
|
7
|
+
get y(): GraphAxis | undefined;
|
|
8
|
+
constructor(element: HTMLElement);
|
|
9
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
extendStatics(d, b);
|
|
10
|
+
function __() { this.constructor = d; }
|
|
11
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
|
+
};
|
|
13
|
+
})();
|
|
14
|
+
import { Graph } from "./Graph";
|
|
15
|
+
import { parseXYAxis } from "./graphHelper";
|
|
16
|
+
var GraphLine = /** @class */ (function (_super) {
|
|
17
|
+
__extends(GraphLine, _super);
|
|
18
|
+
function GraphLine(element) {
|
|
19
|
+
var _this = _super.call(this, element) || this;
|
|
20
|
+
_this._type = "line";
|
|
21
|
+
var xyAxis = parseXYAxis(element.childNodes);
|
|
22
|
+
_this._x = xyAxis.x;
|
|
23
|
+
_this._y = xyAxis.y;
|
|
24
|
+
return _this;
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(GraphLine.prototype, "x", {
|
|
27
|
+
get: function () {
|
|
28
|
+
return this._x;
|
|
29
|
+
},
|
|
30
|
+
enumerable: false,
|
|
31
|
+
configurable: true
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(GraphLine.prototype, "y", {
|
|
34
|
+
get: function () {
|
|
35
|
+
return this._y;
|
|
36
|
+
},
|
|
37
|
+
enumerable: false,
|
|
38
|
+
configurable: true
|
|
39
|
+
});
|
|
40
|
+
return GraphLine;
|
|
41
|
+
}(Graph));
|
|
42
|
+
export { GraphLine };
|
|
43
|
+
//# sourceMappingURL=GraphLine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphLine.js","sourceRoot":"","sources":["../../src/Graph/GraphLine.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;IAA+B,6BAAK;IAUlC,mBAAY,OAAoB;QAAhC,YACE,kBAAM,OAAO,CAAC,SAOf;QALC,KAAI,CAAC,KAAK,GAAG,MAAM,CAAC;QAEpB,IAAM,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC/C,KAAI,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;QACnB,KAAI,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;;IACrB,CAAC;IAhBD,sBAAI,wBAAC;aAAL;YACE,OAAO,IAAI,CAAC,EAAE,CAAC;QACjB,CAAC;;;OAAA;IAGD,sBAAI,wBAAC;aAAL;YACE,OAAO,IAAI,CAAC,EAAE,CAAC;QACjB,CAAC;;;OAAA;IAUH,gBAAC;AAAD,CAAC,AAnBD,CAA+B,KAAK,GAmBnC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { GraphAxis } from ".";
|
|
2
|
+
export var parseXYAxis = function (nodes) {
|
|
3
|
+
var xyAxis = {};
|
|
4
|
+
Array.prototype.forEach.call(nodes, function (child) {
|
|
5
|
+
if (child.nodeType === child.ELEMENT_NODE) {
|
|
6
|
+
if (child.nodeName === "field") {
|
|
7
|
+
}
|
|
8
|
+
var axis = child.getAttribute("axis");
|
|
9
|
+
var operator = child.getAttribute("operator");
|
|
10
|
+
var name_1 = child.getAttribute("name");
|
|
11
|
+
if (!axis) {
|
|
12
|
+
throw new Error("Field " + name_1 + " doesn't have an axis");
|
|
13
|
+
}
|
|
14
|
+
if (!name_1) {
|
|
15
|
+
throw new Error("Missing name attribute for field");
|
|
16
|
+
}
|
|
17
|
+
var graphAxis = new GraphAxis({
|
|
18
|
+
axis: axis,
|
|
19
|
+
name: name_1,
|
|
20
|
+
operator: operator,
|
|
21
|
+
});
|
|
22
|
+
if (axis === "x") {
|
|
23
|
+
xyAxis.x = graphAxis;
|
|
24
|
+
}
|
|
25
|
+
else if (axis === "y") {
|
|
26
|
+
xyAxis.y = graphAxis;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return xyAxis;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=graphHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphHelper.js","sourceRoot":"","sources":["../../src/Graph/graphHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,SAAS,EAAY,MAAM,GAAG,CAAC;AAO9C,MAAM,CAAC,IAAM,WAAW,GAAG,UAAC,KAA4B;IACtD,IAAM,MAAM,GAAQ,EAAE,CAAC;IAEvB,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,UAAC,KAAc;QACjD,IAAI,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,YAAY,EAAE;YACzC,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO,EAAE;aAC/B;YACD,IAAM,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YACxC,IAAM,QAAQ,GAAG,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;YAChD,IAAM,MAAI,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAExC,IAAI,CAAC,IAAI,EAAE;gBACT,MAAM,IAAI,KAAK,CAAC,WAAS,MAAI,0BAAuB,CAAC,CAAC;aACvD;YAED,IAAI,CAAC,MAAI,EAAE;gBACT,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;aACrD;YAED,IAAM,SAAS,GAAG,IAAI,SAAS,CAAC;gBAC9B,IAAI,EAAE,IAAY;gBAClB,IAAI,QAAA;gBACJ,QAAQ,EAAE,QAAoB;aAC/B,CAAC,CAAC;YAEH,IAAI,IAAI,KAAK,GAAG,EAAE;gBAChB,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;aACtB;iBAAM,IAAI,IAAI,KAAK,GAAG,EAAE;gBACvB,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;aACtB;SACF;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAgB,CAAC;AAC1B,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Graph/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -33,5 +33,5 @@ import Timeline from "./Timeline";
|
|
|
33
33
|
import Indicator from "./Indicator";
|
|
34
34
|
import Dashboard from "./Dashboard";
|
|
35
35
|
import DashboardItem from "./DashboardItem";
|
|
36
|
-
import Graph from "./Graph";
|
|
37
|
-
export { Char, Selection, Many2one, Field, Widget, Form, Tree, Boolean, One2many, Integer, Float, FloatTime, Date, DateTime, Many2many, SearchFilter, Container, ContainerWidget, Text, ProgressBar, Notebook, Group, Page, Label, Separator, Button, Reference, Binary, Image, parseContext, transformDomainForChildWidget, Timeline, Indicator, Dashboard, DashboardItem, Graph };
|
|
36
|
+
import { Graph, GraphAxis, GraphIndicator, GraphLine, GraphType, parseGraph } from "./Graph";
|
|
37
|
+
export { Char, Selection, Many2one, Field, Widget, Form, Tree, Boolean, One2many, Integer, Float, FloatTime, Date, DateTime, Many2many, SearchFilter, Container, ContainerWidget, Text, ProgressBar, Notebook, Group, Page, Label, Separator, Button, Reference, Binary, Image, parseContext, transformDomainForChildWidget, Timeline, Indicator, Dashboard, DashboardItem, Graph, GraphAxis, GraphIndicator, GraphLine, GraphType, parseGraph, };
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,6 @@ import Timeline from "./Timeline";
|
|
|
33
33
|
import Indicator from "./Indicator";
|
|
34
34
|
import Dashboard from "./Dashboard";
|
|
35
35
|
import DashboardItem from "./DashboardItem";
|
|
36
|
-
import Graph from "./Graph";
|
|
37
|
-
export { Char, Selection, Many2one, Field, Widget, Form, Tree, Boolean, One2many, Integer, Float, FloatTime, Date, DateTime, Many2many, SearchFilter, Container, ContainerWidget, Text, ProgressBar, Notebook, Group, Page, Label, Separator, Button, Reference, Binary, Image, parseContext, transformDomainForChildWidget, Timeline, Indicator, Dashboard, DashboardItem, Graph };
|
|
36
|
+
import { Graph, GraphAxis, GraphIndicator, GraphLine, parseGraph, } from "./Graph";
|
|
37
|
+
export { Char, Selection, Many2one, Field, Widget, Form, Tree, Boolean, One2many, Integer, Float, FloatTime, Date, DateTime, Many2many, SearchFilter, Container, ContainerWidget, Text, ProgressBar, Notebook, Group, Page, Label, Separator, Button, Reference, Binary, Image, parseContext, transformDomainForChildWidget, Timeline, Indicator, Dashboard, DashboardItem, Graph, GraphAxis, GraphIndicator, GraphLine, parseGraph, };
|
|
38
38
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,IAAI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,EACL,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,SAAS,EACT,eAAe,EACf,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,KAAK,EACL,SAAS,EACT,MAAM,EACN,SAAS,EACT,MAAM,EACN,KAAK,EACL,YAAY,EACZ,6BAA6B,EAC7B,QAAQ,EACR,SAAS,EACT,SAAS,EACT,aAAa,EACb,KAAK,EACL,SAAS,EACT,cAAc,EACd,SAAS,EAET,UAAU,GACX,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type GraphType = "indicator" | "line" | "bar" | "pie";
|
|
2
|
+
|
|
3
|
+
export class Graph {
|
|
4
|
+
_string: string | null = null;
|
|
5
|
+
get string(): string | null {
|
|
6
|
+
return this._string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
_type?: GraphType;
|
|
10
|
+
get type(): GraphType | undefined {
|
|
11
|
+
return this._type;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
constructor(element: HTMLElement) {
|
|
15
|
+
this._string = element.getAttribute("string");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type Axis = "x" | "y";
|
|
2
|
+
export type Operator = "+";
|
|
3
|
+
|
|
4
|
+
export class GraphAxis {
|
|
5
|
+
_name: string | undefined;
|
|
6
|
+
get name(): string | undefined {
|
|
7
|
+
return this._name;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
_axis: Axis | undefined;
|
|
11
|
+
get axis(): Axis | undefined {
|
|
12
|
+
return this._axis;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
_operator: Operator | undefined;
|
|
16
|
+
get operator(): Operator | undefined {
|
|
17
|
+
return this._operator;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
constructor({
|
|
21
|
+
name,
|
|
22
|
+
axis,
|
|
23
|
+
operator,
|
|
24
|
+
}: {
|
|
25
|
+
name: string;
|
|
26
|
+
axis: Axis;
|
|
27
|
+
operator?: Operator;
|
|
28
|
+
}) {
|
|
29
|
+
this._name = name;
|
|
30
|
+
this._axis = axis;
|
|
31
|
+
this._operator = operator;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { GraphIndicator } from "./GraphIndicator";
|
|
2
|
+
import { GraphLine } from "./GraphLine";
|
|
3
|
+
|
|
4
|
+
const GraphTypes: { [key: string]: any } = {
|
|
5
|
+
indicator: GraphIndicator,
|
|
6
|
+
line: GraphLine,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const parseGraph = (xml: string): GraphIndicator | GraphLine => {
|
|
10
|
+
const parser = new DOMParser();
|
|
11
|
+
const view: Document = parser.parseFromString(xml, "text/xml");
|
|
12
|
+
|
|
13
|
+
const type = view.documentElement.getAttribute("type");
|
|
14
|
+
|
|
15
|
+
if (!type) {
|
|
16
|
+
throw new Error(`${type} is not a valid graph`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const graphModel = GraphTypes[type];
|
|
20
|
+
|
|
21
|
+
if (!graphModel) {
|
|
22
|
+
throw new Error(`${type} not found as a GraphModel`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return new graphModel(view.documentElement);
|
|
26
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Graph } from "./Graph";
|
|
2
|
+
|
|
3
|
+
export class GraphIndicator extends Graph {
|
|
4
|
+
_color: string | null = null;
|
|
5
|
+
get color(): string | null {
|
|
6
|
+
return this._color;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
_icon: string | null = null;
|
|
10
|
+
get icon(): string | null {
|
|
11
|
+
return this._icon;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
_totalDomain: string | null = null;
|
|
15
|
+
get totalDomain(): string | null {
|
|
16
|
+
return this._totalDomain;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
_showPercent: boolean = false;
|
|
20
|
+
get showPercent(): boolean {
|
|
21
|
+
return this._showPercent;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_suffix: string | null = null;
|
|
25
|
+
get suffix(): string | null {
|
|
26
|
+
return this._suffix;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
constructor(element: HTMLElement) {
|
|
30
|
+
super(element);
|
|
31
|
+
|
|
32
|
+
this._type = "indicator";
|
|
33
|
+
this._color = element.getAttribute("color");
|
|
34
|
+
this._icon = element.getAttribute("icon");
|
|
35
|
+
this._suffix = element.getAttribute("suffix");
|
|
36
|
+
this._totalDomain = element.getAttribute("totalDomain");
|
|
37
|
+
const showPercent = element.getAttribute("showPercent");
|
|
38
|
+
|
|
39
|
+
if (
|
|
40
|
+
showPercent &&
|
|
41
|
+
(showPercent === "1" ||
|
|
42
|
+
(typeof showPercent === "boolean" && showPercent === true))
|
|
43
|
+
) {
|
|
44
|
+
this._showPercent = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { GraphAxis } from ".";
|
|
2
|
+
import { Graph } from "./Graph";
|
|
3
|
+
import { parseXYAxis } from "./graphHelper";
|
|
4
|
+
|
|
5
|
+
export class GraphLine extends Graph {
|
|
6
|
+
_x: GraphAxis | undefined;
|
|
7
|
+
get x(): GraphAxis | undefined {
|
|
8
|
+
return this._x;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
_y: GraphAxis | undefined;
|
|
12
|
+
get y(): GraphAxis | undefined {
|
|
13
|
+
return this._y;
|
|
14
|
+
}
|
|
15
|
+
constructor(element: HTMLElement) {
|
|
16
|
+
super(element);
|
|
17
|
+
|
|
18
|
+
this._type = "line";
|
|
19
|
+
|
|
20
|
+
const xyAxis = parseXYAxis(element.childNodes);
|
|
21
|
+
this._x = xyAxis.x;
|
|
22
|
+
this._y = xyAxis.y;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Axis, GraphAxis, Operator } from ".";
|
|
2
|
+
|
|
3
|
+
export type XYAxis = {
|
|
4
|
+
x: GraphAxis;
|
|
5
|
+
y: GraphAxis;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const parseXYAxis = (nodes: NodeListOf<ChildNode>): XYAxis => {
|
|
9
|
+
const xyAxis: any = {};
|
|
10
|
+
|
|
11
|
+
Array.prototype.forEach.call(nodes, (child: Element) => {
|
|
12
|
+
if (child.nodeType === child.ELEMENT_NODE) {
|
|
13
|
+
if (child.nodeName === "field") {
|
|
14
|
+
}
|
|
15
|
+
const axis = child.getAttribute("axis");
|
|
16
|
+
const operator = child.getAttribute("operator");
|
|
17
|
+
const name = child.getAttribute("name");
|
|
18
|
+
|
|
19
|
+
if (!axis) {
|
|
20
|
+
throw new Error(`Field ${name} doesn't have an axis`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (!name) {
|
|
24
|
+
throw new Error("Missing name attribute for field");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const graphAxis = new GraphAxis({
|
|
28
|
+
axis: axis as Axis,
|
|
29
|
+
name,
|
|
30
|
+
operator: operator as Operator,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
if (axis === "x") {
|
|
34
|
+
xyAxis.x = graphAxis;
|
|
35
|
+
} else if (axis === "y") {
|
|
36
|
+
xyAxis.y = graphAxis;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return xyAxis as XYAxis;
|
|
42
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -33,7 +33,14 @@ import Timeline from "./Timeline";
|
|
|
33
33
|
import Indicator from "./Indicator";
|
|
34
34
|
import Dashboard from "./Dashboard";
|
|
35
35
|
import DashboardItem from "./DashboardItem";
|
|
36
|
-
import
|
|
36
|
+
import {
|
|
37
|
+
Graph,
|
|
38
|
+
GraphAxis,
|
|
39
|
+
GraphIndicator,
|
|
40
|
+
GraphLine,
|
|
41
|
+
GraphType,
|
|
42
|
+
parseGraph,
|
|
43
|
+
} from "./Graph";
|
|
37
44
|
|
|
38
45
|
export {
|
|
39
46
|
Char,
|
|
@@ -71,5 +78,10 @@ export {
|
|
|
71
78
|
Indicator,
|
|
72
79
|
Dashboard,
|
|
73
80
|
DashboardItem,
|
|
74
|
-
Graph
|
|
81
|
+
Graph,
|
|
82
|
+
GraphAxis,
|
|
83
|
+
GraphIndicator,
|
|
84
|
+
GraphLine,
|
|
85
|
+
GraphType,
|
|
86
|
+
parseGraph,
|
|
75
87
|
};
|
package/src/spec/Graph.spec.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { GraphIndicator, GraphLine, parseGraph } from "..";
|
|
2
2
|
|
|
3
3
|
describe("A Graph", () => {
|
|
4
4
|
it("should parse a basic XML title and type indicator", () => {
|
|
@@ -6,11 +6,30 @@ describe("A Graph", () => {
|
|
|
6
6
|
<graph string="My indicator" type="indicator" color="red:debt>0;green:debt==0" icon="slack" />
|
|
7
7
|
`;
|
|
8
8
|
|
|
9
|
-
const graph =
|
|
9
|
+
const graph = parseGraph(xml) as GraphIndicator;
|
|
10
10
|
|
|
11
11
|
expect(graph.string).toBe("My indicator");
|
|
12
12
|
expect(graph.type).toBe("indicator");
|
|
13
13
|
expect(graph.color).toBe("red:debt>0;green:debt==0");
|
|
14
14
|
expect(graph.icon).toBe("slack");
|
|
15
15
|
});
|
|
16
|
+
it("should parse a chart graph XML with type line", () => {
|
|
17
|
+
const xml = `<?xml version="1.0"?>
|
|
18
|
+
<graph type="line">
|
|
19
|
+
<field name="data_alta" axis="x"/>
|
|
20
|
+
<field name="data_alta" operator="+" axis="y"/>
|
|
21
|
+
</graph>
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
const graph = parseGraph(xml) as GraphLine;
|
|
25
|
+
expect(graph.type).toBe("line");
|
|
26
|
+
expect(graph.x).toBeDefined();
|
|
27
|
+
expect(graph.y).toBeDefined();
|
|
28
|
+
expect(graph.x?.name).toBe("data_alta");
|
|
29
|
+
expect(graph.y?.name).toBe("data_alta");
|
|
30
|
+
expect(graph.x?.axis).toBe("x");
|
|
31
|
+
expect(graph.y?.axis).toBe("y");
|
|
32
|
+
expect(graph.x?.operator).toBeNull();
|
|
33
|
+
expect(graph.y?.operator).toBe("+");
|
|
34
|
+
});
|
|
16
35
|
});
|
package/dist/Graph.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
var Graph = /** @class */ (function () {
|
|
2
|
-
function Graph(xml) {
|
|
3
|
-
this._string = null;
|
|
4
|
-
this._color = null;
|
|
5
|
-
this._icon = null;
|
|
6
|
-
this._suffix = null;
|
|
7
|
-
this._totalDomain = null;
|
|
8
|
-
this._showPercent = false;
|
|
9
|
-
var parser = new DOMParser();
|
|
10
|
-
var view = parser.parseFromString(xml, "text/xml");
|
|
11
|
-
this._string = view.documentElement.getAttribute("string");
|
|
12
|
-
var type = view.documentElement.getAttribute("type");
|
|
13
|
-
this._color = view.documentElement.getAttribute("color");
|
|
14
|
-
this._icon = view.documentElement.getAttribute("icon");
|
|
15
|
-
this._totalDomain = view.documentElement.getAttribute("totalDomain");
|
|
16
|
-
this._suffix = view.documentElement.getAttribute("suffix");
|
|
17
|
-
var showPercent = view.documentElement.getAttribute("showPercent");
|
|
18
|
-
if (showPercent &&
|
|
19
|
-
(showPercent === "1" ||
|
|
20
|
-
(typeof showPercent === "boolean" && showPercent === true))) {
|
|
21
|
-
this._showPercent = true;
|
|
22
|
-
}
|
|
23
|
-
if (type === "indicator") {
|
|
24
|
-
this._type = "indicator";
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
Object.defineProperty(Graph.prototype, "string", {
|
|
28
|
-
get: function () {
|
|
29
|
-
return this._string;
|
|
30
|
-
},
|
|
31
|
-
enumerable: false,
|
|
32
|
-
configurable: true
|
|
33
|
-
});
|
|
34
|
-
Object.defineProperty(Graph.prototype, "type", {
|
|
35
|
-
get: function () {
|
|
36
|
-
return this._type;
|
|
37
|
-
},
|
|
38
|
-
enumerable: false,
|
|
39
|
-
configurable: true
|
|
40
|
-
});
|
|
41
|
-
Object.defineProperty(Graph.prototype, "color", {
|
|
42
|
-
get: function () {
|
|
43
|
-
return this._color;
|
|
44
|
-
},
|
|
45
|
-
enumerable: false,
|
|
46
|
-
configurable: true
|
|
47
|
-
});
|
|
48
|
-
Object.defineProperty(Graph.prototype, "icon", {
|
|
49
|
-
get: function () {
|
|
50
|
-
return this._icon;
|
|
51
|
-
},
|
|
52
|
-
enumerable: false,
|
|
53
|
-
configurable: true
|
|
54
|
-
});
|
|
55
|
-
Object.defineProperty(Graph.prototype, "suffix", {
|
|
56
|
-
get: function () {
|
|
57
|
-
return this._suffix;
|
|
58
|
-
},
|
|
59
|
-
enumerable: false,
|
|
60
|
-
configurable: true
|
|
61
|
-
});
|
|
62
|
-
Object.defineProperty(Graph.prototype, "totalDomain", {
|
|
63
|
-
get: function () {
|
|
64
|
-
return this._totalDomain;
|
|
65
|
-
},
|
|
66
|
-
enumerable: false,
|
|
67
|
-
configurable: true
|
|
68
|
-
});
|
|
69
|
-
Object.defineProperty(Graph.prototype, "showPercent", {
|
|
70
|
-
get: function () {
|
|
71
|
-
return this._showPercent;
|
|
72
|
-
},
|
|
73
|
-
enumerable: false,
|
|
74
|
-
configurable: true
|
|
75
|
-
});
|
|
76
|
-
return Graph;
|
|
77
|
-
}());
|
|
78
|
-
export default Graph;
|
|
79
|
-
//# sourceMappingURL=Graph.js.map
|
package/dist/Graph.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Graph.js","sourceRoot":"","sources":["../src/Graph.ts"],"names":[],"mappings":"AAEA;IAoCE,eAAY,GAAW;QAnCvB,YAAO,GAAkB,IAAI,CAAC;QAU9B,WAAM,GAAkB,IAAI,CAAC;QAK7B,UAAK,GAAkB,IAAI,C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ACpB,CAAC;;;OAAA;IAGD,sBAAI,wBAAK;aAAT;YACE,OAAO,IAAI,CAAC,MAAM,CAAC;QACrB,CAAC;;;OAAA;IAGD,sBAAI,uBAAI;aAAR;YACE,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;;;OAAA;IAGD,sBAAI,yBAAM;aAAV;YACE,OAAO,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC;;;OAAA;IAGD,sBAAI,8BAAW;aAAf;YACE,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;;;OAAA;IAGD,sBAAI,8BAAW;aAAf;YACE,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;;;OAAA;IA0BH,YAAC;AAAD,CAAC,AA5DD,IA4DC;AAED,eAAe,KAAK,CAAC"}
|
package/src/Graph.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
export type GraphType = "indicator";
|
|
2
|
-
|
|
3
|
-
class Graph {
|
|
4
|
-
_string: string | null = null;
|
|
5
|
-
get string(): string | null {
|
|
6
|
-
return this._string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
_type?: GraphType;
|
|
10
|
-
get type(): GraphType | undefined {
|
|
11
|
-
return this._type;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
_color: string | null = null;
|
|
15
|
-
get color(): string | null {
|
|
16
|
-
return this._color;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
_icon: string | null = null;
|
|
20
|
-
get icon(): string | null {
|
|
21
|
-
return this._icon;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
_suffix: string | null = null;
|
|
25
|
-
get suffix(): string | null {
|
|
26
|
-
return this._suffix;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
_totalDomain: string | null = null;
|
|
30
|
-
get totalDomain(): string | null {
|
|
31
|
-
return this._totalDomain;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
_showPercent: boolean = false;
|
|
35
|
-
get showPercent(): boolean {
|
|
36
|
-
return this._showPercent;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
constructor(xml: string) {
|
|
40
|
-
const parser = new DOMParser();
|
|
41
|
-
const view: Document = parser.parseFromString(xml, "text/xml");
|
|
42
|
-
this._string = view.documentElement.getAttribute("string");
|
|
43
|
-
const type = view.documentElement.getAttribute("type");
|
|
44
|
-
|
|
45
|
-
this._color = view.documentElement.getAttribute("color");
|
|
46
|
-
this._icon = view.documentElement.getAttribute("icon");
|
|
47
|
-
this._totalDomain = view.documentElement.getAttribute("totalDomain");
|
|
48
|
-
this._suffix = view.documentElement.getAttribute("suffix");
|
|
49
|
-
|
|
50
|
-
const showPercent = view.documentElement.getAttribute("showPercent");
|
|
51
|
-
if (
|
|
52
|
-
showPercent &&
|
|
53
|
-
(showPercent === "1" ||
|
|
54
|
-
(typeof showPercent === "boolean" && showPercent === true))
|
|
55
|
-
) {
|
|
56
|
-
this._showPercent = true;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (type === "indicator") {
|
|
60
|
-
this._type = "indicator";
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export default Graph;
|