origam 2.37.37 → 2.37.38

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 (27) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/src/components/Chart/OrigamChartBoxPlot.vue +6 -7
  3. package/dist/src/components/Chart/OrigamChartBullet.vue +7 -8
  4. package/dist/src/components/Chart/OrigamChartCandlestick.vue +10 -11
  5. package/dist/src/components/Chart/OrigamChartGauge.vue +8 -6
  6. package/dist/src/components/Chart/OrigamChartHeatmap.vue +9 -5
  7. package/dist/src/components/Chart/OrigamChartMap.vue +14 -15
  8. package/dist/src/components/Chart/OrigamChartPareto.vue +9 -10
  9. package/dist/src/components/Chart/OrigamChartPictorial.vue +10 -11
  10. package/dist/src/components/Chart/OrigamChartPolar.vue +6 -7
  11. package/dist/src/components/Chart/OrigamChartPolarBar.vue +8 -8
  12. package/dist/src/components/Chart/OrigamChartPyramid.vue +6 -7
  13. package/dist/src/components/Chart/OrigamChartRadar.vue +7 -9
  14. package/dist/src/components/Chart/OrigamChartSankey.vue +6 -7
  15. package/dist/src/components/Chart/OrigamChartSparkline.vue +15 -17
  16. package/dist/src/components/Chart/OrigamChartStreamgraph.vue +9 -10
  17. package/dist/src/components/Chart/OrigamChartSunburst.vue +8 -8
  18. package/dist/src/components/Chart/OrigamChartTreemap.vue +6 -7
  19. package/dist/src/components/Chart/OrigamChartVariwide.vue +8 -9
  20. package/dist/src/components/Chart/OrigamChartWordCloud.vue +16 -13
  21. package/dist/src/composables/Chart/chart-size.composable.cjs +8 -3
  22. package/dist/src/composables/Chart/chart-size.composable.d.ts +9 -0
  23. package/dist/src/composables/Chart/chart-size.composable.js +8 -3
  24. package/dist/src/consts/Chart/chart.const.cjs +81 -2
  25. package/dist/src/consts/Chart/chart.const.d.ts +100 -0
  26. package/dist/src/consts/Chart/chart.const.js +25 -0
  27. 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_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,83 @@ 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_SIZE_FALLBACK = exports.CHART_SIZE_FALLBACK = {
80
+ boxPlot: {
81
+ width: 600,
82
+ height: 400
83
+ },
84
+ bullet: {
85
+ width: 600,
86
+ height: 400
87
+ },
88
+ candlestick: {
89
+ width: 600,
90
+ height: 400
91
+ },
92
+ pareto: {
93
+ width: 640,
94
+ height: 400
95
+ },
96
+ pictorial: {
97
+ width: 600,
98
+ height: 400
99
+ },
100
+ pyramid: {
101
+ width: 600,
102
+ height: 400
103
+ },
104
+ sankey: {
105
+ width: 600,
106
+ height: 400
107
+ },
108
+ streamgraph: {
109
+ width: 700,
110
+ height: 420
111
+ },
112
+ treemap: {
113
+ width: 600,
114
+ height: 400
115
+ },
116
+ variwide: {
117
+ width: 600,
118
+ height: 400
119
+ },
120
+ wordCloud: {
121
+ width: 800,
122
+ height: 500
123
+ },
124
+ gauge: {
125
+ width: 360,
126
+ height: 280
127
+ },
128
+ map: {
129
+ width: 1e3,
130
+ height: 500
131
+ },
132
+ sparkline: {
133
+ width: 120,
134
+ height: 30
135
+ },
136
+ polar: {
137
+ width: 360,
138
+ height: 360
139
+ },
140
+ polarBar: {
141
+ width: 400,
142
+ height: 400
143
+ },
144
+ radar: {
145
+ width: 360,
146
+ height: 360
147
+ },
148
+ sunburst: {
149
+ width: 400,
150
+ height: 400
151
+ }
152
+ };
153
+ const CHART_ASPECT_RATIO = exports.CHART_ASPECT_RATIO = {
154
+ radial: 1,
155
+ gauge: 280 / 360,
156
+ map: 0.5
157
+ };
@@ -268,3 +268,103 @@ 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_SIZE_FALLBACK (#1324)
273
+ *
274
+ * @description
275
+ * Taille de la surface de dessin d'un chart tant que rien n'est mesure
276
+ * (SSR, avant montage, boite nulle) : c'est l'ancien `viewBox` fige,
277
+ * conserve comme repli pour que le premier rendu serveur et client
278
+ * restent identiques. Une fois la boite du conteneur mesuree
279
+ * (`useChartSize`), ces valeurs ne servent plus.
280
+ * Les charts a rapport impose (`CHART_ASPECT_RATIO`) gardent un repli
281
+ * a ce meme rapport.
282
+ ********************************************************/
283
+ export declare const CHART_SIZE_FALLBACK: {
284
+ readonly boxPlot: {
285
+ readonly width: 600;
286
+ readonly height: 400;
287
+ };
288
+ readonly bullet: {
289
+ readonly width: 600;
290
+ readonly height: 400;
291
+ };
292
+ readonly candlestick: {
293
+ readonly width: 600;
294
+ readonly height: 400;
295
+ };
296
+ readonly pareto: {
297
+ readonly width: 640;
298
+ readonly height: 400;
299
+ };
300
+ readonly pictorial: {
301
+ readonly width: 600;
302
+ readonly height: 400;
303
+ };
304
+ readonly pyramid: {
305
+ readonly width: 600;
306
+ readonly height: 400;
307
+ };
308
+ readonly sankey: {
309
+ readonly width: 600;
310
+ readonly height: 400;
311
+ };
312
+ readonly streamgraph: {
313
+ readonly width: 700;
314
+ readonly height: 420;
315
+ };
316
+ readonly treemap: {
317
+ readonly width: 600;
318
+ readonly height: 400;
319
+ };
320
+ readonly variwide: {
321
+ readonly width: 600;
322
+ readonly height: 400;
323
+ };
324
+ readonly wordCloud: {
325
+ readonly width: 800;
326
+ readonly height: 500;
327
+ };
328
+ readonly gauge: {
329
+ readonly width: 360;
330
+ readonly height: 280;
331
+ };
332
+ readonly map: {
333
+ readonly width: 1000;
334
+ readonly height: 500;
335
+ };
336
+ readonly sparkline: {
337
+ readonly width: 120;
338
+ readonly height: 30;
339
+ };
340
+ readonly polar: {
341
+ readonly width: 360;
342
+ readonly height: 360;
343
+ };
344
+ readonly polarBar: {
345
+ readonly width: 400;
346
+ readonly height: 400;
347
+ };
348
+ readonly radar: {
349
+ readonly width: 360;
350
+ readonly height: 360;
351
+ };
352
+ readonly sunburst: {
353
+ readonly width: 400;
354
+ readonly height: 400;
355
+ };
356
+ };
357
+ /*********************************************************
358
+ * CHART_ASPECT_RATIO (#1324)
359
+ *
360
+ * @description
361
+ * Rapport hauteur / largeur impose a la surface de dessin des charts
362
+ * dont la geometrie ne se deforme pas (`useChartSize`, option
363
+ * `aspectRatio`). `radial` : cercle, 1:1. `gauge` : demi-anneau, rapport
364
+ * historique 280 / 360. `map` : planisphere 2:1.
365
+ ********************************************************/
366
+ export declare const CHART_ASPECT_RATIO: {
367
+ readonly radial: 1;
368
+ readonly gauge: number;
369
+ readonly map: 0.5;
370
+ };
@@ -61,3 +61,28 @@ 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_SIZE_FALLBACK = {
65
+ boxPlot: { width: 600, height: 400 },
66
+ bullet: { width: 600, height: 400 },
67
+ candlestick: { width: 600, height: 400 },
68
+ pareto: { width: 640, height: 400 },
69
+ pictorial: { width: 600, height: 400 },
70
+ pyramid: { width: 600, height: 400 },
71
+ sankey: { width: 600, height: 400 },
72
+ streamgraph: { width: 700, height: 420 },
73
+ treemap: { width: 600, height: 400 },
74
+ variwide: { width: 600, height: 400 },
75
+ wordCloud: { width: 800, height: 500 },
76
+ gauge: { width: 360, height: 280 },
77
+ map: { width: 1e3, height: 500 },
78
+ sparkline: { width: 120, height: 30 },
79
+ polar: { width: 360, height: 360 },
80
+ polarBar: { width: 400, height: 400 },
81
+ radar: { width: 360, height: 360 },
82
+ sunburst: { width: 400, height: 400 }
83
+ };
84
+ export const CHART_ASPECT_RATIO = {
85
+ radial: 1,
86
+ gauge: 280 / 360,
87
+ map: 0.5
88
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "origam",
3
- "version": "2.37.37",
3
+ "version": "2.37.38",
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": [