@data-vision/interactive-chart 0.0.8

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 (47) hide show
  1. package/README.md +144 -0
  2. package/build/bar.cjs +1 -0
  3. package/build/bar.d.ts +10 -0
  4. package/build/bar.js +44 -0
  5. package/build/base/chart.d.ts +137 -0
  6. package/build/base/color.d.ts +18 -0
  7. package/build/base/dragable.d.ts +29 -0
  8. package/build/base/field.d.ts +18 -0
  9. package/build/base/index.d.ts +5 -0
  10. package/build/base/point.d.ts +15 -0
  11. package/build/brush/brush.d.ts +49 -0
  12. package/build/brush/crop.d.ts +12 -0
  13. package/build/brush/index.d.ts +2 -0
  14. package/build/brush/range.d.ts +6 -0
  15. package/build/brush/thumb.d.ts +6 -0
  16. package/build/chart-Cj4Fiwnb.js +965 -0
  17. package/build/chart-Dr9ZOezr.cjs +1 -0
  18. package/build/dataset-Bv37sY1L.js +18 -0
  19. package/build/dataset-D4KLCpTU.cjs +1 -0
  20. package/build/heatmap-BlMqliH5.cjs +1 -0
  21. package/build/heatmap-Br4YjrBg.js +859 -0
  22. package/build/heatmap.cjs +1 -0
  23. package/build/heatmap.d.ts +91 -0
  24. package/build/heatmap.js +5 -0
  25. package/build/index.cjs +1 -0
  26. package/build/index.d.ts +7 -0
  27. package/build/index.js +20 -0
  28. package/build/legend/index.d.ts +1 -0
  29. package/build/legend/legend.d.ts +20 -0
  30. package/build/line.cjs +1 -0
  31. package/build/line.d.ts +11 -0
  32. package/build/line.js +23 -0
  33. package/build/otdr.cjs +1 -0
  34. package/build/otdr.d.ts +186 -0
  35. package/build/otdr.js +417 -0
  36. package/build/tooltip/crosshair.d.ts +20 -0
  37. package/build/tooltip/index.d.ts +2 -0
  38. package/build/tooltip/tooltip.d.ts +12 -0
  39. package/build/type.d.ts +78 -0
  40. package/build/util/dataset.d.ts +6 -0
  41. package/build/util/date.d.ts +1 -0
  42. package/build/util/env.d.ts +15 -0
  43. package/build/util/event.d.ts +6 -0
  44. package/build/util/index.d.ts +6 -0
  45. package/build/util/numeric.d.ts +26 -0
  46. package/build/util/style.d.ts +3 -0
  47. package/package.json +53 -0
package/build/otdr.js ADDED
@@ -0,0 +1,417 @@
1
+ import { C as A, d as C, m as S, g as U, c as B } from "./chart-Cj4Fiwnb.js";
2
+ import { a as G } from "./chart-Cj4Fiwnb.js";
3
+ import { f as R } from "./dataset-Bv37sY1L.js";
4
+ var p;
5
+ (function(u) {
6
+ u[u.solid = 0] = "solid", u[u.dashed = 1] = "dashed";
7
+ })(p || (p = {}));
8
+ var c;
9
+ (function(u) {
10
+ u[u.two_points = 0] = "two_points", u[u.four_points = 1] = "four_points", u[u.none = 2] = "none";
11
+ })(c || (c = {}));
12
+ var f;
13
+ (function(u) {
14
+ u.line_A = "A", u.line_B = "B", u.line_a = "a", u.line_b = "b";
15
+ })(f || (f = {}));
16
+ class M {
17
+ constructor(e, t, i) {
18
+ Object.defineProperty(this, "name", {
19
+ enumerable: !0,
20
+ configurable: !0,
21
+ writable: !0,
22
+ value: void 0
23
+ }), Object.defineProperty(this, "color", {
24
+ enumerable: !0,
25
+ configurable: !0,
26
+ writable: !0,
27
+ value: void 0
28
+ }), Object.defineProperty(this, "style", {
29
+ enumerable: !0,
30
+ configurable: !0,
31
+ writable: !0,
32
+ value: p.solid
33
+ }), Object.defineProperty(this, "location", {
34
+ enumerable: !0,
35
+ configurable: !0,
36
+ writable: !0,
37
+ value: void 0
38
+ }), Object.defineProperty(this, "order", {
39
+ enumerable: !0,
40
+ configurable: !0,
41
+ writable: !0,
42
+ value: void 0
43
+ }), this.name = e, this.color = t, i && (this.style = i), this.location = 0, this.order = M.orderMap.get(e) ?? 0;
44
+ }
45
+ copy() {
46
+ return new M(this.name, this.color).copyWith({
47
+ location: this.location,
48
+ style: this.style
49
+ });
50
+ }
51
+ copyWith({ name: e, color: t, style: i, location: s, order: a }) {
52
+ return this.name = e ?? this.name, this.color = t ?? this.color, this.style = i ?? this.style, this.location = s ?? this.location, this.order = a ?? this.order, this;
53
+ }
54
+ }
55
+ Object.defineProperty(M, "orderMap", {
56
+ enumerable: !0,
57
+ configurable: !0,
58
+ writable: !0,
59
+ value: /* @__PURE__ */ new Map()
60
+ });
61
+ class L extends A {
62
+ static initConfig() {
63
+ const e = A.config;
64
+ e.measureLine = {
65
+ a: {
66
+ location: "10%",
67
+ order: 0,
68
+ color: "#f00",
69
+ style: p.dashed
70
+ },
71
+ A: {
72
+ location: "25%",
73
+ order: 1,
74
+ color: "#f00",
75
+ style: p.solid
76
+ },
77
+ B: {
78
+ location: "75%",
79
+ order: 2,
80
+ color: "cyan",
81
+ style: p.solid
82
+ },
83
+ b: {
84
+ location: "90%",
85
+ order: 3,
86
+ color: "cyan",
87
+ style: p.dashed
88
+ }
89
+ }, e.grid.top = 15, L.config = e;
90
+ }
91
+ // @override
92
+ constructor(e) {
93
+ super(e), Object.defineProperty(this, "activeEvent", {
94
+ enumerable: !0,
95
+ configurable: !0,
96
+ writable: !0,
97
+ value: null
98
+ }), Object.defineProperty(this, "measureMode", {
99
+ enumerable: !0,
100
+ configurable: !0,
101
+ writable: !0,
102
+ value: c.none
103
+ }), Object.defineProperty(this, "measureLine_a", {
104
+ enumerable: !0,
105
+ configurable: !0,
106
+ writable: !0,
107
+ value: void 0
108
+ }), Object.defineProperty(this, "measureLine_A", {
109
+ enumerable: !0,
110
+ configurable: !0,
111
+ writable: !0,
112
+ value: void 0
113
+ }), Object.defineProperty(this, "measureLine_B", {
114
+ enumerable: !0,
115
+ configurable: !0,
116
+ writable: !0,
117
+ value: void 0
118
+ }), Object.defineProperty(this, "measureLine_b", {
119
+ enumerable: !0,
120
+ configurable: !0,
121
+ writable: !0,
122
+ value: void 0
123
+ }), Object.defineProperty(this, "activeMeasureLine", {
124
+ enumerable: !0,
125
+ configurable: !0,
126
+ writable: !0,
127
+ value: null
128
+ }), Object.defineProperty(this, "draggedMeasureLine", {
129
+ enumerable: !0,
130
+ configurable: !0,
131
+ writable: !0,
132
+ value: null
133
+ }), Object.defineProperty(this, "onMeasureChange", {
134
+ enumerable: !0,
135
+ configurable: !0,
136
+ writable: !0,
137
+ value: null
138
+ }), this.measureLine_a = this.createMeasureLine(f.line_a), this.measureLine_A = this.createMeasureLine(f.line_A), this.measureLine_B = this.createMeasureLine(f.line_B), this.measureLine_b = this.createMeasureLine(f.line_b);
139
+ }
140
+ createMeasureLine(e) {
141
+ const { color: t, style: i, order: s } = L.config.measureLine[e];
142
+ return M.orderMap.set(e, s), new M(e, t, i);
143
+ }
144
+ mergeDataset(e) {
145
+ const { lineWidth: t = 1, precision: i = 1, events: s = [], ...a } = e;
146
+ return {
147
+ lineWidth: t,
148
+ precision: i,
149
+ events: s,
150
+ ...a
151
+ };
152
+ }
153
+ loopDatasets(e, t) {
154
+ if (e)
155
+ for (const i of e) {
156
+ const s = this.mergeDataset(i);
157
+ t(s);
158
+ }
159
+ }
160
+ // @override
161
+ draw(e) {
162
+ const { width: t, height: i, data: s, scale: a, sample: r } = this;
163
+ this.loopDatasets(s, ({ color: o, data: n, lineWidth: d, precision: m }) => {
164
+ e.lineWidth = d, e.strokeStyle = o, e.beginPath();
165
+ const { start: h, end: v, loop: b } = R(n, m, this.xRange);
166
+ b(a.x, (l, y) => {
167
+ const _ = n.slice(l, Math.min(l + y, v + 1)), w = r(_, L.config.dataSampleMethod), { x, y: g } = this.getDataOffset({
168
+ x: l,
169
+ y: w
170
+ }, m);
171
+ l === h ? e.moveTo(x, g) : e.lineTo(x, g);
172
+ }), e.stroke(), this.snapshot = e.getImageData(0, 0, t, i);
173
+ });
174
+ }
175
+ get measureEnabled() {
176
+ return this.measureMode !== c.none;
177
+ }
178
+ // @override
179
+ drawAnnotations(e) {
180
+ this.measureEnabled && this.drawMeasureLines();
181
+ }
182
+ getDataOffset({ x: e, y: t }, i = 1) {
183
+ const { scaleGrid: s, rect: a, xMin: r, yMin: o, scale: n } = this;
184
+ return {
185
+ x: s.left + (i * e - r) / n.x,
186
+ y: a.y - (t - o) / n.y
187
+ };
188
+ }
189
+ getEventOffset({ offset: e, size: t }) {
190
+ const { x: i, y: s } = this.getDataOffset(e), { width: a, height: r } = t;
191
+ return {
192
+ x: i - a / 2,
193
+ y: s - r * 2
194
+ };
195
+ }
196
+ // @override
197
+ drawSnapshot(e) {
198
+ this.loopDatasets(this.data, (t) => {
199
+ this.drawEvents(t);
200
+ });
201
+ }
202
+ drawEvents(e) {
203
+ const { context: t, activeEvent: i, dpr: s, xMin: a, xMax: r, yMin: o, yMax: n, xUnit: d, yUnit: m } = this, { events: h, color: v } = e;
204
+ for (const b of h) {
205
+ const { x: l, y } = this.getEventOffset(b), { key: _, value: w, offset: x, size: g, image: T, renderLabel: O, renderValue: P } = b;
206
+ if (t.drawImage(T, l, y, g.width, g.height), i?.key === _) {
207
+ t.strokeStyle = v, t.lineWidth = 1, t.strokeRect(l, y, g.width, g.height);
208
+ const [D, E] = [l + g.width / 2, y + g.height];
209
+ t.beginPath(), t.moveTo(D, E), t.lineTo(D, E + 32), t.stroke();
210
+ const j = 16 * s.value;
211
+ t.save(), t.fillStyle = v;
212
+ const k = {
213
+ xMin: a,
214
+ xMax: r,
215
+ yMin: o,
216
+ yMax: n,
217
+ xUnit: d,
218
+ yUnit: m,
219
+ event: b,
220
+ dataset: e
221
+ };
222
+ t.fillText(`${P ? P(w, k) : w}`, l, y - j * 2), t.fillText(`${O ? O(x.x, k) : x.x}`, l, y - j), t.restore();
223
+ }
224
+ }
225
+ }
226
+ setActiveEvent(e) {
227
+ if (this.data) {
228
+ let t = null;
229
+ if (e !== null)
230
+ for (const i of this.data) {
231
+ let s = !1;
232
+ const { events: a } = this.mergeDataset(i);
233
+ for (const r of a)
234
+ if (r.key === e) {
235
+ t = r, s = !0;
236
+ break;
237
+ }
238
+ if (s)
239
+ break;
240
+ }
241
+ if (t?.key !== this.activeEvent?.key) {
242
+ if (t) {
243
+ const { x: i, y: s } = t.offset;
244
+ this.setCenter(i, s);
245
+ }
246
+ return this.activeEvent = t, this.shouldUpdate = !0, !0;
247
+ }
248
+ }
249
+ return !1;
250
+ }
251
+ get measureLines() {
252
+ const { measureMode: e, measureLine_A: t, measureLine_B: i, measureLine_a: s, measureLine_b: a } = this;
253
+ let r = [];
254
+ return e === c.two_points ? r = [
255
+ t,
256
+ i
257
+ ] : e === c.four_points && (r = [
258
+ t,
259
+ s,
260
+ a,
261
+ i
262
+ ]), r;
263
+ }
264
+ // @override
265
+ onMouseMove(e) {
266
+ super.onMouseMove(e);
267
+ const { data: t, context: i, dpr: s, dragging: a } = this, r = this.getOffset(e).multiply(s.value);
268
+ let o = null;
269
+ if (this.loopDatasets(t, ({ events: n }) => {
270
+ for (const d of n) {
271
+ const { x: m, y: h } = this.getEventOffset(d), { width: v, height: b } = d.size, l = new Path2D();
272
+ l.moveTo(m - v / 2, h - b / 2), l.rect(m, h, v, b), i.isPointInPath(l, r.x, r.y) && (o = d);
273
+ }
274
+ }), this.activeEvent !== o && (this.activeEvent = o, this.useSnapshot = this.shouldUpdate = !0), !a) {
275
+ const n = this.findNearMeasureLine(r);
276
+ n !== this.activeMeasureLine && (this.setCursor(n ? "ew-resize" : void 0), this.activeMeasureLine = n, this.useSnapshot = this.shouldUpdate = !0);
277
+ }
278
+ }
279
+ /// 按实际绘制顺序排列
280
+ get $measureLines() {
281
+ const { measureLines: e, draggedMeasureLine: t } = this;
282
+ return t !== null ? [
283
+ ...e.filter(({ name: i }) => i !== t.name),
284
+ t
285
+ ] : e;
286
+ }
287
+ drawMeasureLines() {
288
+ for (const e of this.$measureLines)
289
+ this.drawMeasureLine(e);
290
+ }
291
+ getLineOffset(e) {
292
+ const { x: t } = this.getDataOffset({
293
+ x: e.location,
294
+ y: 0
295
+ });
296
+ return t;
297
+ }
298
+ get xRange() {
299
+ return this.bounds.x;
300
+ }
301
+ drawMeasureLine(e) {
302
+ const { context: t, rect: i, scaleGrid: s, activeMeasureLine: a } = this, r = C(e.location, this.xRange);
303
+ r !== e.location && (e.location = r, this.emitMeasureChangeEvent(a));
304
+ const { name: o, color: n, style: d } = e, { width: m } = S(t, o), h = this.getLineOffset(e);
305
+ t.save(), t.fillStyle = n, t.fillText(o, h - m / 2, 7), t.beginPath(), t.moveTo(h, s.top), t.lineTo(h, i.y), t.strokeStyle = n, d === p.dashed && t.setLineDash([2, 2]), t.lineWidth = a?.name === o ? 2 : 1, t.stroke(), t.restore();
306
+ }
307
+ getMeasureLineDefaultAttrs(e) {
308
+ const { location: t, ...i } = L.config.measureLine[e];
309
+ let s = 0;
310
+ return typeof t == "number" ? s = t : s = this.getRatioOffset(+t.replace(/%$/, "") / 100).x, {
311
+ name: e,
312
+ location: s,
313
+ ...i
314
+ };
315
+ }
316
+ get measureLinesMoved() {
317
+ return this.measureLines.some((e) => {
318
+ const { location: t } = this.getMeasureLineDefaultAttrs(e.name);
319
+ return e.location !== t;
320
+ });
321
+ }
322
+ initMeasureLine(e, t) {
323
+ const i = this.getMeasureLineDefaultAttrs(t);
324
+ e.copyWith(i);
325
+ }
326
+ initMeasureLines(e) {
327
+ const t = e ?? this.measureMode;
328
+ switch (t) {
329
+ case c.two_points:
330
+ case c.four_points:
331
+ this.initMeasureLine(this.measureLine_A, f.line_A), this.initMeasureLine(this.measureLine_B, f.line_B), t === c.four_points && (this.initMeasureLine(this.measureLine_a, f.line_a), this.initMeasureLine(this.measureLine_b, f.line_b));
332
+ break;
333
+ case c.none:
334
+ }
335
+ }
336
+ get measureValue() {
337
+ return this.measureLines.map(({ name: e, location: t }) => ({
338
+ name: e,
339
+ location: t
340
+ }));
341
+ }
342
+ setMeasureMode(e) {
343
+ this.measureMode !== e && (this.initMeasureLines(e), this.measureMode = e, this.shouldUpdate = !0);
344
+ }
345
+ fitDatasets(e = !0) {
346
+ if (this.data) {
347
+ let t = 0, i = 0, s = 0;
348
+ for (const a of this.data) {
349
+ const { data: r, precision: o } = this.mergeDataset(a);
350
+ t = Math.max(t, r.length * o), s = U([s, ...r]), i = B([i, ...r]);
351
+ }
352
+ t > 0 && (this.xMin = 0, this.xMax = t, this.yMin = s, this.yMax = i, this.shouldUpdate = e);
353
+ }
354
+ }
355
+ // @override
356
+ reset() {
357
+ super.reset(() => {
358
+ this.fitDatasets(!1), this.measureEnabled && this.measureLinesMoved && (this.initMeasureLines(), this.emitMeasureChangeEvent(null));
359
+ });
360
+ }
361
+ findNearMeasureLine(e) {
362
+ for (let t = this.$measureLines.length - 1; t >= 0; t--) {
363
+ const i = this.$measureLines[t], s = this.getLineOffset(i);
364
+ if (e.x < s + 5 && e.x > s - 5)
365
+ return i;
366
+ }
367
+ return null;
368
+ }
369
+ // @override
370
+ onStart(e) {
371
+ e.stopPropagation, this.activeMeasureLine !== null ? this.dragging = !0 : super.onStart(e);
372
+ }
373
+ emitMeasureChangeEvent(e) {
374
+ const { measureLines: t } = this, i = t.map(({ name: s, location: a }) => ({
375
+ name: s,
376
+ location: e?.name === s ? e.location : a
377
+ }));
378
+ this.onMeasureChange?.({
379
+ current: e,
380
+ context: i
381
+ });
382
+ }
383
+ // 同步更新其他测量线 确保次序
384
+ updateMeasureLines() {
385
+ const { activeMeasureLine: e, measureLines: t } = this;
386
+ if (e !== null) {
387
+ const { name: i, location: s, order: a } = e;
388
+ for (const r of t)
389
+ r.name !== i && (a > r.order && s < r.location || a < r.order && s > r.location) && (r.location = e.location);
390
+ }
391
+ }
392
+ // @override
393
+ onUpdate(e) {
394
+ const { activeMeasureLine: t, scale: i, dpr: s } = this;
395
+ if (t !== null) {
396
+ const { x: a } = e.delta.multiply(i).multiply(s.value), { name: r, location: o } = t, n = C(o + a, this.xRange);
397
+ return n !== o && (t.location = n, this.updateMeasureLines(), this.emitMeasureChangeEvent({
398
+ name: r,
399
+ location: n
400
+ }), this.useSnapshot = this.shouldUpdate = !0), this.draggedMeasureLine = t, e.value;
401
+ }
402
+ return super.onUpdate(e);
403
+ }
404
+ }
405
+ Object.defineProperty(L, "version", {
406
+ enumerable: !0,
407
+ configurable: !0,
408
+ writable: !0,
409
+ value: "0.2.0"
410
+ });
411
+ L.initConfig();
412
+ export {
413
+ G as ControlType,
414
+ p as LineStyle,
415
+ c as MeasureMode,
416
+ L as default
417
+ };
@@ -0,0 +1,20 @@
1
+ import type { Point } from '../base';
2
+ import type { CSSProperties, Edge } from '../type';
3
+ export interface CrosshairOption {
4
+ edge: Edge;
5
+ style?: CSSProperties;
6
+ }
7
+ export declare class Crosshair {
8
+ private root;
9
+ private container;
10
+ private axisX;
11
+ private axisY;
12
+ private option;
13
+ constructor(root: HTMLElement, option: CrosshairOption);
14
+ private createContainer;
15
+ private createAxis;
16
+ setEdge(edge: Edge): void;
17
+ update({ x, y }: Point): void;
18
+ hide(): void;
19
+ dispose(): void;
20
+ }
@@ -0,0 +1,2 @@
1
+ export * from './tooltip';
2
+ export * from './crosshair';
@@ -0,0 +1,12 @@
1
+ import type { CSSProperties, TooltipOption } from '../type';
2
+ export declare class Tooltip {
3
+ private root;
4
+ private xTooltip;
5
+ private yTooltip;
6
+ constructor(root: HTMLElement, style?: CSSProperties);
7
+ private createTooltip;
8
+ private updateTooltip;
9
+ update(xTooltip: TooltipOption | null, yTooltip: TooltipOption | null): void;
10
+ hide(): void;
11
+ dispose(): void;
12
+ }
@@ -0,0 +1,78 @@
1
+ import type { Point } from './base';
2
+ export type CSSProperties = Partial<CSSStyleDeclaration>;
3
+ export type PartialRequired<T extends object, K extends keyof T> = T & Required<Pick<T, K>>;
4
+ export interface Edge {
5
+ left: number;
6
+ top: number;
7
+ right: number;
8
+ bottom: number;
9
+ }
10
+ export type DataCache = [Date, Uint8ClampedArray];
11
+ export interface Offset {
12
+ x: number;
13
+ y: number;
14
+ }
15
+ export interface Size {
16
+ width: number;
17
+ height: number;
18
+ }
19
+ export type RangeValue = [number, number];
20
+ export interface DataTransformer<T> {
21
+ (data: T): T;
22
+ }
23
+ export interface ValueChangeListener<T> {
24
+ (value: T): void;
25
+ }
26
+ export interface DragableContext<T> {
27
+ value: T;
28
+ dragging: boolean;
29
+ }
30
+ export interface TooltipOption {
31
+ offset: Offset;
32
+ content: string;
33
+ }
34
+ export type InteractEvent = MouseEvent | TouchEvent;
35
+ export interface DragUpdateContext<T> {
36
+ value: T;
37
+ delta: Point;
38
+ offset: Point;
39
+ event: InteractEvent;
40
+ }
41
+ export interface DragableOverride<T> {
42
+ getStyle(context: DragableContext<T>): string;
43
+ onStart?(event: InteractEvent): void;
44
+ onUpdate(context: DragUpdateContext<T>): T;
45
+ onEnd?(event: InteractEvent): void;
46
+ }
47
+ export interface DragableOption<T> extends DragableOverride<T> {
48
+ initValue: T;
49
+ }
50
+ export interface Dataset {
51
+ title?: string;
52
+ data: ArrayLike<number> & Iterable<number> & {
53
+ slice(start?: number, end?: number): Iterable<number>;
54
+ };
55
+ precision?: number;
56
+ }
57
+ /**
58
+ * 交互方式
59
+ */
60
+ export declare enum ControlType {
61
+ /**
62
+ * 不可交互
63
+ */
64
+ none = -1,
65
+ /**
66
+ * 区域选择
67
+ */
68
+ crop = 0,
69
+ /**
70
+ * 缩放
71
+ */
72
+ zoom = 1,
73
+ /**
74
+ * 平移
75
+ */
76
+ move = 2
77
+ }
78
+ export type DataSampleMethod = 'none' | 'max' | 'min' | 'avg' | 'lttb';
@@ -0,0 +1,6 @@
1
+ import type { Dataset, RangeValue } from '../type';
2
+ export declare function fitDataset(data: Dataset['data'], precision: number, [xMin, xMax]: RangeValue): {
3
+ start: number;
4
+ end: number;
5
+ loop: (s: number, callback: (i: number, p: number) => void) => void;
6
+ };
@@ -0,0 +1 @@
1
+ export declare function formatTime(date: Date, format?: string): string;
@@ -0,0 +1,15 @@
1
+ import type { ValueChangeListener } from '../type';
2
+ export declare class Dpr {
3
+ private _value;
4
+ private mediaQuery;
5
+ private listener;
6
+ constructor(listener: ValueChangeListener<number>);
7
+ private createMediaMatch;
8
+ get value(): number;
9
+ private onMediaChange;
10
+ dispose(): void;
11
+ }
12
+ export declare function measureText(context: CanvasRenderingContext2D, text: string): {
13
+ width: number;
14
+ height: number;
15
+ };
@@ -0,0 +1,6 @@
1
+ import { Point } from '../base';
2
+ export declare function getOffset(event: MouseEvent | TouchEvent, target?: HTMLElement): Point;
3
+ export declare function debounce(callback: (...args: any[]) => void, delay: number): {
4
+ (this: any, ...args: any[]): void;
5
+ cancel: () => void;
6
+ };
@@ -0,0 +1,6 @@
1
+ export * from './style';
2
+ export * from './event';
3
+ export * from './date';
4
+ export * from './numeric';
5
+ export * from './env';
6
+ export * from './dataset';
@@ -0,0 +1,26 @@
1
+ import type { Point } from '../base';
2
+ import type { DataTransformer, RangeValue, Edge } from '../type';
3
+ export declare const getMin: (args: Iterable<number>) => number;
4
+ export declare const getMax: (args: Iterable<number>) => number;
5
+ export declare const reverseRange: DataTransformer<RangeValue>;
6
+ /**
7
+ *
8
+ * @param {RangeValue} range input range value
9
+ * @param {number} limit value limit
10
+ * @returns {RangeValue}
11
+ */
12
+ export declare function invertRange(range: RangeValue, limit?: number): RangeValue;
13
+ export declare function restrictRange([s1, e1]: RangeValue, [s2, e2]: RangeValue, [sl, el]?: RangeValue): RangeValue;
14
+ export declare function isPointInBounds({ x, y }: Point, { left, top, right, bottom }: Edge): boolean;
15
+ export declare function clampInRange(value: number, [min, max]: RangeValue): number;
16
+ export declare function restrictBoundsInRange(bounds: Edge, xLimit: RangeValue, yLimit: RangeValue): Edge;
17
+ export declare function scaleBounds({ left, top, right, bottom }: Edge, scale: number): {
18
+ left: number;
19
+ top: number;
20
+ right: number;
21
+ bottom: number;
22
+ };
23
+ export declare function createScale(range: RangeValue, [min, max]: RangeValue): {
24
+ rules: number[];
25
+ density: number;
26
+ };
@@ -0,0 +1,3 @@
1
+ import type { CSSProperties } from '../type';
2
+ export declare function createStyle(styles: CSSProperties): string;
3
+ export declare function applyStyle(element: HTMLElement, styles: CSSProperties): void;
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@data-vision/interactive-chart",
3
+ "version": "0.0.8",
4
+ "license": "MIT",
5
+ "author": {
6
+ "name": "icefee",
7
+ "email": "icefee@outlook.com"
8
+ },
9
+ "repository": {
10
+ "url": "https://bitbucket.org/icefee/interactive-chart"
11
+ },
12
+ "type": "module",
13
+ "files": [
14
+ "build"
15
+ ],
16
+ "types": "./build/index.d.ts",
17
+ "main": "./build/index.cjs",
18
+ "module": "./build/index.js",
19
+ "exports": {
20
+ ".": {
21
+ "import": "./build/index.js",
22
+ "require": "./build/index.cjs"
23
+ },
24
+ "./bar": {
25
+ "import": "./build/bar.js",
26
+ "require": "./build/bar.cjs"
27
+ },
28
+ "./line": {
29
+ "import": "./build/line.js",
30
+ "require": "./build/line.cjs"
31
+ },
32
+ "./heatmap": {
33
+ "import": "./build/heatmap.js",
34
+ "require": "./build/heatmap.cjs"
35
+ },
36
+ "./otdr": {
37
+ "import": "./build/otdr.js",
38
+ "require": "./build/otdr.cjs"
39
+ }
40
+ },
41
+ "scripts": {
42
+ "dev": "vite",
43
+ "build": "tsc && vite build",
44
+ "preview": "vite preview"
45
+ },
46
+ "devDependencies": {
47
+ "@rollup/plugin-typescript": "^11.1.6",
48
+ "@types/node": "20.14.9",
49
+ "tslib": "^2.6.3",
50
+ "typescript": "^5.2.2",
51
+ "vite": "^7.3.1"
52
+ }
53
+ }