ag-common 0.0.655 → 0.0.657

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.
@@ -34,6 +34,12 @@ const Svg = styled_1.default.svg `
34
34
  padding: 2px;
35
35
  width: calc(100% - 5px);
36
36
  height: calc(100% - 5px);
37
+
38
+ @keyframes dash {
39
+ to {
40
+ stroke-dashoffset: 1000;
41
+ }
42
+ }
37
43
  `;
38
44
  const LineChart = (p) => {
39
45
  var _a;
@@ -95,9 +101,18 @@ const LineChart = (p) => {
95
101
  } }, points.map((p2) => {
96
102
  var _a, _b, _c;
97
103
  return (react_1.default.createElement(react_1.default.Fragment, { key: JSON.stringify(p2) },
104
+ //mouse selected
98
105
  (p2.origX === ((_c = (_b = (_a = UT.pos) === null || _a === void 0 ? void 0 : _a.data.selectedXs) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.x) ||
99
- p2.x1 === p2.x2) && (react_1.default.createElement("circle", { cx: `${p2.x2}%`, cy: `${p2.y2}%`, r: "8px", fill: p.colours[p2.name] })),
100
- p2.x1 !== p2.x2 && (react_1.default.createElement("line", { strokeOpacity: legendItems.part.find((f) => f.name === p2.name) ? 1 : 0.3, x1: `${p2.x1}%`, x2: `${p2.x2}%`, y1: `${p2.y1}%`, y2: `${p2.y2}%`, style: { stroke: p.colours[p2.name] } }))));
106
+ //only single date point
107
+ p2.x1 === p2.x2 ||
108
+ //is the last point
109
+ p2.isLast) && (react_1.default.createElement("circle", Object.assign({ cx: `${p2.x2}%`, cy: `${p2.y2}%`, r: "8px", style: { zIndex: 1 } }, (p2.isToday && p2.isLast
110
+ ? { stroke: p.colours[p2.name], fill: 'transparent' }
111
+ : { fill: p.colours[p2.name] })))),
112
+ p2.x1 !== p2.x2 && (react_1.default.createElement("line", { strokeOpacity: legendItems.part.find((f) => f.name === p2.name) ? 1 : 0.3, x1: `${p2.x1}%`, x2: `${p2.x2}%`, y1: `${p2.y1}%`, y2: `${p2.y2}%`, style: Object.assign({ stroke: p.colours[p2.name] }, (p2.isToday && {
113
+ strokeDasharray: 10,
114
+ animation: 'dash 50s linear reverse infinite',
115
+ })) }))));
101
116
  })));
102
117
  return (react_1.default.createElement(Base, { className: p.className, "data-type": "lcb", onMouseLeave: () => UT.setPos(undefined), style: style },
103
118
  react_1.default.createElement(UT.Comp, { pos: UT.pos }, (p2) => (react_1.default.createElement(TooltipContent_1.TooltipContent, Object.assign({}, p2, { colours: p.colours, data: p.data, lt: lt2, tt: tt2, legendItems: legendItems, style: style })))),
@@ -7,6 +7,7 @@ exports.LegendX = void 0;
7
7
  const styled_1 = __importDefault(require("@emotion/styled"));
8
8
  const react_1 = __importDefault(require("react"));
9
9
  const common_1 = require("../../../common");
10
+ const styles_1 = require("../../styles");
10
11
  const getLegendItems_1 = require("./getLegendItems");
11
12
  const Base = styled_1.default.div `
12
13
  display: flex;
@@ -33,6 +34,13 @@ const Numbers = styled_1.default.div `
33
34
  flex-flow: row;
34
35
  justify-content: space-between;
35
36
  z-index: 1;
37
+
38
+ @media ${styles_1.smallScreen} {
39
+ [data-group='1'],
40
+ [data-group='2'] {
41
+ display: none;
42
+ }
43
+ }
36
44
  `;
37
45
  const Items = styled_1.default.div `
38
46
  width: 100%;
@@ -73,23 +81,23 @@ const LegendX = ({ data, lt, tt, colours, style, }) => {
73
81
  const minX = Math.min(...xs);
74
82
  const maxX = Math.max(...xs);
75
83
  const maxY = Math.max(...ys);
76
- const itemsRaw = [minX];
84
+ const itemsRaw = [{ v: minX, group: 0 }];
77
85
  const gc = 8;
78
86
  const gap = (maxX - minX) / gc;
79
87
  if (gap > common_1.twelveHMs) {
80
88
  for (let a = 1; a < gc; a += 1) {
81
- itemsRaw.push(itemsRaw[a - 1] + gap);
89
+ itemsRaw.push({ v: itemsRaw[a - 1].v + gap, group: (a % 3) + 1 });
82
90
  }
83
91
  }
84
- itemsRaw.push(maxX);
85
- const items = itemsRaw.map((d) => { var _a; return (_a = lt(d)) !== null && _a !== void 0 ? _a : d; });
92
+ itemsRaw.push({ v: maxX, group: 0 });
93
+ const items = itemsRaw.map((d) => { var _a; return ({ v: (_a = lt(d.v)) !== null && _a !== void 0 ? _a : d.v, group: d.group }); });
86
94
  const ch = maxY.toString().length + 1;
87
95
  return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, style), { marginLeft: 'auto', width: `calc(100% - ${ch}ch)` }) },
88
96
  react_1.default.createElement(Bar, null,
89
97
  react_1.default.createElement(Line, { style: { backgroundColor: style.color } }),
90
98
  react_1.default.createElement(Numbers, null, items.map((i, i2) => (react_1.default.createElement("span", {
91
99
  // eslint-disable-next-line react/no-array-index-key
92
- key: i + i2, style: { backgroundColor: style.backgroundColor } }, i))))),
100
+ key: i.v + i2, "data-group": i.group, style: { backgroundColor: style.backgroundColor } }, i.v))))),
93
101
  legendItems.length > 1 && (react_1.default.createElement(Items, null, legendItems.map((k) => (react_1.default.createElement(Item, { key: k.name },
94
102
  react_1.default.createElement(Col, { style: { backgroundColor: k.colour } }),
95
103
  k.name)))))));
@@ -1,2 +1,3 @@
1
1
  export declare const timeLegendTitle: (s: number) => string;
2
2
  export declare const timeTooltipTitle: (s: number) => string;
3
+ export declare const isToday: (s: number) => boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.timeTooltipTitle = exports.timeLegendTitle = void 0;
3
+ exports.isToday = exports.timeTooltipTitle = exports.timeLegendTitle = void 0;
4
4
  const date_1 = require("../../helpers/date");
5
5
  const timeLegendTitle = (s) => {
6
6
  const ret = (0, date_1.getDMY)(new Date(s), { short: true });
@@ -26,3 +26,11 @@ const timeTooltipTitle = (s) => {
26
26
  return `${dmy} ${diff}`;
27
27
  };
28
28
  exports.timeTooltipTitle = timeTooltipTitle;
29
+ const isToday = (s) => {
30
+ if (!s) {
31
+ return false;
32
+ }
33
+ const td = new Date().getTime() - Number(s);
34
+ return td < 0;
35
+ };
36
+ exports.isToday = isToday;
@@ -7,6 +7,8 @@ interface ILineChartItemComp {
7
7
  name: string;
8
8
  origX: number;
9
9
  origY: number;
10
+ isToday: boolean;
11
+ isLast: boolean;
10
12
  }
11
13
  export declare const interpolate: (raw: ILineChartItemRaw[]) => {
12
14
  points: ILineChartItemComp[];
@@ -4,6 +4,7 @@ exports.interpolate = void 0;
4
4
  const common_1 = require("../../../common");
5
5
  const math_1 = require("../../../common/helpers/math");
6
6
  const date_1 = require("../../helpers/date");
7
+ const dateHelpers_1 = require("./dateHelpers");
7
8
  const interpolate = (raw) => {
8
9
  const points = [];
9
10
  const xs = raw.map((r) => r.x);
@@ -46,6 +47,8 @@ const interpolate = (raw) => {
46
47
  name: p.name,
47
48
  origX: p.x,
48
49
  origY: p.y,
50
+ isToday: (0, dateHelpers_1.isToday)(p.x),
51
+ isLast: i === items.length - 1,
49
52
  };
50
53
  });
51
54
  points.push(...(0, common_1.distinctBy)(p, (s) => JSON.stringify(s)));
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.655",
2
+ "version": "0.0.657",
3
3
  "name": "ag-common",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",