Skip to content

Commit f974e8c

Browse files
committed
Improvement - VueUiSparkline - Add padding config attributes
1 parent e8f24ef commit f974e8c

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/components/vue-ui-sparkline.vue

+10-12
Original file line numberDiff line numberDiff line change
@@ -231,18 +231,16 @@ const svg = ref({
231231
232232
const emits = defineEmits(['hoverIndex', 'selectDatapoint'])
233233
234-
const bottomPadding = ref(6)
235-
236234
const drawingArea = computed(() => {
237-
const topPadding = 12;
235+
const { top: p_top, right: p_right, bottom: p_bottom, left: p_left } = FINAL_CONFIG.value.style.padding;
238236
return {
239-
top: topPadding,
240-
left: 0,
241-
right: svg.value.width,
242-
bottom: svg.value.height - 3,
243-
start: props.showInfo && FINAL_CONFIG.value.style.dataLabel.show && FINAL_CONFIG.value.style.dataLabel.position === 'left' ? svg.value.width - svg.value.chartWidth : svg.value.padding,
244-
width: props.showInfo && FINAL_CONFIG.value.style.dataLabel.show ? svg.value.chartWidth : svg.value.width - svg.value.padding,
245-
height: svg.value.height - topPadding
237+
top: p_top,
238+
left: p_left,
239+
right: svg.value.width - p_right,
240+
bottom: svg.value.height - p_bottom,
241+
start: props.showInfo && FINAL_CONFIG.value.style.dataLabel.show && FINAL_CONFIG.value.style.dataLabel.position === 'left' ? svg.value.width - svg.value.chartWidth + p_left : svg.value.padding + p_left,
242+
width: props.showInfo && FINAL_CONFIG.value.style.dataLabel.show ? svg.value.chartWidth - p_left - p_right : svg.value.width - svg.value.padding - p_left - p_right,
243+
height: svg.value.height - p_top - p_bottom
246244
}
247245
});
248246
@@ -268,7 +266,7 @@ const absoluteMin = computed(() => {
268266
});
269267
270268
const absoluteMax = computed(() => {
271-
return max.value + absoluteMin.value + bottomPadding.value;
269+
return max.value + absoluteMin.value;
272270
});
273271
274272
const absoluteZero = computed(() => {
@@ -397,7 +395,7 @@ function selectDatapoint(datapoint, index) {
397395
</div>
398396

399397
<!-- CHART -->
400-
<svg :xmlns="XMLNS" v-if="isDataset" data-cy="sparkline-svg" :viewBox="`0 0 ${svg.width} ${svg.height}`" :style="`background:${FINAL_CONFIG.style.backgroundColor};overflow:hidden`">
398+
<svg :xmlns="XMLNS" v-if="isDataset" data-cy="sparkline-svg" :viewBox="`0 0 ${svg.width} ${svg.height}`" :style="`background:${FINAL_CONFIG.style.backgroundColor};overflow:visible`">
401399
<PackageVersion />
402400

403401
<!-- BACKGROUND SLOT -->

0 commit comments

Comments
 (0)