1+ <script setup>
2+ import { ref , computed , onMounted } from " vue" ;
3+ import LocalVueUiBullet from ' ../src/components/vue-ui-bullet.vue' ;
4+ import LocalVueDataUi from ' ../src/components/vue-data-ui.vue' ;
5+ import Box from " ./Box.vue" ;
6+ import convertArrayToObject from " ./convertModel" ;
7+ import { useArena } from " ../src/useArena" ;
8+
9+ const { local , build , vduiLocal , vduiBuild } = useArena ()
10+
11+ const dataset = ref ({
12+ value: 85 ,
13+ target: 80 ,
14+ segments: [
15+ {
16+ name: ' Low' ,
17+ from: 0 ,
18+ to: 50 ,
19+ // color: '#4A4A4A'
20+ },
21+ {
22+ name: ' Medium' ,
23+ from: 50 ,
24+ to: 70 ,
25+ // color: '#6A6A6A'
26+ },
27+ {
28+ name: ' High' ,
29+ from: 70 ,
30+ to: 100 ,
31+ // color: '#8A8A8A'
32+ }
33+ ]
34+ })
35+
36+ function randomizeData (){
37+ dataset .value .value = Math .random () * 100
38+ }
39+
40+ const model = ref ([
41+ { key: ' userOptions.show' , def: true , type: ' checkbox' },
42+ { key: ' userOptions.buttons.pdf' , def: true , type: ' checkbox' },
43+ { key: ' userOptions.buttons.img' , def: true , type: ' checkbox' },
44+ { key: ' userOptions.buttons.fullscreen' , def: true , type: ' checkbox' },
45+ { key: ' userOptions.buttonTitles.pdf' , def: ' PDF' , type: ' text' },
46+ { key: ' userOptions.buttonTitles.img' , def: ' IMG' , type: ' text' },
47+ { key: ' userOptions.buttonTitles.fullscreen' , def: ' FSC' , type: ' text' },
48+
49+ { key: ' style.chart.backgroundColor' , def: ' #FFFFFF' , type: ' color' },
50+ { key: ' style.chart.color' , def: ' #1A1A1A' , type: ' color' },
51+ { key: ' style.chart.height' , def: 96 , type: ' range' , min: 64 , max: 120 },
52+ { key: ' style.chart.width' , def: 600 , type: ' range' , min: 400 , max: 1000 },
53+
54+ { key: ' style.chart.padding.top' , def: 24 , type: ' number' , min: 0 , max: 64 },
55+ { key: ' style.chart.padding.right' , def: 24 , type: ' number' , min: 0 , max: 64 },
56+ { key: ' style.chart.padding.bottom' , def: 24 , type: ' number' , min: 0 , max: 64 },
57+ { key: ' style.chart.padding.left' , def: 12 , type: ' number' , min: 0 , max: 64 },
58+
59+ { key: ' style.chart.animation.show' , def: true , type: ' checkbox' },
60+ { key: ' style.chart.animation.animationFrames' , def: 60 , type: ' range' , min: 30 , max: 255 },
61+
62+ { key: ' style.chart.segments.baseColor' , def: ' #9A9A9A' , type: ' color' },
63+ { key: ' style.chart.segments.dataLabels.show' , def: true , type: ' checkbox' },
64+ { key: ' style.chart.segments.dataLabels.color' , def: ' #1A1A1A' , type: ' color' },
65+ { key: ' style.chart.segments.dataLabels.fontSize' , def: 10 , type: ' number' , min: 8 , max: 42 },
66+ { key: ' style.chart.segments.dataLabels.bold' , def: false , type: ' checkbox' },
67+ { key: ' style.chart.segments.dataLabels.prefix' , def: ' ' , type: ' text' },
68+ { key: ' style.chart.segments.dataLabels.suffix' , def: ' ' , type: ' text' },
69+ { key: ' style.chart.segments.dataLabels.offsetY' , def: 0 , type: ' number' , min: - 50 , max: 50 },
70+ { key: ' style.chart.segments.ticks.show' , def: true , type: ' checkbox' },
71+ { key: ' style.chart.segments.ticks.divisions' , def: 10 , type: ' number' , min: 2 , max: 20 },
72+ { key: ' style.chart.segments.ticks.stroke' , def: ' #8A8A8A' , type: ' color' },
73+
74+ { key: ' style.chart.target.onTop' , def: true , type: ' checkbox' },
75+ { key: ' style.chart.target.color' , def: ' #1A1A1A' , type: ' color' },
76+ { key: ' style.chart.target.rounded' , def: true , type: ' checkbox' },
77+ { key: ' style.chart.target.heightRatio' , def: 0.8 , type: ' range' , min: 0.2 , max: 1 , step: 0.01 },
78+ { key: ' style.chart.target.stroke' , def: ' #FFFFFF' , type: ' color' },
79+ { key: ' style.chart.target.strokeWidth' , def: 1 , type: ' number' , min: 0 , max: 6 },
80+ { key: ' style.chart.target.width' , def: 6 , type: ' number' , min: 1 , max: 12 },
81+
82+ { key: ' style.chart.valueBar.color' , def: ' #3A3A3A' , type: ' color' },
83+ { key: ' style.chart.valueBar.heightRatio' , def: 0.33 , type: ' range' , min: 0.2 , max: 1 , step: 0.01 },
84+ { key: ' style.chart.valueBar.stroke' , def: ' #FFFFFF' , type: ' color' },
85+ { key: ' style.chart.valueBar.strokeWidth' , def: 1 , type: ' number' , min: 0 , max: 12 },
86+ { key: ' style.chart.valueBar.label.show' , def: true , type: ' checkbox' },
87+ { key: ' style.chart.valueBar.label.color' , def: ' #1A1A1A' , type: ' color' },
88+ { key: ' style.chart.valueBar.label.fontSize' , def: 14 , type: ' number' , min: 8 , max: 42 },
89+ { key: ' style.chart.valueBar.label.bold' , def: true , type: ' checkbox' },
90+ { key: ' style.chart.valueBar.label.offsetY' , def: 0 , type: ' number' , min: - 50 , max: 50 },
91+
92+ { key: ' style.chart.title.text' , def: ' This is a title' , type: ' text' },
93+ { key: ' style.chart.title.color' , def: ' #1A1A1A' , type: ' color' },
94+ { key: ' style.chart.title.fontSize' , def: 20 , type: ' number' , min: 8 , max: 42 },
95+ { key: ' style.chart.title.bold' , def: true , type: ' checkbox' },
96+ { key: ' style.chart.title.subtitle.text' , def: ' This is a subtitle' , type: ' text' },
97+ { key: ' style.chart.title.subtitle.color' , def: ' #8A8A8A' , type: ' color' },
98+ { key: ' style.chart.title.subtitle.fontSize' , def: 14 , type: ' number' , min: 8 , max: 42 },
99+ { key: ' style.chart.title.subtitle.bold' , def: false , type: ' checkbox' },
100+ ]);
101+
102+ const themeOptions = ref ([
103+ " " ,
104+ " hack" ,
105+ " zen" ,
106+ " concrete" ,
107+ " default"
108+ ])
109+
110+ const currentTheme = ref (themeOptions .value [4 ])
111+
112+ const config = computed (() => {
113+ const c = convertArrayToObject (model .value );
114+ return {
115+ ... c,
116+ theme: currentTheme .value ,
117+ }
118+ })
119+
120+ </script >
121+
122+ <template >
123+ <button @click =" randomizeData" >RANDOM DATA</button >
124+ <div style =" margin : 12px 0 ; color : white " >
125+ Theme:
126+ <select v-model =" currentTheme" >
127+ <option v-for =" opt in themeOptions" >{{ opt }}</option >
128+ </select >
129+ </div >
130+ <Box >
131+ <template #title >VueUiBullet</template >
132+
133+ <template #local >
134+ <LocalVueUiBullet :dataset =" dataset" :config =" config" ref =" local" />
135+ </template >
136+
137+ <template #VDUI-local >
138+ <LocalVueDataUi component =" VueUiBullet" :dataset =" dataset" :config =" config" ref =" localVdui" />
139+ </template >
140+
141+ <template #build >
142+ <VueUiBullet :dataset =" dataset" :config =" config" ref =" build" />
143+ </template >
144+
145+ <template #VDUI-build >
146+ <VueDataUi component =" VueUiBullet" :dataset =" dataset" :config =" config" ref =" buildVdui" />
147+ </template >
148+
149+ <template #knobs >
150+ <div
151+ style =" display : flex ; flex-direction : row ; flex-wrap :wrap ; align-items :center ; width : 100% ; color : #CCCCCC ; gap :24px ;" >
152+ <div v-for =" knob in model" >
153+ <label style =" font-size : 10px " >{{ knob.key }}</label >
154+ <div
155+ style =" display :flex ; flex-direction :row ; flex-wrap : wrap ; align-items :center ; gap :6px ; height : 40px " >
156+ <input v-if =" !['none', 'select'].includes(knob.type)" :step =" knob.step" :type =" knob.type" :min =" knob.min ?? 0"
157+ :max =" knob.max ?? 0" v-model =" knob.def" @change =" step += 1" >
158+ <select v-if =" knob.type === 'select'" v-model =" knob.def" @change =" step += 1" >
159+ <option v-for =" opt in knob.options" >{{ opt }}</option >
160+ </select >
161+ </div >
162+ </div >
163+ </div >
164+ </template >
165+
166+ <template #config >
167+ {{ config }}
168+ </template >
169+ </Box >
170+ </template >
0 commit comments