@gisce/react-ooui 1.2.0-rc.48 → 1.2.0-rc.49

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.
@@ -3,10 +3,13 @@ declare const DefaultGraphOptions: {
3
3
  padding: string;
4
4
  xAxis: {
5
5
  tickCount: number;
6
+ label: {
7
+ formatter: (value: any) => any;
8
+ };
6
9
  };
7
10
  yAxis: {
8
11
  label: {
9
- formatter: (value: number) => string;
12
+ formatter: (value: any) => any;
10
13
  };
11
14
  };
12
15
  legend: {
@@ -58,9 +61,14 @@ declare const DefaultGraphOptions: {
58
61
  value: any;
59
62
  };
60
63
  };
64
+ xAxis: {
65
+ label: {
66
+ formatter: (value: any) => any;
67
+ };
68
+ };
61
69
  yAxis: {
62
70
  label: {
63
- formatter: (value: number) => string;
71
+ formatter: (value: any) => any;
64
72
  };
65
73
  };
66
74
  label: {
@@ -1 +1 @@
1
- {"version":3,"file":"GraphDefaults.d.ts","sourceRoot":"","sources":["GraphDefaults.ts"],"names":[],"mappings":"AAUA,QAAA,MAAM,mBAAmB;;;;;;;;mCAQE,MAAM;;;;;;;;gCAjBf,GAAG;;;;;;;;;;;;mCAsCQ,GAAG;;;;;;;;;;;gCAtCd,GAAG;;;;;;;;;;;;;;;;gCAAH,GAAG;;;;;;;mCAoEM,MAAM;;;;;;;;;;CAsBhC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"GraphDefaults.d.ts","sourceRoot":"","sources":["GraphDefaults.ts"],"names":[],"mappings":"AAiCA,QAAA,MAAM,mBAAmB;;;;;;mCAvBK,GAAG;;;;;mCAAH,GAAG;;;;;;;;gCATf,GAAG;;;;;;;;;;;;mCA4DQ,GAAG;;;;;;;;;;;gCA5Dd,GAAG;;;;;;;;;;;;;;;;gCAAH,GAAG;;;;;;;mCASS,GAAG;;;;;mCAAH,GAAG;;;;;;;;;;CAwGhC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/react-ooui",
3
- "version": "1.2.0-rc.48",
3
+ "version": "1.2.0-rc.49",
4
4
  "files": [
5
5
  "dist",
6
6
  "src",
@@ -8,19 +8,41 @@ const formatter = (graphType: "pie" | "default" | "barGrouped") => {
8
8
  };
9
9
  };
10
10
 
11
+ const axisFormatter = (value: any) => {
12
+ if (typeof value === "string" && stringIsValidNumeric(value)) {
13
+ return parseFloat(value).toLocaleString("es-ES", {
14
+ useGrouping: true,
15
+ });
16
+ } else if (isNumber(value)) {
17
+ return value.toLocaleString("es-ES", {
18
+ useGrouping: true,
19
+ });
20
+ } else {
21
+ return value;
22
+ }
23
+ };
24
+
25
+ const stringIsValidNumeric = (value: string) => {
26
+ const regex = /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/;
27
+ return regex.test(value);
28
+ };
29
+
30
+ const isNumber = (value: any) => {
31
+ return typeof value === "number" && !isNaN(value);
32
+ };
33
+
11
34
  const DefaultGraphOptions = {
12
35
  default: {
13
36
  padding: "auto",
14
37
  xAxis: {
15
38
  tickCount: 5,
39
+ label: {
40
+ formatter: axisFormatter,
41
+ },
16
42
  },
17
43
  yAxis: {
18
44
  label: {
19
- formatter: (value: number) => {
20
- return value.toLocaleString("es-ES", {
21
- useGrouping: true,
22
- });
23
- },
45
+ formatter: axisFormatter,
24
46
  },
25
47
  },
26
48
  legend: {
@@ -65,13 +87,14 @@ const DefaultGraphOptions = {
65
87
  tooltip: {
66
88
  formatter: formatter("barGrouped"),
67
89
  },
90
+ xAxis: {
91
+ label: {
92
+ formatter: axisFormatter,
93
+ },
94
+ },
68
95
  yAxis: {
69
96
  label: {
70
- formatter: (value: number) => {
71
- return value.toLocaleString("es-ES", {
72
- useGrouping: true,
73
- });
74
- },
97
+ formatter: axisFormatter,
75
98
  },
76
99
  },
77
100
  label: {