ag-common 0.0.760 → 0.0.762

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.
@@ -77,12 +77,10 @@ const LegendX = ({ data, lt, tt, colours, style, }) => {
77
77
  tt,
78
78
  }).part;
79
79
  const xs = data.map((a) => a.x);
80
- const ys = data.map((a) => a.y);
81
80
  const minX = Math.min(...xs);
82
81
  const maxX = Math.max(...xs);
83
- const maxY = Math.max(...ys);
84
82
  const itemsRaw = [{ v: minX, group: 0 }];
85
- const gc = 8;
83
+ const gc = 4;
86
84
  const gap = (maxX - minX) / gc;
87
85
  if (gap > common_1.twelveHMs) {
88
86
  for (let a = 1; a < gc; a += 1) {
@@ -91,13 +89,16 @@ const LegendX = ({ data, lt, tt, colours, style, }) => {
91
89
  }
92
90
  itemsRaw.push({ v: maxX, group: 0 });
93
91
  const items = itemsRaw.map((d) => ({ v: lt(d.v), group: d.group }));
94
- const ch = maxY.toString().length + 1;
95
- return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, style), { marginLeft: 'auto', width: `calc(100% - ${ch}ch)` }) },
92
+ return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, style), { width: 'calc(100% - 2.5rem)', marginLeft: '2.5rem' }) },
96
93
  react_1.default.createElement(Bar, null,
97
94
  react_1.default.createElement(Line, { style: { backgroundColor: style.color } }),
98
95
  react_1.default.createElement(Numbers, null, items.map((i, i2) => (react_1.default.createElement("span", {
99
96
  // eslint-disable-next-line react/no-array-index-key
100
- key: i.v + i2, "data-group": i.group, style: { backgroundColor: style.backgroundColor } }, i.v))))),
97
+ key: i.v + i2, "data-group": i.group, style: {
98
+ backgroundColor: style.backgroundColor,
99
+ writingMode: 'vertical-rl',
100
+ textOrientation: 'mixed',
101
+ } }, i.v))))),
101
102
  legendItems.length > 1 && (react_1.default.createElement(Items, null, legendItems.map((k) => (react_1.default.createElement(Item, { key: k.name },
102
103
  react_1.default.createElement(Col, { style: { backgroundColor: k.colour } }),
103
104
  k.name)))))));
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.LegendY = void 0;
7
7
  const styled_1 = __importDefault(require("@emotion/styled"));
8
8
  const react_1 = __importDefault(require("react"));
9
+ const math_1 = require("../../../common/helpers/math");
9
10
  const Base = styled_1.default.div `
10
11
  display: flex;
11
12
  flex-flow: row;
@@ -32,20 +33,12 @@ const LegendY = ({ data, style, }) => {
32
33
  items.push(Math.floor(items[a - 1] + gap));
33
34
  }
34
35
  items.push(maxY);
35
- const ch = maxY.toString().length;
36
- const roundNumber = (num) => {
37
- // Round to 2 decimal places and remove trailing zeros
38
- const rounded = Math.round(num * 100) / 100;
39
- return rounded % 1 === 0
40
- ? rounded.toString()
41
- : rounded.toFixed(2).replace(/\.?0+$/, '');
42
- };
43
- return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, style), { maxWidth: `${ch}ch`, paddingRight: '1ch' }) },
36
+ return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, style), { width: '2.5rem', paddingRight: '1ch' }) },
44
37
  react_1.default.createElement(Numbers, null, items.map((i, i2) => (react_1.default.createElement("span", {
45
38
  // eslint-disable-next-line react/no-array-index-key
46
39
  key: i + i2, style: {
47
40
  color: style.color,
48
41
  backgroundColor: style.backgroundColor,
49
- } }, roundNumber(i)))))));
42
+ } }, (0, math_1.toFixed)(i, 2)))))));
50
43
  };
51
44
  exports.LegendY = LegendY;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.TooltipContent = void 0;
7
7
  const styled_1 = __importDefault(require("@emotion/styled"));
8
8
  const react_1 = __importDefault(require("react"));
9
+ const math_1 = require("../../../common/helpers/math");
9
10
  const Base = styled_1.default.div `
10
11
  padding: 0.5rem;
11
12
  `;
@@ -34,25 +35,18 @@ const Total = styled_1.default.span `
34
35
  const TooltipContent = (p) => {
35
36
  var _a, _b;
36
37
  const name = p.tt((_b = (_a = p.selectedXs) === null || _a === void 0 ? void 0 : _a[0].x) !== null && _b !== void 0 ? _b : 0);
37
- const roundNumber = (num) => {
38
- // Round to 2 decimal places and remove trailing zeros
39
- const rounded = Math.round(num * 100) / 100;
40
- return rounded % 1 === 0
41
- ? rounded.toString()
42
- : rounded.toFixed(2).replace(/\.?0+$/, '');
43
- };
44
38
  return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, p.style), { border: `solid 1px ${p.style.borderColor}` }) },
45
39
  react_1.default.createElement(Title, null, name),
46
40
  react_1.default.createElement(Row, null,
47
41
  react_1.default.createElement("span", null, "total"),
48
- react_1.default.createElement(Total, null, roundNumber(p.legendItems.total))),
42
+ react_1.default.createElement(Total, null, (0, math_1.toFixed)(p.legendItems.total, 2))),
49
43
  p.legendItems.part.map((v) => (react_1.default.createElement(Row, { key: v.name + v.y, style: { color: v.colour } },
50
44
  react_1.default.createElement(ItemTitle, null, v.name),
51
- react_1.default.createElement(Total, null, roundNumber(v.y))))),
45
+ react_1.default.createElement(Total, null, (0, math_1.toFixed)(v.y, 2))))),
52
46
  p.legendItems.rest.length > 0 && (react_1.default.createElement(Row, null,
53
47
  react_1.default.createElement("span", null,
54
48
  p.legendItems.rest.length,
55
49
  " more"),
56
- react_1.default.createElement(Total, null, roundNumber(p.legendItems.restTotal))))));
50
+ react_1.default.createElement(Total, null, (0, math_1.toFixed)(p.legendItems.restTotal, 2))))));
57
51
  };
58
52
  exports.TooltipContent = TooltipContent;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.760",
2
+ "version": "0.0.762",
3
3
  "name": "ag-common",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",