-
-
Notifications
You must be signed in to change notification settings - Fork 425
Expand file tree
/
Copy pathPatternSlot.vue
More file actions
32 lines (29 loc) · 951 Bytes
/
PatternSlot.vue
File metadata and controls
32 lines (29 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<script setup lang="ts">
/**
* This component is designed to create various patterns from seeds, and included
* inside vue-data-ui charts in the #pattern slots.
* Using patterns helps users with vision deficency (like achromatopsia) to distinguish
* series in the context of data visualisation.
*/
import { computed } from 'vue'
import { createSeededSvgPattern, type ChartPatternSlotProps } from '~/utils/charts'
const props = defineProps<ChartPatternSlotProps>()
const pattern = computed(() =>
createSeededSvgPattern(props.seed, {
foregroundColor: props.foregroundColor,
backgroundColor: props.color ?? props.fallbackColor,
minimumSize: props.minSize,
maximumSize: props.maxSize,
}),
)
</script>
<template>
<pattern
:id
patternUnits="userSpaceOnUse"
:width="pattern.width"
:height="pattern.height"
:patternTransform="`rotate(${pattern.rotation})`"
v-html="pattern.contentMarkup"
/>
</template>