Skip to content

Commit 83d903d

Browse files
committed
Improvement - VueUiSparkline - Modifications for embedded use case
1 parent 8264e4a commit 83d903d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/components/vue-ui-sparkline.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ const props = defineProps({
4545
selectedIndex: {
4646
type: Number,
4747
default: undefined
48+
},
49+
heightRatio: {
50+
type: Number,
51+
default: 1
52+
},
53+
forcedPadding: {
54+
type: Number,
55+
default: 30
4856
}
4957
});
5058
@@ -185,7 +193,7 @@ function prepareChart() {
185193
svg.value.width = width;
186194
svg.value.height = height;
187195
svg.value.chartWidth = FINAL_CONFIG.value.style.chartWidth / 500 * width;
188-
svg.value.padding = 30 / 500 * width;
196+
svg.value.padding = props.forcedPadding / 500 * width;
189197
});
190198
191199
resizeObserver.value = new ResizeObserver(handleResize);
@@ -194,10 +202,10 @@ function prepareChart() {
194202
}
195203
196204
const svg = ref({
197-
height: 80,
205+
height: 80 * props.heightRatio,
198206
width: 500,
199207
chartWidth: FINAL_CONFIG.value.style.chartWidth,
200-
padding: 30
208+
padding: props.forcedPadding
201209
});
202210
203211
const emits = defineEmits(['hoverIndex', 'selectDatapoint'])
@@ -338,7 +346,7 @@ function selectDatapoint(datapoint, index) {
338346
</script>
339347

340348
<template>
341-
<div ref="sparklineChart" class="vue-ui-sparkline" :id="uid" :style="`width:100%;font-family:${FINAL_CONFIG.style.fontFamily}`">
349+
<div ref="sparklineChart" class="vue-ui-sparkline" :id="uid" :style="`width:100%;font-family:${FINAL_CONFIG.style.fontFamily};`">
342350
<!-- SLOT BEFORE -->
343351
<slot
344352
name="before"

0 commit comments

Comments
 (0)