Skip to content

Commit

Permalink
fix(VSparkline): accept numeric value for smooth (#20795)
Browse files Browse the repository at this point in the history
fixes #19262
  • Loading branch information
J-Sek authored Jan 16, 2025
1 parent 39fe86d commit 0f833be
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions packages/vuetify/src/components/VSparkline/VBarline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export const VBarline = genericComponent<VBarlineSlots>()({

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

useRender(() => {
const gradientData = !props.gradient.slice().length ? [''] : props.gradient.slice().reverse()
Expand Down Expand Up @@ -155,8 +156,8 @@ export const VBarline = genericComponent<VBarlineSlots>()({
y={ item.y }
width={ lineWidth.value }
height={ item.height }
rx={ typeof props.smooth === 'number' ? props.smooth : props.smooth ? 2 : 0 }
ry={ typeof props.smooth === 'number' ? props.smooth : props.smooth ? 2 : 0 }
rx={ smooth.value }
ry={ smooth.value }
>
{ props.autoDraw && (
<>
Expand Down
4 changes: 3 additions & 1 deletion packages/vuetify/src/components/VSparkline/VTrendline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ export const VTrendline = genericComponent<VTrendlineSlots>()({
}, { immediate: true })

function genPath (fill: boolean) {
const smoothValue = typeof props.smooth === 'boolean' ? (props.smooth ? 8 : 0) : Number(props.smooth)

return _genPath(
genPoints(items.value, boundary.value),
props.smooth ? 8 : Number(props.smooth),
smoothValue,
fill,
parseInt(props.height, 10)
)
Expand Down
4 changes: 2 additions & 2 deletions packages/vuetify/src/components/VSparkline/util/line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { propsFactory } from '@/util'
// Types
import type { PropType } from 'vue'

export type SparklineItem = number | { value: number }
export type SparklineItem = string | number | { value: number }

export const makeLineProps = propsFactory({
autoDraw: Boolean,
Expand Down Expand Up @@ -55,7 +55,7 @@ export const makeLineProps = propsFactory({
default: 8,
},
showLabels: Boolean,
smooth: Boolean,
smooth: [Boolean, String, Number],
width: {
type: [Number, String],
default: 300,
Expand Down

0 comments on commit 0f833be

Please # to comment.