@adecore/charts 0.62.1 → 0.63.0-untangle.1

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.
@@ -1,13 +1,5 @@
1
1
  import { type ReactNode, type Ref } from 'react';
2
- export interface SeriesLegendItem {
3
- readonly key: string;
4
- readonly label: string;
5
- readonly name?: string;
6
- readonly group?: string;
7
- readonly color?: string;
8
- readonly disabled?: boolean;
9
- readonly status?: string;
10
- }
2
+ import { type SeriesLegendItem } from './legend.ts';
11
3
  export interface SeriesLegendGroup {
12
4
  readonly key: string;
13
5
  readonly label: string;
@@ -6,19 +6,16 @@ import { xOf } from './access.js';
6
6
  import { colorOf } from './color.js';
7
7
  import { useChartContext } from './context.js';
8
8
  import { keyIndexOf } from './cursor.js';
9
+ import { crisp } from './plane.js';
9
10
  import { useRegistration } from './register.js';
10
11
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
12
  const MIN_BAND = 4;
12
- /* Room a label needs above its line before it moves under it instead. */
13
- const RULE_LABEL = 18;
14
- /* Between the line and the label it carries, above it or below it. */
15
- const RULE_GAP = 7;
16
13
  /*
17
14
  * A line at a value across the plot, such as a reference to compare against, drawn above the series: horizontal over
18
15
  * columns, vertical through the rows of a horizontal chart.
19
16
  */
20
17
  export function ChartRule(t0) {
21
- const $ = _c(87);
18
+ const $ = _c(42);
22
19
  const {
23
20
  value,
24
21
  label,
@@ -44,309 +41,157 @@ export function ChartRule(t0) {
44
41
  t3 = $[2];
45
42
  }
46
43
  useRegistration(chart.store, "rule", id, t3);
47
- let below;
48
- let t10;
49
- let t11;
50
- let t12;
44
+ let line;
51
45
  let t4;
52
46
  let t5;
53
- let t6;
54
- let t7;
55
- let t8;
56
- let t9;
57
47
  let target;
58
- if ($[3] !== chart || $[4] !== className || $[5] !== dashed || $[6] !== label || $[7] !== ref || $[8] !== tone || $[9] !== value) {
59
- t12 = Symbol.for("react.early_return_sentinel");
48
+ if ($[3] !== chart || $[4] !== value) {
49
+ t5 = Symbol.for("react.early_return_sentinel");
60
50
  bb0: {
61
51
  const pixel = chart.pixelOfY(value);
62
52
  target = chart.elements.rules;
63
53
  if (pixel === null || target === null) {
64
- t12 = null;
54
+ t5 = null;
65
55
  break bb0;
66
56
  }
67
- if (chart.horizontal) {
68
- const left = Math.round(pixel) + 0.5;
69
- const toward = pixel > (chart.plot.left + chart.plot.right) / 2 ? "end" : "start";
70
- let t13;
71
- if ($[21] !== className) {
72
- t13 = clsx("pointer-events-none", className);
73
- $[21] = className;
74
- $[22] = t13;
75
- } else {
76
- t13 = $[22];
77
- }
78
- let t14;
79
- if ($[23] !== tone) {
80
- t14 = colorOf(tone);
81
- $[23] = tone;
82
- $[24] = t14;
83
- } else {
84
- t14 = $[24];
85
- }
86
- let t15;
87
- if ($[25] !== t14) {
88
- t15 = {
89
- color: t14
90
- };
91
- $[25] = t14;
92
- $[26] = t15;
93
- } else {
94
- t15 = $[26];
95
- }
96
- const t16 = dashed ? "4 4" : undefined;
97
- let t17;
98
- if ($[27] !== chart.plot.bottom || $[28] !== chart.plot.top || $[29] !== left || $[30] !== t16) {
99
- t17 = /*#__PURE__*/_jsx("line", {
100
- x1: left,
101
- x2: left,
102
- y1: chart.plot.top,
103
- y2: chart.plot.bottom,
104
- stroke: "currentColor",
105
- strokeDasharray: t16
106
- });
107
- $[27] = chart.plot.bottom;
108
- $[28] = chart.plot.top;
109
- $[29] = left;
110
- $[30] = t16;
111
- $[31] = t17;
112
- } else {
113
- t17 = $[31];
114
- }
115
- const t18 = Math.round(pixel) + (toward === "end" ? 4 : -4);
116
- const t19 = chart.plot.top - RULE_GAP;
117
- let t20;
118
- if ($[32] !== chart.halo) {
119
- t20 = {
120
- stroke: chart.halo
121
- };
122
- $[32] = chart.halo;
123
- $[33] = t20;
124
- } else {
125
- t20 = $[33];
126
- }
127
- let t21;
128
- if ($[34] !== chart || $[35] !== value) {
129
- t21 = chart.formatY(value);
130
- $[34] = chart;
131
- $[35] = value;
132
- $[36] = t21;
133
- } else {
134
- t21 = $[36];
135
- }
136
- const t22 = `${label} · ${t21}`;
137
- let t23;
138
- if ($[37] !== t18 || $[38] !== t19 || $[39] !== t20 || $[40] !== t22 || $[41] !== toward) {
139
- t23 = /*#__PURE__*/_jsx("text", {
140
- x: t18,
141
- y: t19,
142
- textAnchor: toward,
143
- strokeWidth: 4,
144
- paintOrder: "stroke",
145
- className: "fill-text text-xs font-medium tabular-nums",
146
- style: t20,
147
- children: t22
148
- });
149
- $[37] = t18;
150
- $[38] = t19;
151
- $[39] = t20;
152
- $[40] = t22;
153
- $[41] = toward;
154
- $[42] = t23;
155
- } else {
156
- t23 = $[42];
157
- }
158
- let t24;
159
- if ($[43] !== ref || $[44] !== t13 || $[45] !== t15 || $[46] !== t17 || $[47] !== t23) {
160
- t24 = /*#__PURE__*/_jsxs("g", {
161
- ref: ref,
162
- className: t13,
163
- style: t15,
164
- "aria-hidden": true,
165
- children: [t17, t23]
166
- });
167
- $[43] = ref;
168
- $[44] = t13;
169
- $[45] = t15;
170
- $[46] = t17;
171
- $[47] = t23;
172
- $[48] = t24;
173
- } else {
174
- t24 = $[48];
175
- }
176
- let t25;
177
- if ($[49] !== t24 || $[50] !== target) {
178
- t25 = createPortal(t24, target);
179
- $[49] = t24;
180
- $[50] = target;
181
- $[51] = t25;
182
- } else {
183
- t25 = $[51];
184
- }
185
- t12 = t25;
186
- break bb0;
187
- }
188
- const top = Math.round(pixel) + 0.5;
189
- below = top - RULE_LABEL < 0;
190
- t11 = createPortal;
191
- t6 = ref;
192
- if ($[52] !== className) {
193
- t7 = clsx("pointer-events-none", className);
194
- $[52] = className;
195
- $[53] = t7;
196
- } else {
197
- t7 = $[53];
198
- }
199
- let t13;
200
- if ($[54] !== tone) {
201
- t13 = colorOf(tone);
202
- $[54] = tone;
203
- $[55] = t13;
204
- } else {
205
- t13 = $[55];
206
- }
207
- if ($[56] !== t13) {
208
- t8 = {
209
- color: t13
210
- };
211
- $[56] = t13;
212
- $[57] = t8;
213
- } else {
214
- t8 = $[57];
215
- }
216
- t9 = true;
217
- const t14 = dashed ? "4 4" : undefined;
218
- if ($[58] !== chart.plot.left || $[59] !== chart.plot.right || $[60] !== t14 || $[61] !== top) {
219
- t10 = /*#__PURE__*/_jsx("line", {
220
- x1: chart.plot.left,
221
- x2: chart.plot.right,
222
- y1: top,
223
- y2: top,
224
- stroke: "currentColor",
225
- strokeDasharray: t14
226
- });
227
- $[58] = chart.plot.left;
228
- $[59] = chart.plot.right;
229
- $[60] = t14;
230
- $[61] = top;
231
- $[62] = t10;
232
- } else {
233
- t10 = $[62];
234
- }
235
- if ($[63] !== chart.plot.right) {
236
- t5 = Math.round(chart.plot.right);
237
- $[63] = chart.plot.right;
238
- $[64] = t5;
239
- } else {
240
- t5 = $[64];
241
- }
242
- t4 = Math.round(pixel);
57
+ line = chart.plane.valueLine(chart.plot, crisp(pixel));
58
+ t4 = chart.plane.ruleLabel(chart.plot, pixel);
243
59
  }
244
60
  $[3] = chart;
245
- $[4] = className;
246
- $[5] = dashed;
247
- $[6] = label;
248
- $[7] = ref;
249
- $[8] = tone;
250
- $[9] = value;
251
- $[10] = below;
252
- $[11] = t10;
253
- $[12] = t11;
254
- $[13] = t12;
255
- $[14] = t4;
256
- $[15] = t5;
257
- $[16] = t6;
258
- $[17] = t7;
259
- $[18] = t8;
260
- $[19] = t9;
261
- $[20] = target;
61
+ $[4] = value;
62
+ $[5] = line;
63
+ $[6] = t4;
64
+ $[7] = t5;
65
+ $[8] = target;
262
66
  } else {
263
- below = $[10];
264
- t10 = $[11];
265
- t11 = $[12];
266
- t12 = $[13];
267
- t4 = $[14];
268
- t5 = $[15];
269
- t6 = $[16];
270
- t7 = $[17];
271
- t8 = $[18];
272
- t9 = $[19];
273
- target = $[20];
67
+ line = $[5];
68
+ t4 = $[6];
69
+ t5 = $[7];
70
+ target = $[8];
71
+ }
72
+ if (t5 !== Symbol.for("react.early_return_sentinel")) {
73
+ return t5;
74
+ }
75
+ const written = t4;
76
+ let t6;
77
+ if ($[9] !== className) {
78
+ t6 = clsx("pointer-events-none", className);
79
+ $[9] = className;
80
+ $[10] = t6;
81
+ } else {
82
+ t6 = $[10];
274
83
  }
275
- if (t12 !== Symbol.for("react.early_return_sentinel")) {
276
- return t12;
84
+ let t7;
85
+ if ($[11] !== tone) {
86
+ t7 = colorOf(tone);
87
+ $[11] = tone;
88
+ $[12] = t7;
89
+ } else {
90
+ t7 = $[12];
277
91
  }
278
- const t13 = t4 + (below ? RULE_GAP : -RULE_GAP);
279
- const t14 = below ? "0.8em" : undefined;
92
+ let t8;
93
+ if ($[13] !== t7) {
94
+ t8 = {
95
+ color: t7
96
+ };
97
+ $[13] = t7;
98
+ $[14] = t8;
99
+ } else {
100
+ t8 = $[14];
101
+ }
102
+ const t9 = dashed ? "4 4" : undefined;
103
+ let t10;
104
+ if ($[15] !== line.x1 || $[16] !== line.x2 || $[17] !== line.y1 || $[18] !== line.y2 || $[19] !== t9) {
105
+ t10 = /*#__PURE__*/_jsx("line", {
106
+ x1: line.x1,
107
+ x2: line.x2,
108
+ y1: line.y1,
109
+ y2: line.y2,
110
+ stroke: "currentColor",
111
+ strokeDasharray: t9
112
+ });
113
+ $[15] = line.x1;
114
+ $[16] = line.x2;
115
+ $[17] = line.y1;
116
+ $[18] = line.y2;
117
+ $[19] = t9;
118
+ $[20] = t10;
119
+ } else {
120
+ t10 = $[20];
121
+ }
122
+ const t11 = written.x;
123
+ const t12 = written.y;
124
+ const t13 = written.dy;
125
+ const t14 = written.anchor;
280
126
  let t15;
281
- if ($[65] !== chart.halo) {
127
+ if ($[21] !== chart.halo) {
282
128
  t15 = {
283
129
  stroke: chart.halo
284
130
  };
285
- $[65] = chart.halo;
286
- $[66] = t15;
131
+ $[21] = chart.halo;
132
+ $[22] = t15;
287
133
  } else {
288
- t15 = $[66];
134
+ t15 = $[22];
289
135
  }
290
136
  let t16;
291
- if ($[67] !== chart || $[68] !== value) {
137
+ if ($[23] !== chart || $[24] !== value) {
292
138
  t16 = chart.formatY(value);
293
- $[67] = chart;
294
- $[68] = value;
295
- $[69] = t16;
139
+ $[23] = chart;
140
+ $[24] = value;
141
+ $[25] = t16;
296
142
  } else {
297
- t16 = $[69];
143
+ t16 = $[25];
298
144
  }
299
145
  const t17 = `${label} · ${t16}`;
300
146
  let t18;
301
- if ($[70] !== t13 || $[71] !== t14 || $[72] !== t15 || $[73] !== t17 || $[74] !== t5) {
147
+ if ($[26] !== t15 || $[27] !== t17 || $[28] !== written.anchor || $[29] !== written.dy || $[30] !== written.x || $[31] !== written.y) {
302
148
  t18 = /*#__PURE__*/_jsx("text", {
303
- x: t5,
304
- y: t13,
305
- dy: t14,
306
- textAnchor: "end",
149
+ x: t11,
150
+ y: t12,
151
+ dy: t13,
152
+ textAnchor: t14,
307
153
  strokeWidth: 4,
308
154
  paintOrder: "stroke",
309
155
  className: "fill-text text-xs font-medium tabular-nums",
310
156
  style: t15,
311
157
  children: t17
312
158
  });
313
- $[70] = t13;
314
- $[71] = t14;
315
- $[72] = t15;
316
- $[73] = t17;
317
- $[74] = t5;
318
- $[75] = t18;
159
+ $[26] = t15;
160
+ $[27] = t17;
161
+ $[28] = written.anchor;
162
+ $[29] = written.dy;
163
+ $[30] = written.x;
164
+ $[31] = written.y;
165
+ $[32] = t18;
319
166
  } else {
320
- t18 = $[75];
167
+ t18 = $[32];
321
168
  }
322
169
  let t19;
323
- if ($[76] !== t10 || $[77] !== t18 || $[78] !== t6 || $[79] !== t7 || $[80] !== t8 || $[81] !== t9) {
170
+ if ($[33] !== ref || $[34] !== t10 || $[35] !== t18 || $[36] !== t6 || $[37] !== t8) {
324
171
  t19 = /*#__PURE__*/_jsxs("g", {
325
- ref: t6,
326
- className: t7,
172
+ ref: ref,
173
+ className: t6,
327
174
  style: t8,
328
- "aria-hidden": t9,
175
+ "aria-hidden": true,
329
176
  children: [t10, t18]
330
177
  });
331
- $[76] = t10;
332
- $[77] = t18;
333
- $[78] = t6;
334
- $[79] = t7;
335
- $[80] = t8;
336
- $[81] = t9;
337
- $[82] = t19;
178
+ $[33] = ref;
179
+ $[34] = t10;
180
+ $[35] = t18;
181
+ $[36] = t6;
182
+ $[37] = t8;
183
+ $[38] = t19;
338
184
  } else {
339
- t19 = $[82];
185
+ t19 = $[38];
340
186
  }
341
187
  let t20;
342
- if ($[83] !== t11 || $[84] !== t19 || $[85] !== target) {
343
- t20 = t11(t19, target);
344
- $[83] = t11;
345
- $[84] = t19;
346
- $[85] = target;
347
- $[86] = t20;
188
+ if ($[39] !== t19 || $[40] !== target) {
189
+ t20 = createPortal(t19, target);
190
+ $[39] = t19;
191
+ $[40] = target;
192
+ $[41] = t20;
348
193
  } else {
349
- t20 = $[86];
194
+ t20 = $[41];
350
195
  }
351
196
  return t20;
352
197
  }
@@ -373,7 +218,7 @@ export function ChartMarker(t0) {
373
218
  color
374
219
  });
375
220
  const pixel = chart.pixelOfX(x);
376
- if (chart.horizontal || pixel === null || pixel < chart.plot.left || pixel > chart.plot.right) {
221
+ if (!chart.plane.draws("marker") || pixel === null || pixel < chart.plot.left || pixel > chart.plot.right) {
377
222
  return null;
378
223
  }
379
224
  const left = Math.round(pixel) + 0.5;
@@ -508,7 +353,7 @@ export function ChartBand(t0) {
508
353
  }
509
354
  }
510
355
  }
511
- if (chart.horizontal || left === null || right === null || right <= left) {
356
+ if (!chart.plane.draws("band") || left === null || right === null || right <= left) {
512
357
  return null;
513
358
  }
514
359
  const x = Math.round(left);
package/dist/axes.d.ts CHANGED
@@ -42,7 +42,7 @@ export interface ChartGroupAxisProps<Row> {
42
42
  readonly ref?: Ref<HTMLDivElement>;
43
43
  }
44
44
  export declare const LABEL_GAP = 8;
45
- export declare function ChartGrid({ axis, dashed, lines, className, ref }: ChartGridProps): import("react").JSX.Element | null;
45
+ export declare function ChartGrid({ axis, dashed, lines, className, ref }: ChartGridProps): import("react").JSX.Element;
46
46
  export declare function ChartXAxis(props: ChartXAxisProps): import("react").JSX.Element;
47
47
  export declare function ChartYAxis(props: ChartYAxisProps): import("react").JSX.Element;
48
48
  export declare function ChartGroupAxis<Row>({ children, className, ref }: ChartGroupAxisProps<Row>): import("react").ReactPortal | null;