@tekkare/romulus 0.1.155 → 0.1.156
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/dist/module.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<script setup lang="ts">
|
|
7
7
|
import { computed } from 'vue'
|
|
8
8
|
import { useChartTheme } from '../composables/useChartTheme'
|
|
9
|
-
import { rmBarHorizontalOption, rmBarVerticalOption, type RmSeriesInput, RM_CHART_HEIGHTS } from '../utils/chart'
|
|
9
|
+
import { rmBarHorizontalOption, rmBarVerticalOption, type RmBarLabelFormatter, type RmSeriesInput, RM_CHART_HEIGHTS } from '../utils/chart'
|
|
10
10
|
|
|
11
11
|
const props = withDefaults(defineProps<{
|
|
12
12
|
/** Categories de l'axe : annees, libelles d'indicateur. */
|
|
@@ -15,8 +15,12 @@ const props = withDefaults(defineProps<{
|
|
|
15
15
|
horizontal?: boolean
|
|
16
16
|
height?: keyof typeof RM_CHART_HEIGHTS | number
|
|
17
17
|
description?: string
|
|
18
|
-
/**
|
|
19
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Etiquette de chaque barre : en bout de barre a l'horizontale, au-dessus a
|
|
20
|
+
* la verticale. Sans elle, la valeur se lit sur l'axe et dans l'infobulle,
|
|
21
|
+
* ce qui suffit des que les barres sont nombreuses.
|
|
22
|
+
*/
|
|
23
|
+
labelFormatter?: RmBarLabelFormatter
|
|
20
24
|
}>(), {
|
|
21
25
|
horizontal: false,
|
|
22
26
|
height: 'standard',
|
|
@@ -36,7 +40,14 @@ const option = computed(() =>
|
|
|
36
40
|
decal.value,
|
|
37
41
|
props.labelFormatter,
|
|
38
42
|
)
|
|
39
|
-
: rmBarVerticalOption(
|
|
43
|
+
: rmBarVerticalOption(
|
|
44
|
+
props.categories,
|
|
45
|
+
props.series,
|
|
46
|
+
theme.value,
|
|
47
|
+
palette.value.cat,
|
|
48
|
+
decal.value,
|
|
49
|
+
props.labelFormatter,
|
|
50
|
+
),
|
|
40
51
|
)
|
|
41
52
|
</script>
|
|
42
53
|
|
|
@@ -177,7 +177,13 @@ export interface RmSeriesInput {
|
|
|
177
177
|
axis?: 0 | 1;
|
|
178
178
|
}
|
|
179
179
|
/** Bar chart vertical, une ou plusieurs series, empilable. */
|
|
180
|
-
|
|
180
|
+
/**
|
|
181
|
+
* Etiquette d'une barre. L'index est donne parce que la valeur seule ne suffit
|
|
182
|
+
* pas toujours : une part se lit contre un total que l'appelant tient a cote
|
|
183
|
+
* (« 1 240 (18 %) »), et c'est l'index qui la retrouve.
|
|
184
|
+
*/
|
|
185
|
+
export type RmBarLabelFormatter = (value: number, index: number) => string;
|
|
186
|
+
export declare function rmBarVerticalOption(categories: (string | number)[], series: RmSeriesInput[], theme: RmChartTheme, palette: string[], decal?: boolean, formatter?: RmBarLabelFormatter): {
|
|
181
187
|
tooltip: {
|
|
182
188
|
trigger: string;
|
|
183
189
|
backgroundColor: string;
|
|
@@ -282,6 +288,17 @@ export declare function rmBarVerticalOption(categories: (string | number)[], ser
|
|
|
282
288
|
color: string;
|
|
283
289
|
borderRadius: number[];
|
|
284
290
|
};
|
|
291
|
+
label: {
|
|
292
|
+
show: boolean;
|
|
293
|
+
position: string;
|
|
294
|
+
fontSize: number;
|
|
295
|
+
color: string;
|
|
296
|
+
fontFamily: string;
|
|
297
|
+
formatter: (p: {
|
|
298
|
+
value: number;
|
|
299
|
+
dataIndex: number;
|
|
300
|
+
}) => string;
|
|
301
|
+
} | undefined;
|
|
285
302
|
}[];
|
|
286
303
|
backgroundColor: string;
|
|
287
304
|
animation: boolean;
|
|
@@ -296,7 +313,7 @@ export declare function rmBarVerticalOption(categories: (string | number)[], ser
|
|
|
296
313
|
};
|
|
297
314
|
};
|
|
298
315
|
/** Bar chart horizontal, avec valeur affichee en bout de barre. */
|
|
299
|
-
export declare function rmBarHorizontalOption(labels: string[], values: (number | null)[], theme: RmChartTheme, palette: string[], decal?: boolean, formatter?:
|
|
316
|
+
export declare function rmBarHorizontalOption(labels: string[], values: (number | null)[], theme: RmChartTheme, palette: string[], decal?: boolean, formatter?: RmBarLabelFormatter): {
|
|
300
317
|
grid: {
|
|
301
318
|
left: number;
|
|
302
319
|
right: number;
|
|
@@ -356,6 +373,7 @@ export declare function rmBarHorizontalOption(labels: string[], values: (number
|
|
|
356
373
|
fontFamily: string;
|
|
357
374
|
formatter: ((p: {
|
|
358
375
|
value: number;
|
|
376
|
+
dataIndex: number;
|
|
359
377
|
}) => string) | undefined;
|
|
360
378
|
};
|
|
361
379
|
}[];
|
|
@@ -140,7 +140,7 @@ const axisCommon = (theme) => ({
|
|
|
140
140
|
axisLine: { lineStyle: { color: theme.axisLine } },
|
|
141
141
|
splitLine: { lineStyle: { color: theme.splitLine } }
|
|
142
142
|
});
|
|
143
|
-
export function rmBarVerticalOption(categories, series, theme, palette, decal = false) {
|
|
143
|
+
export function rmBarVerticalOption(categories, series, theme, palette, decal = false, formatter) {
|
|
144
144
|
return {
|
|
145
145
|
...rmBaseOption(theme, decal),
|
|
146
146
|
tooltip: { ...rmBaseOption(theme, decal).tooltip, trigger: rmTooltipTrigger(series.length) },
|
|
@@ -155,7 +155,17 @@ export function rmBarVerticalOption(categories, series, theme, palette, decal =
|
|
|
155
155
|
name: s.name,
|
|
156
156
|
stack: s.stack,
|
|
157
157
|
data: s.data,
|
|
158
|
-
itemStyle: { color: s.color ?? rmSeriesColor(palette, i), borderRadius: [3, 3, 0, 0] }
|
|
158
|
+
itemStyle: { color: s.color ?? rmSeriesColor(palette, i), borderRadius: [3, 3, 0, 0] },
|
|
159
|
+
// L'etiquette ne se pose que si l'appelant la demande : sur une serie
|
|
160
|
+
// longue elle se chevaucherait, et l'axe dit deja la valeur.
|
|
161
|
+
label: formatter ? {
|
|
162
|
+
show: true,
|
|
163
|
+
position: "top",
|
|
164
|
+
fontSize: 11,
|
|
165
|
+
color: theme.mutedColor,
|
|
166
|
+
fontFamily: FONT,
|
|
167
|
+
formatter: (p) => formatter(p.value, p.dataIndex)
|
|
168
|
+
} : void 0
|
|
159
169
|
}))
|
|
160
170
|
};
|
|
161
171
|
}
|
|
@@ -178,7 +188,7 @@ export function rmBarHorizontalOption(labels, values, theme, palette, decal = fa
|
|
|
178
188
|
fontSize: 11,
|
|
179
189
|
color: theme.mutedColor,
|
|
180
190
|
fontFamily: FONT,
|
|
181
|
-
formatter: formatter ? (p) => formatter(p.value) : void 0
|
|
191
|
+
formatter: formatter ? (p) => formatter(p.value, p.dataIndex) : void 0
|
|
182
192
|
}
|
|
183
193
|
}]
|
|
184
194
|
};
|