@pie-lib/plot 4.0.4-next.3 → 4.0.4-next.30
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/_virtual/_rolldown/runtime.js +20 -0
- package/dist/draggable.d.ts +13 -0
- package/dist/draggable.js +13 -0
- package/dist/graph-props.d.ts +22 -0
- package/dist/graph-props.js +29 -0
- package/dist/grid-draggable.d.ts +91 -0
- package/dist/grid-draggable.js +168 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +8 -0
- package/dist/label.d.ts +30 -0
- package/dist/label.js +132 -0
- package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +16 -0
- package/dist/node_modules/.bun/invariant@2.2.4/node_modules/invariant/browser.js +28 -0
- package/dist/node_modules/.bun/react-draggable@4.6.0_6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/chunk-D5BXCJ5G.js +503 -0
- package/dist/node_modules/.bun/react-draggable@4.6.0_6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/cjs.js +5 -0
- package/dist/root.d.ts +68 -0
- package/dist/root.js +302 -0
- package/dist/trig.d.ts +41 -0
- package/dist/trig.js +47 -0
- package/dist/types.d.ts +125 -0
- package/dist/types.js +46 -0
- package/dist/utils.d.ts +44 -0
- package/dist/utils.js +82 -0
- package/package.json +35 -25
- package/CHANGELOG.json +0 -17
- package/CHANGELOG.md +0 -838
- package/LICENSE.md +0 -5
- package/lib/draggable.js +0 -44
- package/lib/draggable.js.map +0 -1
- package/lib/graph-props.js +0 -46
- package/lib/graph-props.js.map +0 -1
- package/lib/grid-draggable.js +0 -361
- package/lib/grid-draggable.js.map +0 -1
- package/lib/index.js +0 -44
- package/lib/index.js.map +0 -1
- package/lib/label.js +0 -173
- package/lib/label.js.map +0 -1
- package/lib/root.js +0 -474
- package/lib/root.js.map +0 -1
- package/lib/trig.js +0 -149
- package/lib/trig.js.map +0 -1
- package/lib/types.js +0 -40
- package/lib/types.js.map +0 -1
- package/lib/utils.js +0 -165
- package/lib/utils.js.map +0 -1
- package/src/__tests__/draggable.test.jsx +0 -41
- package/src/__tests__/grid-draggable.test.jsx +0 -487
- package/src/__tests__/root.test.jsx +0 -277
- package/src/__tests__/trig.test.js +0 -163
- package/src/__tests__/utils.test.js +0 -229
- package/src/draggable.jsx +0 -11
- package/src/graph-props.js +0 -34
- package/src/grid-draggable.jsx +0 -332
- package/src/index.js +0 -9
- package/src/label.jsx +0 -199
- package/src/root.jsx +0 -485
- package/src/trig.js +0 -151
- package/src/types.js +0 -41
- package/src/utils.js +0 -167
package/src/utils.js
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import invariant from 'invariant';
|
|
2
|
-
import { head, isEqual, range, tail } from 'lodash-es';
|
|
3
|
-
import Point from '@mapbox/point-geometry';
|
|
4
|
-
|
|
5
|
-
export const xy = (x, y) => ({ x, y });
|
|
6
|
-
|
|
7
|
-
export const buildSizeArray = (size, padding) => {
|
|
8
|
-
padding = Number.isFinite(padding) ? Math.max(padding, 0) : 0;
|
|
9
|
-
invariant(padding < size, 'padding must be less than size');
|
|
10
|
-
const half = Math.round(padding * 0.5);
|
|
11
|
-
return [half, size - half];
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const tickCount = (min, max, step) => {
|
|
15
|
-
invariant(min < max, 'min must be less than max');
|
|
16
|
-
const size = Math.abs(min - max);
|
|
17
|
-
return Math.round(size / step);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export function getInterval(domain, ticks) {
|
|
21
|
-
const { min, max } = domain;
|
|
22
|
-
const { major, minor } = ticks;
|
|
23
|
-
|
|
24
|
-
if (min >= max) {
|
|
25
|
-
throw new Error(`min is > max: ${min} > ${max}`);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const distance = max - min;
|
|
29
|
-
const minorTicks = minor > 0 ? minor + 1 : 1;
|
|
30
|
-
const normalizedMajor = major - 1;
|
|
31
|
-
|
|
32
|
-
if (isNaN(normalizedMajor)) {
|
|
33
|
-
throw new Error('Tick Frequency must be 2 or higher');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (normalizedMajor <= 0) {
|
|
37
|
-
throw new Error('Tick Frequency must be 2 or higher');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const divider = normalizedMajor * minorTicks;
|
|
41
|
-
const raw = distance / divider;
|
|
42
|
-
return parseFloat(Number(raw).toFixed(4));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const mkRange = (min, max, interval) => {
|
|
46
|
-
const raw = range(min, max, interval);
|
|
47
|
-
/* Fix the last step due to rounding errors */
|
|
48
|
-
raw.splice(raw.length, 1, max);
|
|
49
|
-
return raw;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export function snapTo(min, max, interval, value) {
|
|
53
|
-
if (value >= max) {
|
|
54
|
-
return max;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (value <= min) {
|
|
58
|
-
return min;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
let rng = mkRange(min, max, interval);
|
|
62
|
-
|
|
63
|
-
rng = rng.filter((v) => {
|
|
64
|
-
return Math.abs(value - v) <= interval;
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
rng.length &&
|
|
69
|
-
rng.reduce((prev, curr) => {
|
|
70
|
-
const currentDistance = Math.abs(curr - value);
|
|
71
|
-
const previousDistance = Math.abs(prev - value);
|
|
72
|
-
return currentDistance <= previousDistance ? curr : prev;
|
|
73
|
-
})
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function buildTickModel(domain, ticks, interval, scaleFn) {
|
|
78
|
-
const rng = mkRange(domain.min, domain.max, interval);
|
|
79
|
-
|
|
80
|
-
return rng.map((r, index) => {
|
|
81
|
-
const isMajor = index % (ticks.minor + 1) === 0;
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
value: r,
|
|
85
|
-
major: isMajor,
|
|
86
|
-
x: scaleFn(r),
|
|
87
|
-
};
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export const polygonToArea = (points) => {
|
|
92
|
-
const h = head(points);
|
|
93
|
-
const area = {
|
|
94
|
-
left: h.x,
|
|
95
|
-
top: h.y,
|
|
96
|
-
bottom: h.y,
|
|
97
|
-
right: h.x,
|
|
98
|
-
};
|
|
99
|
-
return tail(points).reduce((a, p) => {
|
|
100
|
-
a.left = Math.min(a.left, p.x);
|
|
101
|
-
a.top = Math.max(a.top, p.y);
|
|
102
|
-
a.bottom = Math.min(a.bottom, p.y);
|
|
103
|
-
a.right = Math.max(a.right, p.x);
|
|
104
|
-
return a;
|
|
105
|
-
}, area);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export const lineToArea = (from, to) => {
|
|
109
|
-
const left = Math.min(from.x, to.x);
|
|
110
|
-
const top = Math.max(from.y, to.y);
|
|
111
|
-
const bottom = Math.min(from.y, to.y);
|
|
112
|
-
const right = Math.max(from.x, to.x);
|
|
113
|
-
return { left, top, bottom, right };
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export const bounds = (area, domain, range) => {
|
|
117
|
-
return {
|
|
118
|
-
left: domain.min - area.left,
|
|
119
|
-
right: Math.abs(area.right - domain.max),
|
|
120
|
-
top: Math.abs(area.top - range.max),
|
|
121
|
-
bottom: range.min - area.bottom,
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
export const point = (o) => new Point(o.x, o.y);
|
|
126
|
-
export const getDelta = (from, to) => {
|
|
127
|
-
return point(to).sub(point(from));
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
export const bandKey = (d, index) => `${index}-${d.label || '-'}`;
|
|
131
|
-
|
|
132
|
-
export const isDomainRangeEqual = (graphProps, nextGraphProps) => {
|
|
133
|
-
return isEqual(graphProps.domain, nextGraphProps.domain) && isEqual(graphProps.range, nextGraphProps.range);
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
// findLongestWord is also used in graphing
|
|
137
|
-
export const findLongestWord = (label) => {
|
|
138
|
-
let longestWord = (label || '')
|
|
139
|
-
.replace(/<[^>]+>/g, '')
|
|
140
|
-
.split(' ')
|
|
141
|
-
.sort((a, b) => b.length - a.length);
|
|
142
|
-
|
|
143
|
-
return longestWord[0].length;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
// amountToIncreaseWidth is also used in graphing
|
|
147
|
-
export const amountToIncreaseWidth = (longestWord) => {
|
|
148
|
-
if (!longestWord) {
|
|
149
|
-
return 0;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return longestWord * 20;
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export const extractTextFromHTML = (htmlString) => {
|
|
156
|
-
const parser = new DOMParser();
|
|
157
|
-
const doc = parser?.parseFromString(htmlString, 'text/html');
|
|
158
|
-
return doc?.body?.textContent || '';
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
export const isEmptyObject = (obj) => {
|
|
162
|
-
return obj && Object.keys(obj).length === 0 && obj.constructor === Object;
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
export const isEmptyString = (str) => {
|
|
166
|
-
return typeof str === 'string' && str.trim() === '';
|
|
167
|
-
};
|