Skip to content

Commit af2c3f6

Browse files
committed
Improvement - VueUiGizmo - Add formatters
1 parent 073ebfc commit af2c3f6

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

TestingArena/ArenaVueUiGizmo.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ const model= ref([
2121
const config = computed(() => {
2222
const c = convertArrayToObject(model.value);
2323
return {
24-
...c
24+
...c,
25+
formatter: ({value}) => {
26+
return `f | ${value}`
27+
}
2528
}
2629
})
2730

src/components/vue-ui-gizmo.vue

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup>
22
import { ref, computed, onMounted } from "vue";
33
import { useConfig } from "../useConfig";
4-
import { createUid, error, objectIsEmpty, shiftHue } from "../lib";
4+
import { createUid, error, applyDataLabel, dataLabel } from "../lib";
55
import { useNestedProp } from "../useNestedProp";
66
77
const { vue_ui_gizmo: DEFAULT_CONFIG } = useConfig();
@@ -109,7 +109,14 @@ const gaugeBody = computed(() => {
109109
font-size="20"
110110
:fill="FINAL_CONFIG.textColor"
111111
>
112-
{{ Math.round(props.dataset) }}%
112+
{{ applyDataLabel(
113+
FINAL_CONFIG.formatter,
114+
props.dataset,
115+
dataLabel({
116+
v: props.dataset,
117+
s: '%',
118+
})
119+
) }}
113120
</text>
114121
</template>
115122

@@ -161,7 +168,14 @@ const gaugeBody = computed(() => {
161168
font-size="20"
162169
:fill="FINAL_CONFIG.textColor"
163170
>
164-
{{ Math.round(props.dataset) }}%
171+
{{ applyDataLabel(
172+
FINAL_CONFIG.formatter,
173+
props.dataset,
174+
dataLabel({
175+
v: props.dataset,
176+
s: '%',
177+
})
178+
)}}
165179
</text>
166180
</template>
167181
</svg>

src/useConfig.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4556,7 +4556,8 @@ export function useConfig() {
45564556
gradientColor: '#9db5ed',
45574557
showPercentage: true,
45584558
textColor: COLOR_BLACK,
4559-
fontFamily: 'inherit'
4559+
fontFamily: 'inherit',
4560+
formatter: null
45604561
}
45614562

45624563
return {

types/vue-data-ui.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5290,6 +5290,7 @@ declare module 'vue-data-ui' {
52905290
showPercentage?: boolean;
52915291
textColor?: string;
52925292
fontFamily?: string;
5293+
formatter?: Formatter;
52935294
}
52945295

52955296
export type VueUiGizmoDataset = number;

0 commit comments

Comments
 (0)