1+ <script setup>
2+ import { ref , computed } from " vue" ;
3+ import LocalVueUiGauge from ' ../src/components/vue-ui-gauge.vue' ;
4+ import LocalVueDataUi from ' ../src/components/vue-data-ui.vue' ;
5+ import Box from " ./Box.vue" ;
6+ import convertArrayToObject from " ./convertModel" ;
7+
8+ const dataset = ref ({
9+ base: 100 ,
10+ value: 25 ,
11+ series: [
12+ { from: - 100 , to: 0 },
13+ { from: 0 , to: 100 }
14+ ]
15+ });
16+
17+ const model = ref ([
18+ { key: ' style.fontFamily' , def: ' inherit' , type: ' text' },
19+ { key: ' style.chart.backgroundColor' , def: ' #FFFFFF' , type: ' color' },
20+ { key: ' style.chart.color' , def: ' #1A1A1A' , type: ' color' },
21+ { key: ' style.chart.animation.use' , def: true , type: ' checkbox' },
22+ { key: ' style.chart.animation.speed' , def: 1 , type: ' range' , min: 0 , max: 100 },
23+ { key: ' style.chart.animation.acceleration' , def: 1 , type: ' range' , min: 0 , max: 10 },
24+ { key: ' style.chart.layout.useDiv' , def: false , type: ' checkbox' }, // DEPRECATED
25+ { key: ' style.chart.layout.track.size' , def: 1 , type: ' range' , min: 0.5 , max: 2 , step: 0.01 },
26+ { key: ' style.chart.layout.track.useGradient' , def: true , type: ' checkbox' },
27+ { key: ' style.chart.layout.track.gradientIntensity' , def: 20 , type: ' range' , min: 10 , max: 30 },
28+ { key: ' style.chart.layout.markers.size' , def: 1 , type: ' range' , min: 0.5 , max: 2 , step: 0.01 },
29+ { key: ' style.chart.layout.markers.color' , def: ' #1A1A1A' , type: ' color' },
30+ { key: ' style.chart.layout.markers.stroke' , def: ' #1A1A1A' , type: ' color' },
31+ { key: ' style.chart.layout.markers.strokeWidth' , def: 1 , type: ' range' , min: 0 , max: 12 , step: 0.1 },
32+ { key: ' style.chart.layout.markers.backgroundColor' , def: ' #FFFFFF' , type: ' color' },
33+ { key: ' style.chart.layout.markers.bold' , def: true , type: ' checkbox' },
34+ { key: ' style.chart.layout.markers.fontSizeRatio' , def: 1 , type: ' range' , min: 0 , max: 2 , step: 0.01 },
35+ { key: ' style.chart.layout.markers.offsetY' , def: 0 , type: ' number' , min: - 100 , max: 100 },
36+ { key: ' style.chart.layout.markers.roundingVale' , def: 0 , type: ' number' , min: 0 , max: 12 },
37+ { key: ' style.chart.layout.pointer.type' , def: ' rounded' , type: ' select' , options: [' rounded' , ' pointy' ]},
38+ { key: ' style.chart.layout.pointer.size' , def: 1 , type: ' range' , min: 0.2 , max: 1.5 , step: 0.01 },
39+ { key: ' style.chart.layout.pointer.stroke' , def: ' #1A1A1A' , type: ' color' },
40+ { key: ' style.chart.layout.pointer.strokeWidth' , def: 12 , type: ' range' , min: 1 , max: 48 , step: 0.5 },
41+ { key: ' style.chart.layout.pointer.useRatingColor' , def: true , type: ' checkbox' },
42+ { key: ' style.chart.layout.pointer.color' , def: ' #CCCCCC' , type: ' color' },
43+ { key: ' style.chart.layout.pointer.circle.radius' , def: 10 , type: ' range' , min: 0 , max: 48 , step: 0.5 },
44+ { key: ' style.chart.layout.pointer.circle.stroke' , def: ' #1A1A1A' , type: ' color' },
45+ { key: ' style.chart.layout.pointer.circle.strokeWidth' , def: 2 , type: ' range' , min: 0 , max: 12 , step: 0.5 },
46+ { key: ' style.chart.layout.pointer.circle.color' , def: ' #FFFFFF' , type: ' color' },
47+ { key: ' style.chart.legend.fontSize' , def: 48 , type: ' range' , min: 8 , max: 100 },
48+ { key: ' style.chart.legend.prefix' , def: ' $' , type: ' text' },
49+ { key: ' style.chart.legend.suffix' , def: ' €' , type: ' text' },
50+ { key: ' style.chart.legend.roundingValue' , def: 1 , type: ' number' , min: 0 , max: 12 },
51+ { key: ' style.chart.legend.showPlusSymbol' , def: true , type: ' checkbox' },
52+ { key: ' style.chart.legend.useRatingColor' , def: true , type: ' checkbox' },
53+ { key: ' style.chart.legend.color' , def: ' #1A1A1A' , type: ' color' },
54+ { key: ' style.chart.title.text' , def: ' Lorem ipsum dolor amet' , type: ' text' },
55+ { key: ' style.chart.title.color' , def: ' #1A1A1A' , type: ' color' },
56+ { key: ' style.chart.title.fontSize' , def: 20 , type: ' range' , min: 8 , max: 48 },
57+ { key: ' style.chart.title.bold' , def: true , type: ' checkbox' },
58+ { key: ' style.chart.title.subtitle.text' , def: ' Lorem ipsum dolor sic amet' , type: ' text' },
59+ { key: ' style.chart.title.subtitle.color' , def: ' #CCCCCC' , type: ' color' },
60+ { key: ' style.chart.title.subtitle.fontSize' , def: 16 , type: ' range' , min: 8 , max: 48 },
61+ { key: ' style.chart.title.subtitle.bold' , def: false , type: ' checkbox' },
62+ { key: ' userOptions.show' , def: true , type: ' checkbox' },
63+ { key: ' translations.base' , def: ' Base population' }
64+ ])
65+
66+ const config = computed (() => convertArrayToObject (model .value ))
67+
68+ const step = ref (0 );
69+
70+ </script >
71+
72+ <template >
73+ <Box >
74+ <template #title >VueUiGauge</template >
75+
76+ <template #local :key =" ` local_${step } ` " >
77+ <LocalVueUiGauge :dataset =" dataset" :config =" config" >
78+ <template #svg =" { svg } " >
79+ <circle :cx =" svg.width / 2" :cy =" svg.height / 2" :r =" 30" fill =" #42d392" />
80+ <text :x =" svg.width / 2" :y =" svg.height / 2" text-anchor =" middle" >#SVG</text >
81+ </template >
82+ <template #legend =" { legend } " >
83+ #LEGEND
84+ {{ legend }}
85+ </template >
86+ </LocalVueUiGauge >
87+ </template >
88+
89+ <template #VDUI-local >
90+ <LocalVueDataUi component =" VueUiGauge" :dataset =" dataset" :config =" config" :key =" `VDUI-lodal_${step}`" >
91+ <template #svg =" { svg } " >
92+ <circle :cx =" svg.width / 2" :cy =" svg.height / 2" :r =" 30" fill =" #42d392" />
93+ <text :x =" svg.width / 2" :y =" svg.height / 2" text-anchor =" middle" >#SVG</text >
94+ </template >
95+ <template #legend =" { legend } " >
96+ #LEGEND
97+ {{ legend }}
98+ </template >
99+ </LocalVueDataUi >
100+ </template >
101+
102+ <template #build >
103+ <VueUiGauge :dataset =" dataset" :config =" config" :key =" `build_${step}`" >
104+ <template #svg =" { svg } " >
105+ <circle :cx =" svg.width / 2" :cy =" svg.height / 2" :r =" 30" fill =" #42d392" />
106+ <text :x =" svg.width / 2" :y =" svg.height / 2" text-anchor =" middle" >#SVG</text >
107+ </template >
108+ <template #legend =" { legend } " >
109+ #LEGEND
110+ {{ legend }}
111+ </template >
112+ </VueUiGauge >
113+ </template >
114+
115+ <template #VDUI-build >
116+ <VueDataUi component =" VueUiGauge" :dataset =" dataset" :config =" config" :key =" `VDUI-build_${step}`" >
117+ <template #svg =" { svg } " >
118+ <circle :cx =" svg.width / 2" :cy =" svg.height / 2" :r =" 30" fill =" #42d392" />
119+ <text :x =" svg.width / 2" :y =" svg.height / 2" text-anchor =" middle" >#SVG</text >
120+ </template >
121+ <template #legend =" { legend } " >
122+ #LEGEND
123+ {{ legend }}
124+ </template >
125+ </VueDataUi >
126+ </template >
127+
128+ <template #knobs >
129+ <div
130+ style =" display : flex ; flex-direction : row ; flex-wrap :wrap ; align-items :center ; width : 100% ; color : #CCCCCC ; gap :24px ;" >
131+ <div v-for =" knob in model" >
132+ <label style =" font-size : 10px " >{{ knob.key }}</label >
133+ <div
134+ style =" display :flex ; flex-direction :row ; flex-wrap : wrap ; align-items :center ; gap :6px ; height : 40px " >
135+ <input v-if =" !['none', 'select'].includes(knob.type)" :step =" knob.step" :type =" knob.type" :min =" knob.min ?? 0"
136+ :max =" knob.max ?? 0" v-model =" knob.def" @change =" step += 1" >
137+ <select v-if =" knob.type === 'select'" v-model =" knob.def" @change =" step += 1" >
138+ <option v-for =" opt in knob.options" >{{ opt }}</option >
139+ </select >
140+ </div >
141+ </div >
142+ </div >
143+ </template >
144+
145+ <template #config >
146+ {{ config }}
147+ </template >
148+ </Box >
149+ </template >
0 commit comments