Skip to content

Commit 0f833be

Browse files
authored
fix(VSparkline): accept numeric value for smooth (#20795)
fixes #19262
1 parent 39fe86d commit 0f833be

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

packages/vuetify/src/components/VSparkline/VBarline.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export const VBarline = genericComponent<VBarlineSlots>()({
123123

124124
const bars = computed(() => genBars(items.value, boundary.value))
125125
const offsetX = computed(() => (Math.abs(bars.value[0].x - bars.value[1].x) - lineWidth.value) / 2)
126+
const smooth = computed(() => typeof props.smooth === 'boolean' ? (props.smooth ? 2 : 0) : Number(props.smooth))
126127

127128
useRender(() => {
128129
const gradientData = !props.gradient.slice().length ? [''] : props.gradient.slice().reverse()
@@ -155,8 +156,8 @@ export const VBarline = genericComponent<VBarlineSlots>()({
155156
y={ item.y }
156157
width={ lineWidth.value }
157158
height={ item.height }
158-
rx={ typeof props.smooth === 'number' ? props.smooth : props.smooth ? 2 : 0 }
159-
ry={ typeof props.smooth === 'number' ? props.smooth : props.smooth ? 2 : 0 }
159+
rx={ smooth.value }
160+
ry={ smooth.value }
160161
>
161162
{ props.autoDraw && (
162163
<>

packages/vuetify/src/components/VSparkline/VTrendline.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,11 @@ export const VTrendline = genericComponent<VTrendlineSlots>()({
149149
}, { immediate: true })
150150

151151
function genPath (fill: boolean) {
152+
const smoothValue = typeof props.smooth === 'boolean' ? (props.smooth ? 8 : 0) : Number(props.smooth)
153+
152154
return _genPath(
153155
genPoints(items.value, boundary.value),
154-
props.smooth ? 8 : Number(props.smooth),
156+
smoothValue,
155157
fill,
156158
parseInt(props.height, 10)
157159
)

packages/vuetify/src/components/VSparkline/util/line.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { propsFactory } from '@/util'
44
// Types
55
import type { PropType } from 'vue'
66

7-
export type SparklineItem = number | { value: number }
7+
export type SparklineItem = string | number | { value: number }
88

99
export const makeLineProps = propsFactory({
1010
autoDraw: Boolean,
@@ -55,7 +55,7 @@ export const makeLineProps = propsFactory({
5555
default: 8,
5656
},
5757
showLabels: Boolean,
58-
smooth: Boolean,
58+
smooth: [Boolean, String, Number],
5959
width: {
6060
type: [Number, String],
6161
default: 300,

0 commit comments

Comments
 (0)