@adecore/charts 0.41.1 → 0.42.0

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.
@@ -13,9 +13,12 @@ const MIN_BAND = 4;
13
13
  const RULE_LABEL = 18;
14
14
  /* Between the line and the label it carries, above it or below it. */
15
15
  const RULE_GAP = 7;
16
- /* A horizontal line at a value across the plot, such as a reference to compare against, drawn above the series. */
16
+ /*
17
+ * A line at a value across the plot, such as a reference to compare against, drawn above the series: horizontal over
18
+ * columns, vertical through the rows of a horizontal chart.
19
+ */
17
20
  export function ChartRule(t0) {
18
- const $ = _c(55);
21
+ const $ = _c(87);
19
22
  const {
20
23
  value,
21
24
  label,
@@ -52,7 +55,7 @@ export function ChartRule(t0) {
52
55
  let t8;
53
56
  let t9;
54
57
  let target;
55
- if ($[3] !== chart || $[4] !== className || $[5] !== dashed || $[6] !== ref || $[7] !== tone || $[8] !== value) {
58
+ if ($[3] !== chart || $[4] !== className || $[5] !== dashed || $[6] !== label || $[7] !== ref || $[8] !== tone || $[9] !== value) {
56
59
  t12 = Symbol.for("react.early_return_sentinel");
57
60
  bb0: {
58
61
  const pixel = chart.pixelOfY(value);
@@ -61,37 +64,158 @@ export function ChartRule(t0) {
61
64
  t12 = null;
62
65
  break bb0;
63
66
  }
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
+ }
64
188
  const top = Math.round(pixel) + 0.5;
65
189
  below = top - RULE_LABEL < 0;
66
190
  t11 = createPortal;
67
191
  t6 = ref;
68
- if ($[20] !== className) {
192
+ if ($[52] !== className) {
69
193
  t7 = clsx("pointer-events-none", className);
70
- $[20] = className;
71
- $[21] = t7;
194
+ $[52] = className;
195
+ $[53] = t7;
72
196
  } else {
73
- t7 = $[21];
197
+ t7 = $[53];
74
198
  }
75
199
  let t13;
76
- if ($[22] !== tone) {
200
+ if ($[54] !== tone) {
77
201
  t13 = colorOf(tone);
78
- $[22] = tone;
79
- $[23] = t13;
202
+ $[54] = tone;
203
+ $[55] = t13;
80
204
  } else {
81
- t13 = $[23];
205
+ t13 = $[55];
82
206
  }
83
- if ($[24] !== t13) {
207
+ if ($[56] !== t13) {
84
208
  t8 = {
85
209
  color: t13
86
210
  };
87
- $[24] = t13;
88
- $[25] = t8;
211
+ $[56] = t13;
212
+ $[57] = t8;
89
213
  } else {
90
- t8 = $[25];
214
+ t8 = $[57];
91
215
  }
92
216
  t9 = true;
93
217
  const t14 = dashed ? "4 4" : undefined;
94
- if ($[26] !== chart.plot.left || $[27] !== chart.plot.right || $[28] !== t14 || $[29] !== top) {
218
+ if ($[58] !== chart.plot.left || $[59] !== chart.plot.right || $[60] !== t14 || $[61] !== top) {
95
219
  t10 = /*#__PURE__*/_jsx("line", {
96
220
  x1: chart.plot.left,
97
221
  x2: chart.plot.right,
@@ -100,52 +224,53 @@ export function ChartRule(t0) {
100
224
  stroke: "currentColor",
101
225
  strokeDasharray: t14
102
226
  });
103
- $[26] = chart.plot.left;
104
- $[27] = chart.plot.right;
105
- $[28] = t14;
106
- $[29] = top;
107
- $[30] = t10;
227
+ $[58] = chart.plot.left;
228
+ $[59] = chart.plot.right;
229
+ $[60] = t14;
230
+ $[61] = top;
231
+ $[62] = t10;
108
232
  } else {
109
- t10 = $[30];
233
+ t10 = $[62];
110
234
  }
111
- if ($[31] !== chart.plot.right) {
235
+ if ($[63] !== chart.plot.right) {
112
236
  t5 = Math.round(chart.plot.right);
113
- $[31] = chart.plot.right;
114
- $[32] = t5;
237
+ $[63] = chart.plot.right;
238
+ $[64] = t5;
115
239
  } else {
116
- t5 = $[32];
240
+ t5 = $[64];
117
241
  }
118
242
  t4 = Math.round(pixel);
119
243
  }
120
244
  $[3] = chart;
121
245
  $[4] = className;
122
246
  $[5] = dashed;
123
- $[6] = ref;
124
- $[7] = tone;
125
- $[8] = value;
126
- $[9] = below;
127
- $[10] = t10;
128
- $[11] = t11;
129
- $[12] = t12;
130
- $[13] = t4;
131
- $[14] = t5;
132
- $[15] = t6;
133
- $[16] = t7;
134
- $[17] = t8;
135
- $[18] = t9;
136
- $[19] = target;
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;
137
262
  } else {
138
- below = $[9];
139
- t10 = $[10];
140
- t11 = $[11];
141
- t12 = $[12];
142
- t4 = $[13];
143
- t5 = $[14];
144
- t6 = $[15];
145
- t7 = $[16];
146
- t8 = $[17];
147
- t9 = $[18];
148
- target = $[19];
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];
149
274
  }
150
275
  if (t12 !== Symbol.for("react.early_return_sentinel")) {
151
276
  return t12;
@@ -153,27 +278,27 @@ export function ChartRule(t0) {
153
278
  const t13 = t4 + (below ? RULE_GAP : -RULE_GAP);
154
279
  const t14 = below ? "0.8em" : undefined;
155
280
  let t15;
156
- if ($[33] !== chart.halo) {
281
+ if ($[65] !== chart.halo) {
157
282
  t15 = {
158
283
  stroke: chart.halo
159
284
  };
160
- $[33] = chart.halo;
161
- $[34] = t15;
285
+ $[65] = chart.halo;
286
+ $[66] = t15;
162
287
  } else {
163
- t15 = $[34];
288
+ t15 = $[66];
164
289
  }
165
290
  let t16;
166
- if ($[35] !== chart || $[36] !== value) {
291
+ if ($[67] !== chart || $[68] !== value) {
167
292
  t16 = chart.formatY(value);
168
- $[35] = chart;
169
- $[36] = value;
170
- $[37] = t16;
293
+ $[67] = chart;
294
+ $[68] = value;
295
+ $[69] = t16;
171
296
  } else {
172
- t16 = $[37];
297
+ t16 = $[69];
173
298
  }
174
299
  const t17 = `${label} · ${t16}`;
175
300
  let t18;
176
- if ($[38] !== t13 || $[39] !== t14 || $[40] !== t15 || $[41] !== t17 || $[42] !== t5) {
301
+ if ($[70] !== t13 || $[71] !== t14 || $[72] !== t15 || $[73] !== t17 || $[74] !== t5) {
177
302
  t18 = /*#__PURE__*/_jsx("text", {
178
303
  x: t5,
179
304
  y: t13,
@@ -185,17 +310,17 @@ export function ChartRule(t0) {
185
310
  style: t15,
186
311
  children: t17
187
312
  });
188
- $[38] = t13;
189
- $[39] = t14;
190
- $[40] = t15;
191
- $[41] = t17;
192
- $[42] = t5;
193
- $[43] = t18;
313
+ $[70] = t13;
314
+ $[71] = t14;
315
+ $[72] = t15;
316
+ $[73] = t17;
317
+ $[74] = t5;
318
+ $[75] = t18;
194
319
  } else {
195
- t18 = $[43];
320
+ t18 = $[75];
196
321
  }
197
322
  let t19;
198
- if ($[44] !== t10 || $[45] !== t18 || $[46] !== t6 || $[47] !== t7 || $[48] !== t8 || $[49] !== t9) {
323
+ if ($[76] !== t10 || $[77] !== t18 || $[78] !== t6 || $[79] !== t7 || $[80] !== t8 || $[81] !== t9) {
199
324
  t19 = /*#__PURE__*/_jsxs("g", {
200
325
  ref: t6,
201
326
  className: t7,
@@ -203,25 +328,25 @@ export function ChartRule(t0) {
203
328
  "aria-hidden": t9,
204
329
  children: [t10, t18]
205
330
  });
206
- $[44] = t10;
207
- $[45] = t18;
208
- $[46] = t6;
209
- $[47] = t7;
210
- $[48] = t8;
211
- $[49] = t9;
212
- $[50] = t19;
331
+ $[76] = t10;
332
+ $[77] = t18;
333
+ $[78] = t6;
334
+ $[79] = t7;
335
+ $[80] = t8;
336
+ $[81] = t9;
337
+ $[82] = t19;
213
338
  } else {
214
- t19 = $[50];
339
+ t19 = $[82];
215
340
  }
216
341
  let t20;
217
- if ($[51] !== t11 || $[52] !== t19 || $[53] !== target) {
342
+ if ($[83] !== t11 || $[84] !== t19 || $[85] !== target) {
218
343
  t20 = t11(t19, target);
219
- $[51] = t11;
220
- $[52] = t19;
221
- $[53] = target;
222
- $[54] = t20;
344
+ $[83] = t11;
345
+ $[84] = t19;
346
+ $[85] = target;
347
+ $[86] = t20;
223
348
  } else {
224
- t20 = $[54];
349
+ t20 = $[86];
225
350
  }
226
351
  return t20;
227
352
  }
@@ -248,7 +373,7 @@ export function ChartMarker(t0) {
248
373
  color
249
374
  });
250
375
  const pixel = chart.pixelOfX(x);
251
- if (pixel === null || pixel < chart.plot.left || pixel > chart.plot.right) {
376
+ if (chart.horizontal || pixel === null || pixel < chart.plot.left || pixel > chart.plot.right) {
252
377
  return null;
253
378
  }
254
379
  const left = Math.round(pixel) + 0.5;
@@ -383,7 +508,7 @@ export function ChartBand(t0) {
383
508
  }
384
509
  }
385
510
  }
386
- if (left === null || right === null || right <= left) {
511
+ if (chart.horizontal || left === null || right === null || right <= left) {
387
512
  return null;
388
513
  }
389
514
  const x = Math.round(left);
package/dist/axes.d.ts CHANGED
@@ -17,6 +17,7 @@ export interface ChartXAxisProps {
17
17
  readonly label?: string;
18
18
  readonly logLabel?: string;
19
19
  readonly onThinnedChange?: (thinned: boolean) => void;
20
+ readonly maxWidth?: number;
20
21
  readonly className?: string;
21
22
  readonly ref?: Ref<SVGGElement>;
22
23
  }
@@ -42,6 +43,6 @@ export interface ChartGroupAxisProps<Row> {
42
43
  }
43
44
  export declare const LABEL_GAP = 8;
44
45
  export declare function ChartGrid({ axis, dashed, lines, className, ref }: ChartGridProps): import("react").JSX.Element | null;
45
- export declare function ChartXAxis({ format, ticks, angle, thin, align, title, label: spoken, logLabel, onThinnedChange, className, ref }: ChartXAxisProps): import("react").JSX.Element;
46
- export declare function ChartYAxis({ format, ticks, side, title, className, ref }: ChartYAxisProps): import("react").ReactPortal | null;
46
+ export declare function ChartXAxis(props: ChartXAxisProps): import("react").JSX.Element;
47
+ export declare function ChartYAxis(props: ChartYAxisProps): import("react").JSX.Element;
47
48
  export declare function ChartGroupAxis<Row>({ children, className, ref }: ChartGroupAxisProps<Row>): import("react").ReactPortal | null;