Skip to content

Commit

Permalink
docs: segmentValueFormatter story
Browse files Browse the repository at this point in the history
  • Loading branch information
palerdot committed Feb 29, 2024
1 parent 652a94b commit 05c0ae1
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions src/stories/Speedometer.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,44 @@ export const ConfiguringTheFormatForValuesDisplayed = () => ({
`,
})

function segmentValueFormatter(value) {
if (value < 200) {
return `${value} 😒`
}
if (value < 400) {
return `${value} 😐`
}
if (value < 600) {
return `${value} 😌`
}
if (value < 800) {
return `${value} 😊`
}
if (value < 900) {
return `${value} 😉`
}

return `${value} 😇`
}

// ref: https://github.com/vuejs/vue/issues/2436
export const CustomSegmentValueFormatter = () => ({
methods: {
segmentValueFormatter,
},

template: `
<div>
<vue-speedometer
:value="333"
needleColor="steelblue"
:segmentValueFormatter="segmentValueFormatter"
:paddingHorizontal="34"
/>
</div>
`,
})

export const CustomCurrentValueText = () => ({
template: `
<div>
Expand Down Expand Up @@ -323,8 +361,9 @@ export const ConfigureNeedleLengthAndFontSizes = () => ({
`,
})

export const GradientEffectWithLargeNumberOfSegmentsAndMaxSegmentLabelsConfig = () => ({
template: `
export const GradientEffectWithLargeNumberOfSegmentsAndMaxSegmentLabelsConfig =
() => ({
template: `
<div>
<vue-speedometer
:needleHeightRatio="0.7"
Expand All @@ -335,7 +374,7 @@ export const GradientEffectWithLargeNumberOfSegmentsAndMaxSegmentLabelsConfig =
/>
</div>
`,
})
})

export const NoSegmentLabels = () => ({
template: `
Expand Down

0 comments on commit 05c0ae1

Please sign in to comment.