Skip to content

Commit 54a07f3

Browse files
committed
feat(a11y): use seeded patterns for bar charts
1 parent 2d7df54 commit 54a07f3

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

app/components/Compare/FacetBarChart.vue

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { VueUiHorizontalBar } from 'vue-data-ui/vue-ui-horizontal-bar'
44
import type { VueUiHorizontalBarConfig, VueUiHorizontalBarDatasetItem } from 'vue-data-ui'
55
import { getFrameworkColor, isListedFramework } from '~/utils/frameworks'
66
import { drawSmallNpmxLogoAndTaglineWatermark } from '~/composables/useChartWatermark'
7+
78
import {
89
loadFile,
910
insertLineBreaks,
@@ -237,14 +238,26 @@ const config = computed<VueUiHorizontalBarConfig>(() => {
237238
},
238239
}
239240
})
241+
240242
</script>
241243

242244
<template>
243245
<div class="font-mono facet-bar">
244246
<ClientOnly v-if="dataset.length">
245247
<VueUiHorizontalBar :key="chartKey" :dataset :config class="[direction:ltr]">
248+
<template #pattern="{ patternId, seriesIndex }">
249+
<ChartPatternSlot
250+
v-if="seriesIndex != 0"
251+
:id="patternId"
252+
:seed="seriesIndex"
253+
:foreground-color="colors.bg!"
254+
fallback-color="transparent"
255+
:max-size="24"
256+
:min-size="16"
257+
/>
258+
</template>
259+
246260
<template #svg="{ svg }">
247-
<!-- Inject npmx logo & tagline during SVG and PNG print -->
248261
<g
249262
v-if="svg.isPrintingSvg || svg.isPrintingImg"
250263
v-html="
@@ -261,15 +274,19 @@ const config = computed<VueUiHorizontalBarConfig>(() => {
261274
<span v-if="isOpen" class="i-lucide:x w-6 h-6" aria-hidden="true" />
262275
<span v-else class="i-lucide:ellipsis-vertical w-6 h-6" aria-hidden="true" />
263276
</template>
277+
264278
<template #optionCsv>
265279
<span class="text-fg-subtle font-mono pointer-events-none">CSV</span>
266280
</template>
281+
267282
<template #optionImg>
268283
<span class="text-fg-subtle font-mono pointer-events-none">PNG</span>
269284
</template>
285+
270286
<template #optionSvg>
271287
<span class="text-fg-subtle font-mono pointer-events-none">SVG</span>
272288
</template>
289+
273290
<template #optionAltCopy>
274291
<span
275292
class="w-6 h-6"
@@ -311,4 +328,4 @@ const config = computed<VueUiHorizontalBarConfig>(() => {
311328
margin: 0 auto;
312329
height: 2rem;
313330
}
314-
</style>
331+
</style>

0 commit comments

Comments
 (0)