origam 2.37.38 → 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.
- package/CHANGELOG.md +17 -0
- package/dist/src/components/Chart/OrigamChartAxis.vue +15 -1
- package/dist/src/consts/Chart/chart.const.cjs +3 -1
- package/dist/src/consts/Chart/chart.const.d.ts +13 -0
- package/dist/src/consts/Chart/chart.const.js +2 -0
- package/dist/src/interfaces/Chart/chart-axis.interface.d.ts +11 -0
- package/dist/src/utils/Chart/chart-axis-label.util.cjs +35 -0
- package/dist/src/utils/Chart/chart-axis-label.util.d.ts +24 -0
- package/dist/src/utils/Chart/chart-axis-label.util.js +24 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,23 @@ This project follows [Semantic Versioning](https://semver.org).
|
|
|
18
18
|
|
|
19
19
|
## [Unreleased]
|
|
20
20
|
|
|
21
|
+
## [2.37.39] - 2026-11-05
|
|
22
|
+
|
|
23
|
+
### Fixed — `OrigamChartCartesian` : les étiquettes de l'axe X ne se chevauchent plus sur un chart étroit (#1325)
|
|
24
|
+
|
|
25
|
+
Depuis 2.37.37, le cartésien suit la largeur de son conteneur. Sur un chart étroit, les graduations se resserrent et les étiquettes se chevauchaient : à 320 px, 4 paires sur 12 étiquettes.
|
|
26
|
+
|
|
27
|
+
- **Décimation** : une étiquette sur N reste affichée. N est calculé à partir de la largeur du plus long label et de l'écart minimal (`CHART_AXIS_LABEL_MIN_GAP`) rapportés au plus petit pas entre graduations. Le texte reste horizontal et entier.
|
|
28
|
+
- **Largeur mesurée** : après le montage, la largeur réelle des labels est mesurée (`getComputedTextLength`). En SSR et avant la mesure, une estimation (`CHART_AXIS_LABEL_CHAR_WIDTH`) sert de repli, ce qui garde un markup initial identique côté serveur et côté client. La mesure suit la police réelle, y compris une taille surchargée par un thème.
|
|
29
|
+
- Les labels écartés restent dans le DOM avec `visibility="hidden"` et `aria-hidden`. Chaque point garde la catégorie et la valeur dans son nom accessible.
|
|
30
|
+
- La logique vit dans `utils/Chart/chart-axis-label.util.ts` (`measureWidestAxisLabel`, `decimateAxisTicks`). L'interface `IChartAxisLabelSlot` est ajoutée.
|
|
31
|
+
- **Vérifié** par la spec `chart-cartesian-axis-label-decimation.spec.ts`, inscrite dans `GREEN_SPECS` :
|
|
32
|
+
- à 320 px, elle est rouge sur le parent (4 intersections) et verte avec le correctif (0 intersection, 6 étiquettes sur 12) ;
|
|
33
|
+
- le cas « police d'axe grossie à 1.5rem » est rouge avec l'estimation seule (1 intersection) et vert avec la mesure ;
|
|
34
|
+
- 600 et 960 px sont inchangés ;
|
|
35
|
+
- un TU SSR passe sans warning (PR #1335).
|
|
36
|
+
- **Limite** : un changement de taille de police seul, à l'exécution, ne déclenche pas de nouvelle mesure. Elle est relancée quand les graduations ou `xAxisFormat` changent.
|
|
37
|
+
|
|
21
38
|
## [2.37.38] - 2026-11-05
|
|
22
39
|
|
|
23
40
|
### Fixed — Charts : la surface de dessin suit la taille du conteneur sur 19 charts (#1324)
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
<g
|
|
19
19
|
v-if="showAxis"
|
|
20
|
+
ref="axisRef"
|
|
20
21
|
class="origam-chart__axis"
|
|
21
22
|
data-cy="origam-chart-axis"
|
|
22
23
|
>
|
|
@@ -46,9 +47,11 @@
|
|
|
46
47
|
{{ formatY(tick.value as number) }}
|
|
47
48
|
</text>
|
|
48
49
|
<text
|
|
49
|
-
v-for="
|
|
50
|
+
v-for="{ tick, i, shown } in xTicks"
|
|
50
51
|
:key="`xl-${ i }`"
|
|
51
52
|
class="origam-chart__axis-label origam-chart__axis-label--x"
|
|
53
|
+
:visibility="shown ? undefined : 'hidden'"
|
|
54
|
+
:aria-hidden="shown ? undefined : 'true'"
|
|
52
55
|
:x="tick.position"
|
|
53
56
|
:y="plot.y1 + 16"
|
|
54
57
|
text-anchor="middle"
|
|
@@ -84,6 +87,8 @@
|
|
|
84
87
|
</template>
|
|
85
88
|
|
|
86
89
|
<script lang="ts" setup>
|
|
90
|
+
import { computed, nextTick, onMounted, ref, shallowRef, watch } from "vue";
|
|
91
|
+
import { decimateAxisTicks, measureWidestAxisLabel } from "../../utils/Chart/chart-axis-label.util";
|
|
87
92
|
defineOptions({
|
|
88
93
|
name: "OrigamChartAxis",
|
|
89
94
|
inheritAttrs: false
|
|
@@ -104,6 +109,15 @@ const formatX = (value) => {
|
|
|
104
109
|
if (props.xAxisFormat) return props.xAxisFormat(value);
|
|
105
110
|
return String(value);
|
|
106
111
|
};
|
|
112
|
+
const axisRef = shallowRef(null);
|
|
113
|
+
const measuredWidest = ref(measureWidestAxisLabel(null));
|
|
114
|
+
const measure = async () => {
|
|
115
|
+
await nextTick();
|
|
116
|
+
measuredWidest.value = measureWidestAxisLabel(axisRef.value);
|
|
117
|
+
};
|
|
118
|
+
onMounted(measure);
|
|
119
|
+
watch(() => [props.ticks.x, props.xAxisFormat], measure);
|
|
120
|
+
const xTicks = computed(() => decimateAxisTicks(props.ticks.x, formatX, measuredWidest.value));
|
|
107
121
|
const formatY = (value) => {
|
|
108
122
|
if (props.yAxisFormat) return props.yAxisFormat(value);
|
|
109
123
|
return String(value);
|
|
@@ -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_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;
|
|
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;
|
|
@@ -76,6 +76,8 @@ 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
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;
|
|
79
81
|
const CHART_SIZE_FALLBACK = exports.CHART_SIZE_FALLBACK = {
|
|
80
82
|
boxPlot: {
|
|
81
83
|
width: 600,
|
|
@@ -268,6 +268,19 @@ 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;
|
|
271
284
|
/*********************************************************
|
|
272
285
|
* CHART_SIZE_FALLBACK (#1324)
|
|
273
286
|
*
|
|
@@ -61,6 +61,8 @@ 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;
|
|
64
66
|
export const CHART_SIZE_FALLBACK = {
|
|
65
67
|
boxPlot: { width: 600, height: 400 },
|
|
66
68
|
bullet: { width: 600, height: 400 },
|
|
@@ -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
|
+
}
|