@cfasim-ui/docs 0.4.15 → 0.5.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.
@@ -223,6 +223,134 @@ contrast).
223
223
  </template>
224
224
  </ComponentDemo>
225
225
 
226
+ ### Value labels on bars
227
+
228
+ Set `bar-labels` to write values directly on the bars (pair with
229
+ `:value-axis="false"` for an axis-free look). Pass an options object to tune:
230
+
231
+ - `format` — a `NumberFormat` or `(value, ctx) => string` (`ctx` has
232
+ `categoryIndex` / `seriesIndex`); return `""` to drop a label.
233
+ - `align` — `"center"` (default), `"start"`, or `"end"` within the segment.
234
+ - `color` — auto-contrast per segment by default, or a fixed color.
235
+ - Small/overlapping labels overflow past the segment edge and are spread
236
+ apart (`overlap: "shift"`) or dropped (`overlap: "hide"`).
237
+
238
+ `category-header` / `value-header` title the two columns, and
239
+ `category-align="start"` left-aligns the category labels.
240
+
241
+ <ComponentDemo>
242
+ <BarChart
243
+ :series="[
244
+ { data: [99, 88, 50, 1], legend: 'High', color: '#3f1f5e' },
245
+ { data: [0.5, 10, 30, 20], legend: 'Medium', color: '#8a5fb0' },
246
+ { data: [0.5, 2, 20, 79], legend: 'Low', color: '#c9aee0' },
247
+ ]"
248
+ :categories="['Alpha', 'Beta', 'Gamma', 'Delta']"
249
+ title="Projected outbreak size by scenario"
250
+ :title-style="{ fontSize: 16 }"
251
+ orientation="horizontal"
252
+ layout="stacked"
253
+ :value-axis="false"
254
+ category-header="Scenario"
255
+ value-header="Proportion of simulations in each category"
256
+ category-align="start"
257
+ :height="260"
258
+ :chart-padding="{ left: 18, right: 64 }"
259
+ :tick-label-style="{ fontSize: 11, color: 'currentColor' }"
260
+ :bar-labels="{
261
+ align: 'start',
262
+ fontWeight: 600,
263
+ format: (v, { categoryIndex }) =>
264
+ v < 1
265
+ ? '<1%'
266
+ : categoryIndex === 0
267
+ ? `${Math.round(v)}%`
268
+ : String(Math.round(v)),
269
+ }"
270
+ />
271
+
272
+ <template #code>
273
+
274
+ ```vue
275
+ <BarChart
276
+ :series="[
277
+ { data: [99, 88, 50, 1], legend: 'High', color: '#3f1f5e' },
278
+ { data: [0.5, 10, 30, 20], legend: 'Medium', color: '#8a5fb0' },
279
+ { data: [0.5, 2, 20, 79], legend: 'Low', color: '#c9aee0' },
280
+ ]"
281
+ :categories="['Alpha', 'Beta', 'Gamma', 'Delta']"
282
+ title="Projected outbreak size by scenario"
283
+ :title-style="{ fontSize: 16 }"
284
+ orientation="horizontal"
285
+ layout="stacked"
286
+ :value-axis="false"
287
+ category-header="Scenario"
288
+ value-header="Proportion of simulations in each category"
289
+ category-align="start"
290
+ :height="260"
291
+ :chart-padding="{ left: 18, right: 64 }"
292
+ :tick-label-style="{ fontSize: 11, color: 'currentColor' }"
293
+ :bar-labels="{
294
+ align: 'start',
295
+ fontWeight: 600,
296
+ format: (v, { categoryIndex }) =>
297
+ v < 1
298
+ ? '<1%'
299
+ : categoryIndex === 0
300
+ ? `${Math.round(v)}%`
301
+ : String(Math.round(v)),
302
+ }"
303
+ />
304
+ ```
305
+
306
+ </template>
307
+ </ComponentDemo>
308
+
309
+ #### Small segments
310
+
311
+ A single proportion bar with two tiny tail segments (98% / 1% / 1%). The
312
+ dominant segment labels inside; the two slivers can't fit their text, so the
313
+ labels overflow to the right and the overlap pass spreads them apart instead
314
+ of letting them pile up.
315
+
316
+ <ComponentDemo>
317
+ <BarChart
318
+ :series="[
319
+ { data: [98], legend: 'Recovered', color: '#3f1f5e' },
320
+ { data: [1], legend: 'Hospitalized', color: '#8a5fb0' },
321
+ { data: [1], legend: 'Deceased', color: '#c9aee0' },
322
+ ]"
323
+ :categories="['Outcome']"
324
+ orientation="horizontal"
325
+ layout="stacked"
326
+ :value-axis="false"
327
+ :height="120"
328
+ :chart-padding="{ left: 60, right: 40 }"
329
+ :bar-labels="{ format: (v) => `${v}%` }"
330
+ />
331
+
332
+ <template #code>
333
+
334
+ ```vue
335
+ <BarChart
336
+ :series="[
337
+ { data: [98], legend: 'Recovered', color: '#3f1f5e' },
338
+ { data: [1], legend: 'Hospitalized', color: '#8a5fb0' },
339
+ { data: [1], legend: 'Deceased', color: '#c9aee0' },
340
+ ]"
341
+ :categories="['Outcome']"
342
+ orientation="horizontal"
343
+ layout="stacked"
344
+ :value-axis="false"
345
+ :height="120"
346
+ :chart-padding="{ left: 60, right: 40 }"
347
+ :bar-labels="{ format: (v) => `${v}%` }"
348
+ />
349
+ ```
350
+
351
+ </template>
352
+ </ComponentDemo>
353
+
226
354
  ### Custom value tick format
227
355
 
228
356
  Use `value-tick-format` to format the value-axis labels. `tooltip-value-format` controls the tooltip values independently; if omitted, the tooltip uses `value-tick-format`.
@@ -593,6 +721,7 @@ anchor. `lineColor`, `lineWidth`, and `lineDash` style the line.
593
721
  | `csv` | `string \| (() =&gt; string)` | No | — |
594
722
  | `filename` | `string` | No | — |
595
723
  | `downloadLink` | `boolean \| string` | No | — |
724
+ | `downloadButton` | `boolean \| string` | No | — |
596
725
  | `annotations` | `readonly ChartAnnotation[]` | No | — |
597
726
  | `chartPadding` | `ChartPadding` | No | — |
598
727
  | `data` | `BarChartData` | No | — |
@@ -607,8 +736,13 @@ anchor. `lineColor`, `lineWidth`, and `lineDash` style the line.
607
736
  | `valueTicks` | `number \| number[]` | No | — |
608
737
  | `valueTickFormat` | `NumberFormat` | No | — |
609
738
  | `categoryFormat` | `(label: string, index: number) =&gt; string` | No | — |
739
+ | `categoryAlign` | `"start" \| "center" \| "end"` | No | — |
610
740
  | `dateFormat` | `DateFormat` | No | — |
611
741
  | `barPadding` | `number` | No | `0.2` |
612
742
  | `groupGap` | `number` | No | `1` |
613
743
  | `valueGrid` | `boolean` | No | `true` |
744
+ | `valueAxis` | `boolean` | No | `true` |
745
+ | `barLabels` | `boolean \| BarLabelStyle` | No | — |
746
+ | `categoryHeader` | `string` | No | — |
747
+ | `valueHeader` | `string` | No | — |
614
748