origam 2.37.37 → 2.37.39

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 (32) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/src/components/Chart/OrigamChartAxis.vue +15 -1
  3. package/dist/src/components/Chart/OrigamChartBoxPlot.vue +6 -7
  4. package/dist/src/components/Chart/OrigamChartBullet.vue +7 -8
  5. package/dist/src/components/Chart/OrigamChartCandlestick.vue +10 -11
  6. package/dist/src/components/Chart/OrigamChartGauge.vue +8 -6
  7. package/dist/src/components/Chart/OrigamChartHeatmap.vue +9 -5
  8. package/dist/src/components/Chart/OrigamChartMap.vue +14 -15
  9. package/dist/src/components/Chart/OrigamChartPareto.vue +9 -10
  10. package/dist/src/components/Chart/OrigamChartPictorial.vue +10 -11
  11. package/dist/src/components/Chart/OrigamChartPolar.vue +6 -7
  12. package/dist/src/components/Chart/OrigamChartPolarBar.vue +8 -8
  13. package/dist/src/components/Chart/OrigamChartPyramid.vue +6 -7
  14. package/dist/src/components/Chart/OrigamChartRadar.vue +7 -9
  15. package/dist/src/components/Chart/OrigamChartSankey.vue +6 -7
  16. package/dist/src/components/Chart/OrigamChartSparkline.vue +15 -17
  17. package/dist/src/components/Chart/OrigamChartStreamgraph.vue +9 -10
  18. package/dist/src/components/Chart/OrigamChartSunburst.vue +8 -8
  19. package/dist/src/components/Chart/OrigamChartTreemap.vue +6 -7
  20. package/dist/src/components/Chart/OrigamChartVariwide.vue +8 -9
  21. package/dist/src/components/Chart/OrigamChartWordCloud.vue +16 -13
  22. package/dist/src/composables/Chart/chart-size.composable.cjs +8 -3
  23. package/dist/src/composables/Chart/chart-size.composable.d.ts +9 -0
  24. package/dist/src/composables/Chart/chart-size.composable.js +8 -3
  25. package/dist/src/consts/Chart/chart.const.cjs +83 -2
  26. package/dist/src/consts/Chart/chart.const.d.ts +113 -0
  27. package/dist/src/consts/Chart/chart.const.js +27 -0
  28. package/dist/src/interfaces/Chart/chart-axis.interface.d.ts +11 -0
  29. package/dist/src/utils/Chart/chart-axis-label.util.cjs +35 -0
  30. package/dist/src/utils/Chart/chart-axis-label.util.d.ts +24 -0
  31. package/dist/src/utils/Chart/chart-axis-label.util.js +24 -0
  32. package/package.json +1 -1
@@ -37,7 +37,7 @@
37
37
  ref="svgRef"
38
38
  class="origam-chart-word-cloud__svg origam-chart__svg"
39
39
  :class="svgClasses"
40
- :viewBox="`0 0 ${ SVG_WIDTH } ${ SVG_HEIGHT }`"
40
+ :viewBox="`0 0 ${ svgWidth } ${ svgHeight }`"
41
41
  :role="CHART_SVG_ROLE"
42
42
  :aria-label="svgAriaLabel"
43
43
  preserveAspectRatio="xMidYMid meet"
@@ -131,7 +131,7 @@
131
131
  </template>
132
132
 
133
133
  <script lang="ts" setup>
134
- import { CHART_SVG_ROLE } from "../../consts/Chart/chart.const";
134
+ import { CHART_SIZE_FALLBACK, CHART_SVG_ROLE } from "../../consts/Chart/chart.const";
135
135
  import {
136
136
  computed,
137
137
  ref
@@ -139,6 +139,7 @@ import {
139
139
  import OrigamChartLegend from "./OrigamChartLegend.vue";
140
140
  import OrigamChartTooltip from "./OrigamChartTooltip.vue";
141
141
  import { useUnsupportedProp } from "../../composables/Commons/unsupportedProp.composable";
142
+ import { useChartSize } from "../../composables/Chart/chart-size.composable";
142
143
  import { useChartAnimationStyle } from "../../composables/Chart/chart-animation.composable";
143
144
  import { useChartHeaderTypography } from "../../composables/Chart/chart-header-typography.composable";
144
145
  import { useBackgroundColor } from "../../composables/Commons/backgroundColor.composable";
@@ -235,10 +236,13 @@ const { headerTypographyStyles } = useChartHeaderTypography({
235
236
  return props.fontSize;
236
237
  }
237
238
  });
238
- const SVG_WIDTH = 800;
239
- const SVG_HEIGHT = 500;
240
- const CENTER_X = SVG_WIDTH / 2;
241
- const CENTER_Y = SVG_HEIGHT / 2;
239
+ const { resizeRef: svgRef, width: svgWidth, height: svgHeight } = useChartSize(CHART_SIZE_FALLBACK.wordCloud);
240
+ const fontScale = computed(() => Math.min(
241
+ svgWidth.value / CHART_SIZE_FALLBACK.wordCloud.width,
242
+ svgHeight.value / CHART_SIZE_FALLBACK.wordCloud.height
243
+ ));
244
+ const centerX = computed(() => svgWidth.value / 2);
245
+ const centerY = computed(() => svgHeight.value / 2);
242
246
  const SPIRAL_STEP = 0.15;
243
247
  const SPIRAL_A = 4;
244
248
  const MAX_SPIRAL_ITERATIONS = 1e3;
@@ -302,7 +306,7 @@ const placedWords = computed(() => {
302
306
  const result = [];
303
307
  const placed = [];
304
308
  sorted.forEach((datum, idx) => {
305
- const fontSize = props.minFontSize + datum.value / maxVal * (props.maxFontSize - props.minFontSize);
309
+ const fontSize = (props.minFontSize + datum.value / maxVal * (props.maxFontSize - props.minFontSize)) * fontScale.value;
306
310
  const angle = angleFor(idx);
307
311
  const isVertical = angle !== 0 && Math.abs(angle) === 90;
308
312
  const estimatedW = datum.text.length * fontSize * WORD_WIDTH_FACTOR;
@@ -310,8 +314,8 @@ const placedWords = computed(() => {
310
314
  const wordW = isVertical ? estimatedH : estimatedW;
311
315
  const wordH = isVertical ? estimatedW : estimatedH;
312
316
  const color = colorFor(idx);
313
- let cx = CENTER_X;
314
- let cy = CENTER_Y;
317
+ let cx = centerX.value;
318
+ let cy = centerY.value;
315
319
  let placed_ = false;
316
320
  if (placed.length === 0) {
317
321
  placed_ = true;
@@ -319,9 +323,9 @@ const placedWords = computed(() => {
319
323
  let theta = 0;
320
324
  for (let iter = 0; iter < MAX_SPIRAL_ITERATIONS; iter++) {
321
325
  const r = SPIRAL_A * theta;
322
- cx = CENTER_X + r * Math.cos(theta);
323
- cy = CENTER_Y + r * Math.sin(theta);
324
- if (cx < wordW / 2 || cx > SVG_WIDTH - wordW / 2 || cy < wordH / 2 || cy > SVG_HEIGHT - wordH / 2) {
326
+ cx = centerX.value + r * Math.cos(theta);
327
+ cy = centerY.value + r * Math.sin(theta);
328
+ if (cx < wordW / 2 || cx > svgWidth.value - wordW / 2 || cy < wordH / 2 || cy > svgHeight.value - wordH / 2) {
325
329
  theta += SPIRAL_STEP;
326
330
  continue;
327
331
  }
@@ -375,7 +379,6 @@ const legendItems = computed(() => {
375
379
  visible: true
376
380
  }));
377
381
  });
378
- const svgRef = ref(null);
379
382
  const mousePos = ref({ x: 0, y: 0 });
380
383
  const hoveredIndex = ref(null);
381
384
  const hoveredWord = computed(() => {
@@ -6,13 +6,18 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.useChartSize = useChartSize;
7
7
  var _vue = require("vue");
8
8
  var _resizeObserver = require("../Commons/resizeObserver.composable.cjs");
9
- function useChartSize(fallback) {
9
+ function useChartSize(fallback, options = {}) {
10
10
  const {
11
11
  resizeRef,
12
12
  contentRect
13
13
  } = (0, _resizeObserver.useResizeObserver)();
14
- const width = (0, _vue.computed)(() => contentRect.value?.width || fallback.width);
15
- const height = (0, _vue.computed)(() => contentRect.value?.height || fallback.height);
14
+ const measuredWidth = (0, _vue.computed)(() => contentRect.value?.width || fallback.width);
15
+ const measuredHeight = (0, _vue.computed)(() => contentRect.value?.height || fallback.height);
16
+ const width = (0, _vue.computed)(() => {
17
+ const ratio = options.aspectRatio;
18
+ return ratio ? Math.min(measuredWidth.value, measuredHeight.value / ratio) : measuredWidth.value;
19
+ });
20
+ const height = (0, _vue.computed)(() => options.aspectRatio ? width.value * options.aspectRatio : measuredHeight.value);
16
21
  return {
17
22
  resizeRef,
18
23
  width,
@@ -7,10 +7,19 @@
7
7
  * conteneur au lieu d'une constante. Tant que rien n'est mesure (SSR,
8
8
  * avant montage, boite nulle) on rend `fallback`, identique entre
9
9
  * serveur et premier rendu client — pas de mismatch d'hydratation.
10
+ *
11
+ * @description
12
+ * `aspectRatio` (#1324, hauteur / largeur) est le mode des charts a
13
+ * geometrie non deformable (radiaux : `1`, jauge, carte) : la surface a
14
+ * ce rapport exact, sa largeur suit le conteneur et une hauteur imposee
15
+ * (prop `height`) la plafonne — le cercle ou la carte n'est jamais
16
+ * ecrase.
10
17
  ********************************************************/
11
18
  export declare function useChartSize(fallback: {
12
19
  width: number;
13
20
  height: number;
21
+ }, options?: {
22
+ aspectRatio?: number;
14
23
  }): {
15
24
  resizeRef: import("vue").Ref<SVGSVGElement | null | undefined, SVGSVGElement | null | undefined>;
16
25
  width: import("vue").ComputedRef<number>;
@@ -1,8 +1,13 @@
1
1
  import { computed } from "vue";
2
2
  import { useResizeObserver } from "../Commons/resizeObserver.composable.js";
3
- export function useChartSize(fallback) {
3
+ export function useChartSize(fallback, options = {}) {
4
4
  const { resizeRef, contentRect } = useResizeObserver();
5
- const width = computed(() => contentRect.value?.width || fallback.width);
6
- const height = computed(() => contentRect.value?.height || fallback.height);
5
+ const measuredWidth = computed(() => contentRect.value?.width || fallback.width);
6
+ const measuredHeight = computed(() => contentRect.value?.height || fallback.height);
7
+ const width = computed(() => {
8
+ const ratio = options.aspectRatio;
9
+ return ratio ? Math.min(measuredWidth.value, measuredHeight.value / ratio) : measuredWidth.value;
10
+ });
11
+ const height = computed(() => options.aspectRatio ? width.value * options.aspectRatio : measuredHeight.value);
7
12
  return { resizeRef, width, height };
8
13
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.CHART_Y_TICK_COUNT = exports.CHART_TICK_LABEL_PRECISION_FACTOR = exports.CHART_SVG_ROLE = exports.CHART_SLICE_LABEL_PREFIX = exports.CHART_SCATTER_MIN_RADIUS = exports.CHART_SCATTER_MAX_RADIUS = exports.CHART_SCATTER_DEFAULT_RADIUS = exports.CHART_RANGE_SELECTOR_DEFAULT_BUTTONS = exports.CHART_RADAR_RADIUS_INSET = exports.CHART_RADAR_MIN_RADIUS = exports.CHART_RADAR_MARKER_RADIUS = exports.CHART_POINT_MARKER_RADIUS = exports.CHART_PLOT_LINE_LABEL_TOP_OFFSET = exports.CHART_PLOT_LINE_LABEL_OFFSET = exports.CHART_PLOT_LINE_DEFAULT_WIDTH = exports.CHART_PLOT_BAND_DEFAULT_OPACITY = exports.CHART_PIE_RADIUS_INSET = exports.CHART_PIE_MIN_RADIUS = exports.CHART_PERCENT_TICK_STEP = exports.CHART_PERCENT_MIN = exports.CHART_PERCENT_MAX = exports.CHART_NICE_STEP_LADDER = exports.CHART_EPSILON = exports.CHART_DEFAULT_PALETTE = exports.CHART_DASH_ARRAY_SOLID = exports.CHART_DASH_ARRAY_DOTTED = exports.CHART_DASH_ARRAY_DASHED = exports.CHART_COLOR_FALLBACK = exports.CHART_BAR_SLOT_FILL_RATIO = exports.CHART_ANNOTATION_LABEL_PADDING = exports.CHART_ANNOTATION_LABEL_MIN_WIDTH = exports.CHART_ANNOTATION_LABEL_HEIGHT = exports.CHART_ANNOTATION_LABEL_CHAR_WIDTH = exports.CHART_ANNOTATION_DEFAULT_WIDTH = exports.CHART_ANNOTATION_DEFAULT_RADIUS = exports.CHART_ANNOTATION_DEFAULT_DY = exports.CHART_ANNOTATION_ARROWHEAD_WIDTH_FACTOR = exports.CHART_ANNOTATION_ARROWHEAD_SPREAD = exports.CHART_ANNOTATION_ARROWHEAD_PRECISION = exports.CHART_ANNOTATION_ARROWHEAD_MIN_SIZE = exports.CHART_ANIMATION_DURATION_DEFAULT = void 0;
6
+ exports.CHART_Y_TICK_COUNT = exports.CHART_TICK_LABEL_PRECISION_FACTOR = exports.CHART_SVG_ROLE = exports.CHART_SLICE_LABEL_PREFIX = exports.CHART_SIZE_FALLBACK = exports.CHART_SCATTER_MIN_RADIUS = exports.CHART_SCATTER_MAX_RADIUS = exports.CHART_SCATTER_DEFAULT_RADIUS = exports.CHART_RANGE_SELECTOR_DEFAULT_BUTTONS = exports.CHART_RADAR_RADIUS_INSET = exports.CHART_RADAR_MIN_RADIUS = exports.CHART_RADAR_MARKER_RADIUS = exports.CHART_POINT_MARKER_RADIUS = exports.CHART_PLOT_LINE_LABEL_TOP_OFFSET = exports.CHART_PLOT_LINE_LABEL_OFFSET = exports.CHART_PLOT_LINE_DEFAULT_WIDTH = exports.CHART_PLOT_BAND_DEFAULT_OPACITY = exports.CHART_PIE_RADIUS_INSET = exports.CHART_PIE_MIN_RADIUS = exports.CHART_PERCENT_TICK_STEP = exports.CHART_PERCENT_MIN = exports.CHART_PERCENT_MAX = exports.CHART_NICE_STEP_LADDER = exports.CHART_EPSILON = exports.CHART_DEFAULT_PALETTE = exports.CHART_DASH_ARRAY_SOLID = exports.CHART_DASH_ARRAY_DOTTED = exports.CHART_DASH_ARRAY_DASHED = exports.CHART_COLOR_FALLBACK = exports.CHART_BAR_SLOT_FILL_RATIO = exports.CHART_AXIS_LABEL_MIN_GAP = exports.CHART_AXIS_LABEL_CHAR_WIDTH = exports.CHART_ASPECT_RATIO = exports.CHART_ANNOTATION_LABEL_PADDING = exports.CHART_ANNOTATION_LABEL_MIN_WIDTH = exports.CHART_ANNOTATION_LABEL_HEIGHT = exports.CHART_ANNOTATION_LABEL_CHAR_WIDTH = exports.CHART_ANNOTATION_DEFAULT_WIDTH = exports.CHART_ANNOTATION_DEFAULT_RADIUS = exports.CHART_ANNOTATION_DEFAULT_DY = exports.CHART_ANNOTATION_ARROWHEAD_WIDTH_FACTOR = exports.CHART_ANNOTATION_ARROWHEAD_SPREAD = exports.CHART_ANNOTATION_ARROWHEAD_PRECISION = exports.CHART_ANNOTATION_ARROWHEAD_MIN_SIZE = exports.CHART_ANIMATION_DURATION_DEFAULT = void 0;
7
7
  var _intent = require("../../enums/Commons/intent.enum.cjs");
8
8
  const CHART_Y_TICK_COUNT = exports.CHART_Y_TICK_COUNT = 5;
9
9
  const CHART_ANIMATION_DURATION_DEFAULT = exports.CHART_ANIMATION_DURATION_DEFAULT = 600;
@@ -75,4 +75,85 @@ const CHART_SCATTER_DEFAULT_RADIUS = exports.CHART_SCATTER_DEFAULT_RADIUS = 5;
75
75
  const CHART_SCATTER_MIN_RADIUS = exports.CHART_SCATTER_MIN_RADIUS = 5;
76
76
  const CHART_SCATTER_MAX_RADIUS = exports.CHART_SCATTER_MAX_RADIUS = 36;
77
77
  const CHART_SLICE_LABEL_PREFIX = exports.CHART_SLICE_LABEL_PREFIX = "Slice";
78
- const CHART_SVG_ROLE = exports.CHART_SVG_ROLE = "group";
78
+ const CHART_SVG_ROLE = exports.CHART_SVG_ROLE = "group";
79
+ const CHART_AXIS_LABEL_CHAR_WIDTH = exports.CHART_AXIS_LABEL_CHAR_WIDTH = 8;
80
+ const CHART_AXIS_LABEL_MIN_GAP = exports.CHART_AXIS_LABEL_MIN_GAP = 8;
81
+ const CHART_SIZE_FALLBACK = exports.CHART_SIZE_FALLBACK = {
82
+ boxPlot: {
83
+ width: 600,
84
+ height: 400
85
+ },
86
+ bullet: {
87
+ width: 600,
88
+ height: 400
89
+ },
90
+ candlestick: {
91
+ width: 600,
92
+ height: 400
93
+ },
94
+ pareto: {
95
+ width: 640,
96
+ height: 400
97
+ },
98
+ pictorial: {
99
+ width: 600,
100
+ height: 400
101
+ },
102
+ pyramid: {
103
+ width: 600,
104
+ height: 400
105
+ },
106
+ sankey: {
107
+ width: 600,
108
+ height: 400
109
+ },
110
+ streamgraph: {
111
+ width: 700,
112
+ height: 420
113
+ },
114
+ treemap: {
115
+ width: 600,
116
+ height: 400
117
+ },
118
+ variwide: {
119
+ width: 600,
120
+ height: 400
121
+ },
122
+ wordCloud: {
123
+ width: 800,
124
+ height: 500
125
+ },
126
+ gauge: {
127
+ width: 360,
128
+ height: 280
129
+ },
130
+ map: {
131
+ width: 1e3,
132
+ height: 500
133
+ },
134
+ sparkline: {
135
+ width: 120,
136
+ height: 30
137
+ },
138
+ polar: {
139
+ width: 360,
140
+ height: 360
141
+ },
142
+ polarBar: {
143
+ width: 400,
144
+ height: 400
145
+ },
146
+ radar: {
147
+ width: 360,
148
+ height: 360
149
+ },
150
+ sunburst: {
151
+ width: 400,
152
+ height: 400
153
+ }
154
+ };
155
+ const CHART_ASPECT_RATIO = exports.CHART_ASPECT_RATIO = {
156
+ radial: 1,
157
+ gauge: 280 / 360,
158
+ map: 0.5
159
+ };
@@ -268,3 +268,116 @@ export declare const CHART_SLICE_LABEL_PREFIX = "Slice";
268
268
  * focusable points be announced.
269
269
  ********************************************************/
270
270
  export declare const CHART_SVG_ROLE = "group";
271
+ /*********************************************************
272
+ * CHART_AXIS_LABEL_CHAR_WIDTH / CHART_AXIS_LABEL_MIN_GAP — décimation (#1325)
273
+ *
274
+ * @description
275
+ * Repli (SSR, avant mesure) pour la largeur d'une étiquette de l'axe X (px par caractère,
276
+ * pour la police 0.75rem par défaut, taillée sur le glyphe large) et
277
+ * espace minimal exigé entre deux étiquettes voisines. Servent à calculer
278
+ * le pas de décimation « une étiquette sur N ». Après montage la largeur est mesurée :
279
+ * la largeur par caractère ne sert plus qu'au premier rendu (l'écart reste utilisé), où un
280
+ * `--origam-chart__axis-label---font-size` très supérieur au défaut peut sous-estimer.
281
+ ********************************************************/
282
+ export declare const CHART_AXIS_LABEL_CHAR_WIDTH = 8;
283
+ export declare const CHART_AXIS_LABEL_MIN_GAP = 8;
284
+ /*********************************************************
285
+ * CHART_SIZE_FALLBACK (#1324)
286
+ *
287
+ * @description
288
+ * Taille de la surface de dessin d'un chart tant que rien n'est mesure
289
+ * (SSR, avant montage, boite nulle) : c'est l'ancien `viewBox` fige,
290
+ * conserve comme repli pour que le premier rendu serveur et client
291
+ * restent identiques. Une fois la boite du conteneur mesuree
292
+ * (`useChartSize`), ces valeurs ne servent plus.
293
+ * Les charts a rapport impose (`CHART_ASPECT_RATIO`) gardent un repli
294
+ * a ce meme rapport.
295
+ ********************************************************/
296
+ export declare const CHART_SIZE_FALLBACK: {
297
+ readonly boxPlot: {
298
+ readonly width: 600;
299
+ readonly height: 400;
300
+ };
301
+ readonly bullet: {
302
+ readonly width: 600;
303
+ readonly height: 400;
304
+ };
305
+ readonly candlestick: {
306
+ readonly width: 600;
307
+ readonly height: 400;
308
+ };
309
+ readonly pareto: {
310
+ readonly width: 640;
311
+ readonly height: 400;
312
+ };
313
+ readonly pictorial: {
314
+ readonly width: 600;
315
+ readonly height: 400;
316
+ };
317
+ readonly pyramid: {
318
+ readonly width: 600;
319
+ readonly height: 400;
320
+ };
321
+ readonly sankey: {
322
+ readonly width: 600;
323
+ readonly height: 400;
324
+ };
325
+ readonly streamgraph: {
326
+ readonly width: 700;
327
+ readonly height: 420;
328
+ };
329
+ readonly treemap: {
330
+ readonly width: 600;
331
+ readonly height: 400;
332
+ };
333
+ readonly variwide: {
334
+ readonly width: 600;
335
+ readonly height: 400;
336
+ };
337
+ readonly wordCloud: {
338
+ readonly width: 800;
339
+ readonly height: 500;
340
+ };
341
+ readonly gauge: {
342
+ readonly width: 360;
343
+ readonly height: 280;
344
+ };
345
+ readonly map: {
346
+ readonly width: 1000;
347
+ readonly height: 500;
348
+ };
349
+ readonly sparkline: {
350
+ readonly width: 120;
351
+ readonly height: 30;
352
+ };
353
+ readonly polar: {
354
+ readonly width: 360;
355
+ readonly height: 360;
356
+ };
357
+ readonly polarBar: {
358
+ readonly width: 400;
359
+ readonly height: 400;
360
+ };
361
+ readonly radar: {
362
+ readonly width: 360;
363
+ readonly height: 360;
364
+ };
365
+ readonly sunburst: {
366
+ readonly width: 400;
367
+ readonly height: 400;
368
+ };
369
+ };
370
+ /*********************************************************
371
+ * CHART_ASPECT_RATIO (#1324)
372
+ *
373
+ * @description
374
+ * Rapport hauteur / largeur impose a la surface de dessin des charts
375
+ * dont la geometrie ne se deforme pas (`useChartSize`, option
376
+ * `aspectRatio`). `radial` : cercle, 1:1. `gauge` : demi-anneau, rapport
377
+ * historique 280 / 360. `map` : planisphere 2:1.
378
+ ********************************************************/
379
+ export declare const CHART_ASPECT_RATIO: {
380
+ readonly radial: 1;
381
+ readonly gauge: number;
382
+ readonly map: 0.5;
383
+ };
@@ -61,3 +61,30 @@ export const CHART_SCATTER_MIN_RADIUS = 5;
61
61
  export const CHART_SCATTER_MAX_RADIUS = 36;
62
62
  export const CHART_SLICE_LABEL_PREFIX = "Slice";
63
63
  export const CHART_SVG_ROLE = "group";
64
+ export const CHART_AXIS_LABEL_CHAR_WIDTH = 8;
65
+ export const CHART_AXIS_LABEL_MIN_GAP = 8;
66
+ export const CHART_SIZE_FALLBACK = {
67
+ boxPlot: { width: 600, height: 400 },
68
+ bullet: { width: 600, height: 400 },
69
+ candlestick: { width: 600, height: 400 },
70
+ pareto: { width: 640, height: 400 },
71
+ pictorial: { width: 600, height: 400 },
72
+ pyramid: { width: 600, height: 400 },
73
+ sankey: { width: 600, height: 400 },
74
+ streamgraph: { width: 700, height: 420 },
75
+ treemap: { width: 600, height: 400 },
76
+ variwide: { width: 600, height: 400 },
77
+ wordCloud: { width: 800, height: 500 },
78
+ gauge: { width: 360, height: 280 },
79
+ map: { width: 1e3, height: 500 },
80
+ sparkline: { width: 120, height: 30 },
81
+ polar: { width: 360, height: 360 },
82
+ polarBar: { width: 400, height: 400 },
83
+ radar: { width: 360, height: 360 },
84
+ sunburst: { width: 400, height: 400 }
85
+ };
86
+ export const CHART_ASPECT_RATIO = {
87
+ radial: 1,
88
+ gauge: 280 / 360,
89
+ map: 0.5
90
+ };
@@ -100,3 +100,14 @@ export interface IChartSecondaryYAxis {
100
100
  /** Optional axis title rendered alongside the right axis. */
101
101
  title?: string;
102
102
  }
103
+ /*********************************************************
104
+ * IChartAxisLabelSlot (#1325)
105
+ *
106
+ * @description
107
+ * Une étiquette X avec son index et son état de décimation.
108
+ ********************************************************/
109
+ export interface IChartAxisLabelSlot {
110
+ tick: IChartTick;
111
+ i: number;
112
+ shown: boolean;
113
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.decimateAxisTicks = decimateAxisTicks;
7
+ exports.measureWidestAxisLabel = measureWidestAxisLabel;
8
+ var _chart = require("../../consts/Chart/chart.const.cjs");
9
+ function measureWidestAxisLabel(root) {
10
+ if (!root) return null;
11
+ const nodes = Array.from(root.querySelectorAll(".origam-chart__axis-label--x"));
12
+ let widest = 0;
13
+ for (const node of nodes) {
14
+ const length = typeof node.getComputedTextLength === "function" ? node.getComputedTextLength() : 0;
15
+ if (length > widest) widest = length;
16
+ }
17
+ return widest > 0 ? widest : null;
18
+ }
19
+ function decimateAxisTicks(ticks, format, measured) {
20
+ let longest = 0;
21
+ for (const tick of ticks) longest = Math.max(longest, format(tick.value).length);
22
+ const widest = measured ?? longest * _chart.CHART_AXIS_LABEL_CHAR_WIDTH;
23
+ let pitch = Infinity;
24
+ let previous;
25
+ for (const tick of ticks) {
26
+ if (previous !== void 0) pitch = Math.min(pitch, Math.abs(tick.position - previous));
27
+ previous = tick.position;
28
+ }
29
+ const step = Number.isFinite(pitch) && pitch > 0 ? Math.max(1, Math.ceil((widest + _chart.CHART_AXIS_LABEL_MIN_GAP) / pitch)) : 1;
30
+ return ticks.map((tick, i) => ({
31
+ tick,
32
+ i,
33
+ shown: i % step === 0
34
+ }));
35
+ }
@@ -0,0 +1,24 @@
1
+ import type { IChartAxisLabelSlot } from '../../interfaces/Chart/chart-axis.interface';
2
+ import type { IChartTick } from '../../interfaces/Chart/chart.interface';
3
+ /*********************************************************
4
+ * measureWidestAxisLabel (#1325)
5
+ *
6
+ * @description
7
+ * Largeur réelle (getComputedTextLength) de la plus longue étiquette X
8
+ * sous `root`, ou `null` quand rien n'est mesurable (SSR, jsdom, aucun
9
+ * label, largeur nulle) : l'appelant retombe alors sur l'estimation.
10
+ * Ces fonctions vivent hors du .vue : le paquet publié expose les
11
+ * .vue sans types, et un `ref<…>` ou un lambda typé y devient erreur
12
+ * pour tout consommateur qui les vérifie.
13
+ ********************************************************/
14
+ export declare function measureWidestAxisLabel(root: ParentNode | null): number | null;
15
+ /*********************************************************
16
+ * decimateAxisTicks (#1325)
17
+ *
18
+ * @description
19
+ * Une étiquette sur N : N = ceil((largeur + écart minimal) / plus petit
20
+ * écart entre graduations). `measured` (px) l'emporte ; sinon la largeur
21
+ * est estimée (caractères × CHART_AXIS_LABEL_CHAR_WIDTH), identique côté
22
+ * serveur et client.
23
+ ********************************************************/
24
+ export declare function decimateAxisTicks(ticks: Array<IChartTick>, format: (value: number | string) => string, measured: number | null): Array<IChartAxisLabelSlot>;
@@ -0,0 +1,24 @@
1
+ import { CHART_AXIS_LABEL_CHAR_WIDTH, CHART_AXIS_LABEL_MIN_GAP } from "../../consts/Chart/chart.const.js";
2
+ export function measureWidestAxisLabel(root) {
3
+ if (!root) return null;
4
+ const nodes = Array.from(root.querySelectorAll(".origam-chart__axis-label--x"));
5
+ let widest = 0;
6
+ for (const node of nodes) {
7
+ const length = typeof node.getComputedTextLength === "function" ? node.getComputedTextLength() : 0;
8
+ if (length > widest) widest = length;
9
+ }
10
+ return widest > 0 ? widest : null;
11
+ }
12
+ export function decimateAxisTicks(ticks, format, measured) {
13
+ let longest = 0;
14
+ for (const tick of ticks) longest = Math.max(longest, format(tick.value).length);
15
+ const widest = measured ?? longest * CHART_AXIS_LABEL_CHAR_WIDTH;
16
+ let pitch = Infinity;
17
+ let previous;
18
+ for (const tick of ticks) {
19
+ if (previous !== void 0) pitch = Math.min(pitch, Math.abs(tick.position - previous));
20
+ previous = tick.position;
21
+ }
22
+ const step = Number.isFinite(pitch) && pitch > 0 ? Math.max(1, Math.ceil((widest + CHART_AXIS_LABEL_MIN_GAP) / pitch)) : 1;
23
+ return ticks.map((tick, i) => ({ tick, i, shown: i % step === 0 }));
24
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "origam",
3
- "version": "2.37.37",
3
+ "version": "2.37.39",
4
4
  "type": "module",
5
5
  "description": "origam — a Vue 3 design system with multi-theme design tokens, CSS-first components and TypeScript types.",
6
6
  "keywords": [