1+ <script setup>
2+ import { ref , computed } from " vue" ;
3+ import LocalVueUiDonut from ' ../src/components/vue-ui-donut.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+ {
10+ name: ' Serie 1' ,
11+ values: [100 ]
12+ },
13+ {
14+ name: ' Serie 2' ,
15+ values: [50 ]
16+ },
17+ {
18+ name: ' Serie 3' ,
19+ values: [25 ]
20+ }
21+ ]);
22+
23+ const model = ref ([
24+ { key: ' useCssAnimation' , def: true , type: ' checkbox' , label: ' useCssAnimation' , category: ' general' },
25+ { key: ' useBlurOnHover' , def: true , type: ' checkbox' , label: " useBlurOnHover" , category: ' general' },
26+ { key: ' style.fontFamily' , def: ' inherit' , type: ' text' , label: " fontFamily" , category: ' general' },
27+ { key: ' style.chart.useGradient' , def: true , type: ' checkbox' , label: ' useGradient' , category: ' general' },
28+ { key: ' style.chart.gradientIntensity' , def: 40 , min: 0 , max: 100 , type: ' range' , label: ' gradientIntensity' , category: ' general' },
29+ { key: ' style.chart.backgroundColor' , def: ' #FFFFFF' , type: ' color' , label: ' backgroundColor' , category: ' general' },
30+ { key: ' style.chart.color' , def: ' #1A1A1A' , type: ' color' , label: ' textColor' , category: ' general' },
31+ { key: ' style.chart.layout.labels.dataLabels.show' , def: true , type: ' checkbox' , label: ' show' , category: ' labels' },
32+ { key: ' style.chart.layout.labels.dataLabels.hideUnderValue' , def: 3 , type: ' number' , min: 0 , max: 100 , label: ' hideUnderValue' , category: ' labels' },
33+ { key: ' style.chart.layout.labels.dataLabels.useLabelSlots' , def: false , type: ' checkbox' },
34+ { key: ' style.chart.layout.labels.dataLabels.prefix' , def: ' ' , type: ' text' , label: ' prefix' , category: ' labels' },
35+ { key: ' style.chart.layout.labels.dataLabels.suffix' , def: ' ' , type: ' text' , label: ' suffix' , category: ' labels' },
36+ { key: ' style.chart.layout.labels.value.show' , def: true , type: ' checkbox' , label: ' showValue' , category: ' labels' },
37+ { key: ' style.chart.layout.labels.value.rounding' , def: 0 , type: ' number' , min: 0 , max: 6 , label: ' valueRounding' , category: ' labels' },
38+ { key: ' style.chart.layout.labels.percentage.color' , def: ' #1A1A1A' , type: ' color' , label: ' colorPercentage' , category: ' labels' },
39+ { key: ' style.chart.layout.labels.percentage.bold' , def: true , type: ' checkbox' , label: ' bold' , category: ' labels' },
40+ { key: ' style.chart.layout.labels.percentage.fontSize' , def: 18 , min: 6 , max: 48 , type: ' number' , label: ' fontSize' , category: ' labels' },
41+ { key: ' style.chart.layout.labels.name.color' , def: ' #1A1A1A' , type: ' color' , label: ' colorName' , category: ' labels' },
42+ { key: ' style.chart.layout.labels.name.bold' , def: false , type: ' checkbox' , label: ' bold' , category: ' labels' },
43+ { key: ' style.chart.layout.labels.name.fontSize' , def: 14 , type: ' number' , min: 6 , max: 36 , label: ' fontSize' , category: ' labels' },
44+ { key: ' style.chart.layout.labels.hollow.show' , def: true , type: ' checkbox' , label: [' hollow' , ' is' , ' show' ], category: ' labels' },
45+ { key: ' style.chart.layout.labels.hollow.total.show' , def: true , type: ' checkbox' , label: [' hollow' , ' total' , ' is' , ' show' ], category: ' labels' },
46+ { key: ' style.chart.layout.labels.hollow.total.bold' , def: false , type: ' checkbox' , label: [' hollow' , ' total' , ' is' , ' bold' ], category: ' labels' },
47+ { key: ' style.chart.layout.labels.hollow.total.fontSize' , def: 18 , type: ' number' , min: 6 , max: 48 , label: [' hollow' , ' total' , ' is' , ' fontSize' ], category: ' labels' },
48+ { key: ' style.chart.layout.labels.hollow.total.color' , def: ' #AAAAAA' , type: ' color' , label: [' hollow' , ' total' , ' is' , ' color' ], category: ' labels' },
49+ { key: ' style.chart.layout.labels.hollow.total.text' , def: ' Total' , type: ' text' , label: [' hollow' , ' total' , ' is' , ' textContent' ], category: ' labels' },
50+ { key: ' style.chart.layout.labels.hollow.total.offsetY' , def: 0 , type: ' number' , min: - 100 , max: 100 , label: [' hollow' , ' total' , ' is' , ' offsetY' ], category: ' labels' },
51+ { key: ' style.chart.layout.labels.hollow.total.value.color' , def: ' #1A1A1A' , type: ' color' , label: [' hollow' , ' total' , ' value' , ' is' , ' color' ], category: ' labels' },
52+ { key: ' style.chart.layout.labels.hollow.total.value.fontSize' , def: 18 , type: ' number' , min: 6 , max: 48 , label: [' hollow' , ' total' , ' value' , ' is' , ' fontSize' ], category: ' labels' },
53+ { key: ' style.chart.layout.labels.hollow.total.value.bold' , def: true , type: ' checkbox' , label: [' hollow' , ' total' , ' value' , ' is' , ' bold' ], category: ' labels' },
54+ { key: ' style.chart.layout.labels.hollow.total.value.prefix' , def: ' ' , type: ' text' , label: [' hollow' , ' total' , ' value' , ' is' , ' prefix' ], category: ' labels' },
55+ { key: ' style.chart.layout.labels.hollow.total.value.suffix' , def: ' ' , type: ' text' , label: [' hollow' , ' total' , ' value' , ' is' , ' suffix' ], category: ' labels' },
56+ { key: ' style.chart.layout.labels.hollow.total.value.offsetY' , def: 0 , type: ' number' , min: - 100 , max: 100 , label: [' hollow' , ' total' , ' value' , ' is' , ' offsetY' ], category: ' labels' },
57+ { key: ' style.chart.layout.labels.hollow.total.value.rounding' , def: 0 , type: ' number' , min: 0 , max: 6 , label: [' hollow' , ' total' , ' value' , ' is' , ' rounding' ], category: ' labels' },
58+ { key: ' style.chart.layout.labels.hollow.average.show' , def: true , type: ' checkbox' , label: [' hollow' , ' average' , ' is' , ' show' ], category: ' labels' },
59+ { key: ' style.chart.layout.labels.hollow.average.bold' , def: false , type: ' checkbox' , label: [' hollow' , ' average' , ' is' , ' bold' ], category: ' labels' },
60+ { key: ' style.chart.layout.labels.hollow.average.color' , def: " #AAAAAA" , type: " color" , label: [' hollow' , ' average' , ' is' , ' color' ], category: ' labels' },
61+ { key: ' style.chart.layout.labels.hollow.average.fontSize' , def: 18 , type: ' number' , min: 6 , max: 48 , label: [' hollow' , ' average' , ' is' , ' fontSize' ], category: ' labels' },
62+ { key: ' style.chart.layout.labels.hollow.average.text' , def: ' Average' , type: ' text' , label: [' hollow' , ' average' , ' is' , ' textContent' ], category: ' labels' },
63+ { key: ' style.chart.layout.labels.hollow.average.offsetY' , def: 0 , type: ' number' , min: - 100 , max: 100 , label: [' hollow' , ' average' , ' is' , ' offsetY' ], category: ' labels' },
64+ { key: ' style.chart.layout.labels.hollow.average.value.color' , def: " #1A1A1A" , type: ' color' , label: [' hollow' , ' average' , ' value' , ' is' , ' color' ], category: ' labels' },
65+ { key: ' style.chart.layout.labels.hollow.average.value.fontSize' , def: 18 , type: ' number' , min: 6 , max: 48 , label: [' hollow' , ' average' , ' value' , ' is' , ' fontSize' ], category: ' labels' },
66+ { key: ' style.chart.layout.labels.hollow.average.value.bold' , def: true , type: ' checkbox' , label: [' hollow' , ' average' , ' value' , ' is' , ' bold' ], category: ' labels' },
67+ { key: ' style.chart.layout.labels.hollow.average.value.prefix' , def: ' ' , type: ' text' , label: [' hollow' , ' average' , ' value' , ' is' , ' prefix' ], category: ' labels' },
68+ { key: ' style.chart.layout.labels.hollow.average.value.suffix' , def: ' ' , type: ' text' , label: [' hollow' , ' average' , ' value' , ' is' , ' suffix' ], category: ' labels' },
69+ { key: ' style.chart.layout.labels.hollow.average.value.offsetY' , def: 0 , type: ' number' , min: - 100 , max: 100 , label: [' hollow' , ' average' , ' value' , ' is' , ' offsetY' ], category: ' labels' },
70+ { key: ' style.chart.layout.labels.hollow.average.value.rounding' , def: 0 , type: ' number' , min: 0 , max: 6 , label: [' hollow' , ' average' , ' value' , ' is' , ' rounding' ], category: ' labels' },
71+ { key: ' style.chart.layout.donut.strokeWidth' , def: 64 , type: ' range' , min: 3 , max: 130 , label: ' thickness' , category: ' donut' },
72+ { key: ' style.chart.layout.donut.borderWidth' , def: 1 , type: ' range' , min: 0 , max: 36 , label: [' border' , ' is' , ' thickness' ], category: ' donut' },
73+ { key: ' style.chart.legend.show' , def: true , type: ' checkbox' , label: ' show' , category: ' legend' },
74+ { key: ' style.chart.legend.backgroundColor' , def: ' #FFFFFF' , type: ' color' , label: ' backgroundColor' , category: ' legend' },
75+ { key: ' style.chart.legend.color' , def: ' #1A1A1A' , type: ' color' , label: ' textColor' , category: ' legend' },
76+ { key: ' style.chart.legend.fontSize' , def: 16 , type: ' number' , min: 6 , max: 42 , label: ' fontSize' , category: ' legend' },
77+ { key: ' style.chart.legend.bold' , def: false , type: ' checkbox' , label: ' bold' , category: ' legend' },
78+ { key: ' style.chart.legend.roundingValue' , def: 0 , type: ' number' , min: 0 , max: 6 , label: [' rounding' , ' is' , ' value' ], category: ' legend' },
79+ { key: ' style.chart.legend.roundingPercentage' , def: 0 , type: ' number' , min: 0 , max: 6 , label: ' percentageRounding' , category: ' legend' },
80+ { key: ' style.chart.title.text' , def: ' Title' , type: ' text' , label: ' textContent' , category: ' title' },
81+ { key: ' style.chart.title.color' , def: ' #1A1A1A' , type: ' color' , label: ' textColor' , category: ' title' },
82+ { key: ' style.chart.title.fontSize' , def: 20 , type: ' number' , min: 6 , max: 48 , label: ' fontSize' , category: ' title' },
83+ { key: ' style.chart.title.bold' , def: true , type: ' checkbox' , label: ' bold' , category: ' title' },
84+ { key: ' style.chart.title.subtitle.text' , def: ' ' , type: ' text' , label: ' textContent' , category: ' subtitle' },
85+ { key: ' style.chart.title.subtitle.color' , def: ' #A1A1A1' , type: ' color' , label: ' textColor' , category: ' subtitle' },
86+ { key: ' style.chart.title.subtitle.fontSize' , def: 16 , type: ' number' , min: 6 , max: 42 , label: ' fontSize' , category: ' subtitle' },
87+ { key: ' style.chart.title.subtitle.bold' , def: false , type: ' checkbox' , label: ' bold' , category: ' subtitle' },
88+ { key: ' userOptions.show' , def: true , type: ' checkbox' , label: ' showUserOptions' , category: ' general' },
89+ { key: ' table.show' , def: false , type: ' checkbox' , label: ' show' , category: ' table' },
90+ { key: ' table.responsiveBreakpoint' , def: 400 , type: ' number' , min: 300 , max: 800 , label: ' responsiveBreakpoint' , category: ' table' },
91+ { key: ' table.columnNames.series' , def: ' Series' , type: ' text' , label: [' columnName' , ' is' , ' series' ], category: ' table' },
92+ { key: ' table.columnNames.value' , def: ' Value' , type: ' text' , label: [' columnName' , ' is' , ' value' ], category: ' table' },
93+ { key: ' table.columnNames.percentage' , def: ' Percentage' , type: ' text' , label: [' columnName' , ' is' , ' percentage' ], category: ' table' },
94+ { key: ' table.th.backgroundColor' , def: ' #FFFFFF' , type: ' color' , label: ' backgroundColorHeader' , category: ' table' },
95+ { key: ' table.th.color' , def: ' #1A1A1A' , type: ' color' , label: ' textColorHeader' , category: ' table' },
96+ { key: ' table.th.outline' , def: ' none' , type: ' text' , label: ' outlineHeader' , category: ' table' },
97+ { key: ' table.td.backgroundColor' , def: ' #FFFFFF' , type: ' color' , label: ' backgroundColorRow' , category: ' table' },
98+ { key: ' table.td.color' , def: ' #1A1A1A' , type: ' color' , label: ' textColorRow' , category: ' table' },
99+ { key: ' table.td.outline' , def: ' none' , type: ' text' , label: ' outlineRow' , category: ' table' },
100+ { key: ' table.td.roundingValue' , def: 0 , type: ' number' , min: 0 , max: 6 , label: [' rounding' , ' is' , ' value' ], category: ' table' },
101+ { key: ' table.td.roundingPercentage' , def: 0 , type: ' number' , min: 0 , max: 6 , label: [' rounding' , ' is' , ' percentage' ], category: ' table' },
102+ { key: ' style.chart.tooltip.show' , def: true , type: ' checkbox' , label: ' show' , category: ' tooltip' },
103+ { key: ' style.chart.tooltip.backgroundColor' , def: ' #FFFFFF' , type: ' color' , label: ' backgroundColor' , category: ' tooltip' },
104+ { key: ' style.chart.tooltip.color' , def: ' #1A1A1A' , type: ' color' , label: ' textColor' , category: ' tooltip' },
105+ { key: ' style.chart.tooltip.fontSize' , def: 14 , type: ' number' , min: 6 , max: 24 , label: ' fontSize' , category: ' tooltip' },
106+ { key: ' style.chart.tooltip.showValue' , def: true , type: ' checkbox' , label: ' showValue' , category: ' tooltip' },
107+ { key: ' style.chart.tooltip.roundingValue' , def: 0 , type: ' number' , min: 0 , max: 6 , label: [' rounding' , ' is' , ' value' ], category: ' tooltip' },
108+ { key: ' style.chart.tooltip.showPercentage' , def: true , type: ' checkbox' , label: ' showPercentage' , category: ' tooltip' },
109+ { key: ' style.chart.tooltip.roundingPercentage' , def: 0 , type: ' number' , min: 0 , max: 6 , label: ' percentageRounding' , category: ' tooltip' },
110+ ])
111+
112+ const testCustomTooltip = ref (false );
113+
114+ const config = computed (() => {
115+ const c = convertArrayToObject (model .value );
116+ if (testCustomTooltip .value ) {
117+ return {
118+ ... c,
119+ style: {
120+ ... c .style ,
121+ chart: {
122+ ... c .style .chart ,
123+ tooltip: {
124+ ... c .style .chart .tooltip ,
125+ customFormat : (data ) => {
126+ console .log (' XY CUSTOM TOOLTIP' , data);
127+ return " CUSTOM TOOLTIP"
128+ }
129+ }
130+ }
131+ },
132+ }
133+ } else {
134+ return c
135+ }
136+ });
137+
138+ const step = ref (0 )
139+
140+ function selectLegend (leg ) {
141+ alert (` @selectLegend\n\n ${ JSON .stringify (leg)} ` )
142+ }
143+
144+ </script >
145+
146+ <template >
147+ <div style =" margin : 12px 0 " >
148+ <input type =" checkbox" v-model =" testCustomTooltip" id =" custom-tooltip" />
149+ <label for =" custom-tooltip" style =" color :#CCCCCC " >Test custom tooltip</label >
150+ </div >
151+ <Box >
152+ <template #title >VueUiDonut</template >
153+
154+ <template #local >
155+ <LocalVueUiDonut :dataset =" dataset" :config =" config" :key =" `local_${step}`" >
156+ <template #svg =" { svg } " >
157+ <circle :cx =" 30" :cy =" 30" :r =" 30" fill =" #42d392" />
158+ <text :x =" 30" :y =" 30" text-anchor =" middle" >#SVG</text >
159+ </template >
160+ <template #dataLabel =" { datapoint , isBlur , isVisible , isSafari , textAlign , flexAlign , percentage } " >
161+ <div :style =" `background:${datapoint.color}`" >
162+ {{ datapoint.name }} : {{ percentage }}
163+ </div >
164+ </template >
165+ <template #legend =" { legend } " >
166+ #LEGEND
167+ <div style =" font-size : 8px " >
168+ {{ legend }}
169+ </div >
170+ </template >
171+ <template #tooltip-before =" { datapoint , seriesIndex , series , config , bars , lines , plots } " >
172+ #BEFORE {{ series.name }}
173+ </template >
174+ <template #tooltip-after =" { datapoint , seriesIndex , series , config , bars , lines , plots } " >
175+ #AFTER {{ series.name }}
176+ </template >
177+ </LocalVueUiDonut >
178+ </template >
179+
180+ <template #VDUI-local >
181+ <LocalVueDataUi component =" VueUiDonut" :dataset =" dataset" :config =" config" :key =" `local_${step}`" >
182+ <template #svg =" { svg } " >
183+ <circle :cx =" 30" :cy =" 30" :r =" 30" fill =" #42d392" />
184+ <text :x =" 30" :y =" 30" text-anchor =" middle" >#SVG</text >
185+ </template >
186+ <template #dataLabel =" { datapoint , isBlur , isVisible , isSafari , textAlign , flexAlign , percentage } " >
187+ <div :style =" `background:${datapoint.color}`" >
188+ {{ datapoint.name }} : {{ percentage }}
189+ </div >
190+ </template >
191+ <template #legend =" { legend } " >
192+ #LEGEND
193+ <div style =" font-size : 8px " >
194+ {{ legend }}
195+ </div >
196+ </template >
197+ <template #tooltip-before =" { datapoint , seriesIndex , series , config , bars , lines , plots } " >
198+ #BEFORE {{ series.name }}
199+ </template >
200+ <template #tooltip-after =" { datapoint , seriesIndex , series , config , bars , lines , plots } " >
201+ #AFTER {{ series.name }}
202+ </template >
203+ </LocalVueDataUi >
204+ </template >
205+
206+ <template #build >
207+ <VueUiDonut :dataset =" dataset" :config =" config" :key =" `local_${step}`" >
208+ <template #svg =" { svg } " >
209+ <circle :cx =" 30" :cy =" 30" :r =" 30" fill =" #42d392" />
210+ <text :x =" 30" :y =" 30" text-anchor =" middle" >#SVG</text >
211+ </template >
212+ <template #dataLabel =" { datapoint , isBlur , isVisible , isSafari , textAlign , flexAlign , percentage } " >
213+ <div :style =" `background:${datapoint.color}`" >
214+ {{ datapoint.name }} : {{ percentage }}
215+ </div >
216+ </template >
217+ <template #legend =" { legend } " >
218+ #LEGEND
219+ <div style =" font-size : 8px " >
220+ {{ legend }}
221+ </div >
222+ </template >
223+ <template #tooltip-before =" { datapoint , seriesIndex , series , config , bars , lines , plots } " >
224+ #BEFORE {{ series.name }}
225+ </template >
226+ <template #tooltip-after =" { datapoint , seriesIndex , series , config , bars , lines , plots } " >
227+ #AFTER {{ series.name }}
228+ </template >
229+ </VueUiDonut >
230+ </template >
231+
232+ <template #VDUI-build >
233+ <VueDataUi component =" VueUiDonut" :dataset =" dataset" :config =" config" :key =" `local_${step}`" >
234+ <template #svg =" { svg } " >
235+ <circle :cx =" 30" :cy =" 30" :r =" 30" fill =" #42d392" />
236+ <text :x =" 30" :y =" 30" text-anchor =" middle" >#SVG</text >
237+ </template >
238+ <template #dataLabel =" { datapoint , isBlur , isVisible , isSafari , textAlign , flexAlign , percentage } " >
239+ <div :style =" `background:${datapoint.color}`" >
240+ {{ datapoint.name }} : {{ percentage }}
241+ </div >
242+ </template >
243+ <template #legend =" { legend } " >
244+ #LEGEND
245+ <div style =" font-size : 8px " >
246+ {{ legend }}
247+ </div >
248+ </template >
249+ <template #tooltip-before =" { datapoint , seriesIndex , series , config , bars , lines , plots } " >
250+ #BEFORE {{ series.name }}
251+ </template >
252+ <template #tooltip-after =" { datapoint , seriesIndex , series , config , bars , lines , plots } " >
253+ #AFTER {{ series.name }}
254+ </template >
255+ </VueDataUi >
256+ </template >
257+
258+ <template #knobs >
259+ <div style =" display : flex ; flex-direction : row ; flex-wrap :wrap ; align-items :center ; width : 100% ; color : #CCCCCC ; gap :24px ;" >
260+ <div v-for =" knob in model" >
261+ <label style =" font-size : 10px " >{{ knob.key }}</label >
262+ <div style =" display :flex ; flex-direction :row ; flex-wrap : wrap ; align-items :center ; gap :6px ; height : 40px " >
263+ <input v-if =" !['none', 'select'].includes(knob.type)" :type =" knob.type" :min =" knob.min ?? 0" :max =" knob.max ?? 0" v-model =" knob.def" @change =" step += 1" >
264+ <select v-if =" knob.type === 'select'" v-model =" knob.def" @change =" step += 1" >
265+ <option v-for =" opt in knob.options" >{{ opt }}</option >
266+ </select >
267+ </div >
268+ </div >
269+ </div >
270+ </template >
271+
272+ <template #config >
273+ {{ config }}
274+ </template >
275+ </Box >
276+ </template >
0 commit comments