@gisce/ooui 0.2.12 → 0.2.13

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.
Files changed (41) hide show
  1. package/dist/{Graph/GraphIndicator.d.ts → Graph.d.ts} +10 -5
  2. package/dist/Graph.js +79 -0
  3. package/dist/Graph.js.map +1 -0
  4. package/dist/index.d.ts +2 -2
  5. package/dist/index.js +2 -2
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/Graph.ts +65 -0
  9. package/src/index.ts +2 -14
  10. package/src/spec/Graph.spec.ts +16 -0
  11. package/dist/Graph/Graph.d.ts +0 -8
  12. package/dist/Graph/Graph.js +0 -23
  13. package/dist/Graph/Graph.js.map +0 -1
  14. package/dist/Graph/Graph.spec.d.ts +0 -1
  15. package/dist/Graph/Graph.spec.js +0 -26
  16. package/dist/Graph/Graph.spec.js.map +0 -1
  17. package/dist/Graph/GraphAxis.d.ts +0 -15
  18. package/dist/Graph/GraphAxis.js +0 -32
  19. package/dist/Graph/GraphAxis.js.map +0 -1
  20. package/dist/Graph/GraphFactory.d.ts +0 -3
  21. package/dist/Graph/GraphFactory.js +0 -20
  22. package/dist/Graph/GraphFactory.js.map +0 -1
  23. package/dist/Graph/GraphIndicator.js +0 -75
  24. package/dist/Graph/GraphIndicator.js.map +0 -1
  25. package/dist/Graph/GraphLine.d.ts +0 -9
  26. package/dist/Graph/GraphLine.js +0 -43
  27. package/dist/Graph/GraphLine.js.map +0 -1
  28. package/dist/Graph/graphHelper.d.ts +0 -6
  29. package/dist/Graph/graphHelper.js +0 -32
  30. package/dist/Graph/graphHelper.js.map +0 -1
  31. package/dist/Graph/index.d.ts +0 -5
  32. package/dist/Graph/index.js +0 -6
  33. package/dist/Graph/index.js.map +0 -1
  34. package/src/Graph/Graph.spec.ts +0 -36
  35. package/src/Graph/Graph.ts +0 -17
  36. package/src/Graph/GraphAxis.ts +0 -33
  37. package/src/Graph/GraphFactory.ts +0 -26
  38. package/src/Graph/GraphIndicator.ts +0 -47
  39. package/src/Graph/GraphLine.ts +0 -24
  40. package/src/Graph/graphHelper.ts +0 -42
  41. package/src/Graph/index.ts +0 -5
@@ -1,14 +1,19 @@
1
- import { Graph } from "./Graph";
2
- export declare class GraphIndicator extends Graph {
1
+ export declare type GraphType = "indicator";
2
+ declare class Graph {
3
+ _string: string | null;
4
+ get string(): string | null;
5
+ _type?: GraphType;
6
+ get type(): GraphType | undefined;
3
7
  _color: string | null;
4
8
  get color(): string | null;
5
9
  _icon: string | null;
6
10
  get icon(): string | null;
11
+ _suffix: string | null;
12
+ get suffix(): string | null;
7
13
  _totalDomain: string | null;
8
14
  get totalDomain(): string | null;
9
15
  _showPercent: boolean;
10
16
  get showPercent(): boolean;
11
- _suffix: string | null;
12
- get suffix(): string | null;
13
- constructor(element: HTMLElement);
17
+ constructor(xml: string);
14
18
  }
19
+ export default Graph;
package/dist/Graph.js ADDED
@@ -0,0 +1,79 @@
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
@@ -0,0 +1 @@
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,CAAC;QAK5B,YAAO,GAAkB,IAAI,CAAC;QAK9B,iBAAY,GAAkB,IAAI,CAAC;QAKnC,iBAAY,GAAY,KAAK,CAAC;QAM5B,IAAM,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC/B,IAAM,IAAI,GAAa,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAC/D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC3D,IAAM,IAAI,GAAG,IAAI,CA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,sBAAI,8BAAW;aAAf;YACE,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;;;OAAA;IA0BH,YAAC;AAAD,CAAC,AA5DD,IA4DC;AAED,eAAe,KAAK,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, 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, };
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 };
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, 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, };
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 };
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,MAAM,QAAQ,CAAC;AAC1B,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,IAAI,MAAM,QAAQ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IAAI,EACJ,SAAS,EACT,QAAQ,EACR,KAAK,EACL,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,OAAO,EACP,KAAK,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,EACN,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/ooui",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "dependencies": {},
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/Graph.ts ADDED
@@ -0,0 +1,65 @@
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;
package/src/index.ts CHANGED
@@ -33,14 +33,7 @@ import Timeline from "./Timeline";
33
33
  import Indicator from "./Indicator";
34
34
  import Dashboard from "./Dashboard";
35
35
  import DashboardItem from "./DashboardItem";
36
- import {
37
- Graph,
38
- GraphAxis,
39
- GraphIndicator,
40
- GraphLine,
41
- GraphType,
42
- parseGraph,
43
- } from "./Graph";
36
+ import Graph from "./Graph";
44
37
 
45
38
  export {
46
39
  Char,
@@ -78,10 +71,5 @@ export {
78
71
  Indicator,
79
72
  Dashboard,
80
73
  DashboardItem,
81
- Graph,
82
- GraphAxis,
83
- GraphIndicator,
84
- GraphLine,
85
- GraphType,
86
- parseGraph,
74
+ Graph
87
75
  };
@@ -0,0 +1,16 @@
1
+ import Graph from "../Graph";
2
+
3
+ describe("A Graph", () => {
4
+ it("should parse a basic XML title and type indicator", () => {
5
+ const xml = `<?xml version="1.0"?>
6
+ <graph string="My indicator" type="indicator" color="red:debt>0;green:debt==0" icon="slack" />
7
+ `;
8
+
9
+ const graph = new Graph(xml);
10
+
11
+ expect(graph.string).toBe("My indicator");
12
+ expect(graph.type).toBe("indicator");
13
+ expect(graph.color).toBe("red:debt>0;green:debt==0");
14
+ expect(graph.icon).toBe("slack");
15
+ });
16
+ });
@@ -1,8 +0,0 @@
1
- export declare type GraphType = "indicator" | "line" | "bar" | "pie";
2
- export declare class Graph {
3
- _string: string | null;
4
- get string(): string | null;
5
- _type?: GraphType;
6
- get type(): GraphType | undefined;
7
- constructor(element: HTMLElement);
8
- }
@@ -1,23 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,26 +0,0 @@
1
- import { parseGraph } from "..";
2
- describe("A Graph", function () {
3
- it("should parse a basic XML title and type indicator", function () {
4
- var xml = "<?xml version=\"1.0\"?>\n <graph string=\"My indicator\" type=\"indicator\" color=\"red:debt>0;green:debt==0\" icon=\"slack\" />\n ";
5
- var graph = parseGraph(xml);
6
- expect(graph.string).toBe("My indicator");
7
- expect(graph.type).toBe("indicator");
8
- expect(graph.color).toBe("red:debt>0;green:debt==0");
9
- expect(graph.icon).toBe("slack");
10
- });
11
- it("should parse a chart graph XML with type line", function () {
12
- var _a, _b, _c, _d, _e, _f;
13
- var xml = "<?xml version=\"1.0\"?>\n <graph type=\"line\">\n <field name=\"data_alta\" axis=\"x\"/>\n <field name=\"data_alta\" operator=\"+\" axis=\"y\"/>\n </graph>\n ";
14
- var graph = parseGraph(xml);
15
- expect(graph.type).toBe("line");
16
- expect(graph.x).toBeDefined();
17
- expect(graph.y).toBeDefined();
18
- expect((_a = graph.x) === null || _a === void 0 ? void 0 : _a.name).toBe("data_alta");
19
- expect((_b = graph.y) === null || _b === void 0 ? void 0 : _b.name).toBe("data_alta");
20
- expect((_c = graph.x) === null || _c === void 0 ? void 0 : _c.axis).toBe("x");
21
- expect((_d = graph.y) === null || _d === void 0 ? void 0 : _d.axis).toBe("y");
22
- expect((_e = graph.x) === null || _e === void 0 ? void 0 : _e.operator).toBeNull();
23
- expect((_f = graph.y) === null || _f === void 0 ? void 0 : _f.operator).toBe("+");
24
- });
25
- });
26
- //# sourceMappingURL=Graph.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Graph.spec.js","sourceRoot":"","sources":["../../src/Graph/Graph.spec.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAEhC,QAAQ,CAAC,SAAS,EAAE;IAClB,EAAE,CAAC,mDAAmD,EAAE;QACtD,IAAM,GAAG,GAAG,2IAEX,CAAC;QAEF,IAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAmB,CAAC;QAEhD,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC1C,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACrC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QACrD,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,+CAA+C,EAAE;;QAClD,IAAM,GAAG,GAAG,mLAKX,CAAC;QAEF,IAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAc,CAAC;QAC3C,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAChC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAC9B,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAC9B,MAAM,OAAC,KAAK,CAAC,CAAC,0CAAE,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACxC,MAAM,OAAC,KAAK,CAAC,CAAC,0CAAE,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACxC,MAAM,OAAC,KAAK,CAAC,CAAC,0CAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAChC,MAAM,OAAC,KAAK,CAAC,CAAC,0CAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAChC,MAAM,OAAC,KAAK,CAAC,CAAC,0CAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;QACrC,MAAM,OAAC,KAAK,CAAC,CAAC,0CAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,15 +0,0 @@
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
- }
@@ -1,32 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,3 +0,0 @@
1
- import { GraphIndicator } from "./GraphIndicator";
2
- import { GraphLine } from "./GraphLine";
3
- export declare const parseGraph: (xml: string) => GraphIndicator | GraphLine;
@@ -1,20 +0,0 @@
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
@@ -1 +0,0 @@
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,75 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,9 +0,0 @@
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
- }
@@ -1,43 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,6 +0,0 @@
1
- import { GraphAxis } from ".";
2
- export declare type XYAxis = {
3
- x: GraphAxis;
4
- y: GraphAxis;
5
- };
6
- export declare const parseXYAxis: (nodes: NodeListOf<ChildNode>) => XYAxis;
@@ -1,32 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,5 +0,0 @@
1
- export * from "./Graph";
2
- export * from "./GraphFactory";
3
- export * from "./GraphIndicator";
4
- export * from "./GraphLine";
5
- export * from "./GraphAxis";
@@ -1,6 +0,0 @@
1
- export * from "./Graph";
2
- export * from "./GraphFactory";
3
- export * from "./GraphIndicator";
4
- export * from "./GraphLine";
5
- export * from "./GraphAxis";
6
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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"}
@@ -1,36 +0,0 @@
1
- import { GraphIndicator, GraphLine } from ".";
2
- import { parseGraph } from "..";
3
-
4
- describe("A Graph", () => {
5
- it("should parse a basic XML title and type indicator", () => {
6
- const xml = `<?xml version="1.0"?>
7
- <graph string="My indicator" type="indicator" color="red:debt>0;green:debt==0" icon="slack" />
8
- `;
9
-
10
- const graph = parseGraph(xml) as GraphIndicator;
11
-
12
- expect(graph.string).toBe("My indicator");
13
- expect(graph.type).toBe("indicator");
14
- expect(graph.color).toBe("red:debt>0;green:debt==0");
15
- expect(graph.icon).toBe("slack");
16
- });
17
- it("should parse a chart graph XML with type line", () => {
18
- const xml = `<?xml version="1.0"?>
19
- <graph type="line">
20
- <field name="data_alta" axis="x"/>
21
- <field name="data_alta" operator="+" axis="y"/>
22
- </graph>
23
- `;
24
-
25
- const graph = parseGraph(xml) as GraphLine;
26
- expect(graph.type).toBe("line");
27
- expect(graph.x).toBeDefined();
28
- expect(graph.y).toBeDefined();
29
- expect(graph.x?.name).toBe("data_alta");
30
- expect(graph.y?.name).toBe("data_alta");
31
- expect(graph.x?.axis).toBe("x");
32
- expect(graph.y?.axis).toBe("y");
33
- expect(graph.x?.operator).toBeNull();
34
- expect(graph.y?.operator).toBe("+");
35
- });
36
- });
@@ -1,17 +0,0 @@
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
- }
@@ -1,33 +0,0 @@
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
- }
@@ -1,26 +0,0 @@
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
- };
@@ -1,47 +0,0 @@
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
- }
@@ -1,24 +0,0 @@
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
- }
@@ -1,42 +0,0 @@
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
- };
@@ -1,5 +0,0 @@
1
- export * from "./Graph";
2
- export * from "./GraphFactory";
3
- export * from "./GraphIndicator";
4
- export * from "./GraphLine";
5
- export * from "./GraphAxis";