1+ <script setup>
2+ import { ref , computed } from " vue" ;
3+ import LocalVueUiTreemap from ' ../src/components/vue-ui-treemap.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: ' S1' ,
11+ value: 100 ,
12+ children: [
13+ {
14+ name: ' S1 - C1' ,
15+ value: 50
16+ },
17+ {
18+ name: ' S1 -C2' ,
19+ value: 25
20+ },
21+ {
22+ name: ' S1 - C3' ,
23+ value: 12.5 ,
24+ children: [
25+ {
26+ name: ' S1 - C3 - CC1' ,
27+ value: 6
28+ },
29+ {
30+ name: ' S1 - C3 - CC2' ,
31+ value: 6.5
32+ },
33+ ]
34+ }
35+ ]
36+ },
37+ {
38+ name: ' S2' ,
39+ value: 200 ,
40+ children: [
41+ {
42+ name: ' S2 - C1' ,
43+ value: 100
44+ },
45+ {
46+ name: ' S2 - C2' ,
47+ value: 50
48+ },
49+ {
50+ name: ' S2 - C3' ,
51+ value: 25
52+ }
53+ ]
54+ },
55+ {
56+ name: ' S3' ,
57+ value: 100 ,
58+ children: [
59+ {
60+ name: ' S3 - C1' ,
61+ value: 50
62+ },
63+ {
64+ name: ' S3 - C2' ,
65+ value: 25
66+ },
67+ {
68+ name: ' S3 - C3' ,
69+ value: 12.5
70+ }
71+ ]
72+ },
73+ {
74+ name: ' S4' ,
75+ value: 20 ,
76+ children: [
77+ {
78+ name: ' S3 - C1' ,
79+ value: 10
80+ },
81+ {
82+ name: ' S3 - C2' ,
83+ value: 5
84+ },
85+ {
86+ name: ' S3 - C3' ,
87+ value: 2.5
88+ }
89+ ]
90+ },
91+ {
92+ name: ' S5' ,
93+ value: 10 ,
94+ children: [
95+ {
96+ name: ' S3 - C1' ,
97+ value: 5
98+ },
99+ {
100+ name: ' S3 - C2' ,
101+ value: 2.5
102+ },
103+ {
104+ name: ' S3 - C3' ,
105+ value: 1.125
106+ }
107+ ]
108+ },
109+ ]);
110+
111+ const model = ref ([
112+ { key: ' userOptions.show' , def: true , type: ' checkbox' },
113+ { key: ' style.fontFamily' , def: ' inherit' , type: ' text' },
114+ { key: ' style.chart.backgroundColor' , def: ' #FFFFFF' , type: ' color' },
115+ { key: ' style.chart.color' , def: ' #1A1A1A' , type: ' color' },
116+ { key: ' style.chart.height' , def: 500 , type: ' number' , min: 100 , max: 1000 },
117+ { key: ' style.chart.width' , def: 800 , type: ' number' , min: 100 , max: 1500 },
118+ { key: ' style.chart.padding.top' , def: 0 , type: ' number' , min: 0 , max: 100 },
119+ { key: ' style.chart.padding.right' , def: 0 , type: ' number' , min: 0 , max: 100 },
120+ { key: ' style.chart.padding.bottom' , def: 0 , type: ' number' , min: 0 , max: 100 },
121+ { key: ' style.chart.padding.left' , def: 0 , type: ' number' , min: 0 , max: 100 },
122+ { key: ' style.chart.layout.sorted' , def: true , type: ' checkbox' },
123+ { key: ' style.chart.layout.rects.stroke' , def: ' #FFFFFF' , type: ' color' },
124+ { key: ' style.chart.layout.rects.strokeWidth' , def: 1 , type: ' number' , min: 0 , max: 12 },
125+ { key: ' style.chart.layout.rects.borderRadius' , def: 0 , type: ' number' , min: 0 , max: 24 },
126+ { key: ' style.chart.layout.rects.colorRatio' , def: 0.3 , type: ' number' , min: 0 , max: 1 , step: 0.01 },
127+ { key: ' style.chart.layout.rects.gradient.show' , def: true , type: ' checkbox' },
128+ { key: ' style.chart.layout.rects.gradient.intensity' , def: 30 , type: ' range' , min: 0 , max: 100 },
129+ { key: ' style.chart.layout.rects.selected.stroke' , def: ' #FFFFFF' , type: ' color' },
130+ { key: ' style.chart.layout.rects.selected.strokeWidth' , def: 1 , type: ' number' , min: 0 , max: 12 },
131+ { key: ' style.chart.layout.rects.selected.unselectedOpacity' , def: 0.6 , type: ' range' , min: 0 , max: 1 , step: 0.01 },
132+ { key: ' style.chart.layout.labels.showDefaultLabels' , def: true , type: ' checkbox' },
133+ { key: ' style.chart.layout.labels.fontSize' , def: 14 , type: ' range' , min: 8 , max: 48 , step: 1 },
134+ { key: ' style.chart.layout.labels.minFontSize' , def: 10 , type: ' range' , min: 6 , max: 48 , step: 1 },
135+ { key: ' style.chart.layout.labels.hideUnderProportion' , def: 0.03 , type: ' number' , min: 0 , max: 1 , step: 0.01 },
136+ { key: ' style.chart.layout.labels.prefix' , def: ' Value: ' , type: ' text' },
137+ { key: ' style.chart.layout.labels.suffix' , def: ' €' , type: ' text' },
138+ { key: ' style.chart.layout.labels.rounding' , def: 1 , type: ' number' , min: 0 , max: 12 },
139+ { key: ' style.chart.legend.backgroundColor' , def: ' #FFFFFF' , type: ' color' },
140+ { key: ' style.chart.legend.color' , def: ' #1A1A1A' , type: ' color' },
141+ { key: ' style.chart.legend.show' , def: true , type: ' checkbox' },
142+ { key: ' style.chart.legend.fontSize' , def: 14 , type: ' number' , min: 8 , max: 48 },
143+ { key: ' style.chart.legend.bold' , def: false , type: ' checkbox' },
144+ { key: ' style.chart.legend.roundingValue' , def: 1 , type: ' number' , min: 0 , max: 12 },
145+ { key: ' style.chart.legend.roundingPercentage' , def: 1 , type: ' number' , min: 0 , max: 12 },
146+ { key: ' style.chart.title.text' , def: " Lorem ipsum dolor sic amet" , type: " text" },
147+ { key: ' style.chart.title.color' , def: ' #1A1A1A' , type: ' color' },
148+ { key: ' style.chart.title.fontSize' , def: 20 , type: ' number' , min: 8 , max: 48 },
149+ { key: ' style.chart.title.bold' , def: true , type: ' checkbox' },
150+ { key: ' style.chart.title.subtitle.text' , def: ' Lorem ipsum dolor sic amet titulum subtitulum' },
151+ { key: ' style.chart.title.subtitle.color' , def: ' #CCCCCC' , type: ' color' },
152+ { key: ' style.chart.title.subtitle.fontSize' , def: 16 , type: ' number' , min: 8 , max: 48 },
153+ { key: ' style.chart.title.subtitle.bold' , def: false , type: ' checkbox' },
154+ { key: ' style.chart.tooltip.show' , def: true , type: ' checkbox' },
155+ { key: ' style.chart.tooltip.color' , def: ' #1A1A1A' , type: ' color' },
156+ { key: ' style.chart.tooltip.backgroundColor' , def: ' #FFFFFF' , type: ' color' },
157+ { key: ' style.chart.tooltip.fontSize' , def: 14 , type: ' number' , min: 8 , max: 48 },
158+ { key: ' style.chart.tooltip.roundingValue' , def: 1 , type: ' number' , min: 0 , max: 12 },
159+ { key: ' table.show' , def: false , type: ' checkbox' },
160+ { key: ' table.responsiveBreakpoint' , def: 300 , type: ' number' , min: 300 , max: 800 },
161+ { key: ' table.columnNames.series' , def: ' Series' , type: ' text' },
162+ { key: ' table.columnNames.value' , def: ' Value' , type: ' text' },
163+ { key: ' table.columnNames.percentage' , def: ' Percentage' , type: ' text' },
164+ { key: ' table.th.backgroundColor' , def: ' #FFFFFF' , type: ' color' },
165+ { key: ' table.th.color' , def: ' #1A1A1A' , type: ' color' },
166+ { key: ' table.th.outline' , def: ' none' },
167+ { key: ' table.td.backgroundColor' , def: ' #FFFFFF' , type: ' color' },
168+ { key: ' table.td.color' , def: ' #1A1A1A' , type: ' color' },
169+ { key: ' table.td.roundingValue' , def: 2 , type: ' number' , min: 0 , max: 12 },
170+ { key: ' table.td.roundingPercentage' , def: 2 , type: ' number' , min: 0 , max: 12 },
171+ ]);
172+
173+ const testCustomTooltip = ref (false );
174+
175+ const config = computed (() => {
176+ const c = convertArrayToObject (model .value );
177+ if (testCustomTooltip .value ) {
178+ return {
179+ ... c,
180+ style: {
181+ ... c .style ,
182+ chart: {
183+ ... c .style .chart ,
184+ tooltip: {
185+ ... c .style .chart .tooltip ,
186+ customFormat : ({ datapoint }) => {
187+ let html = ' ' ;
188+ console .log (datapoint);
189+ return " test"
190+ }
191+ }
192+ }
193+ }
194+
195+ }
196+ } else {
197+ return {
198+ ... c
199+ }
200+ }
201+ });
202+
203+ const step = ref (0 )
204+
205+ function selectLegend (leg ) {
206+ alert (` @selectLegend\n\n ${ JSON .stringify (leg)} ` )
207+ }
208+
209+ function selectDatapoint (d ) {
210+ alert (` @selectDatapoint\n\n ${ JSON .stringify (d)} ` )
211+ }
212+
213+ </script >
214+
215+ <template >
216+ <div style =" margin : 12px 0 " >
217+ <input type =" checkbox" v-model =" testCustomTooltip" id =" custom-tooltip" />
218+ <label for =" custom-tooltip" style =" color :#CCCCCC " >Test custom tooltip</label >
219+ </div >
220+ <Box >
221+ <template #title >VueUiTreemap</template >
222+
223+ <template #local >
224+ <LocalVueUiTreemap :dataset =" dataset" :config =" config" :key =" `local_${step}`" @selectDatapoint =" selectDatapoint" @selectLegend =" selectLegend" >
225+ </LocalVueUiTreemap >
226+ </template >
227+
228+ <template #VDUI-local >
229+ <LocalVueDataUi component =" VueUiTreemap" :dataset =" dataset" :config =" config" :key =" `VDUI-lodal_${step}`" @selectDatapoint =" selectDatapoint" @selectLegend =" selectLegend" >
230+ </LocalVueDataUi >
231+ </template >
232+
233+ <template #build >
234+ <VueUiTreemap :dataset =" dataset" :config =" config" :key =" `build_${step}`" @selectDatapoint =" selectDatapoint" @selectLegend =" selectLegend" >
235+ </VueUiTreemap >
236+ </template >
237+
238+ <template #VDUI-build >
239+ <VueDataUi component =" VueUiTreemap" :dataset =" dataset" :config =" config" :key =" `VDUI-build_${step}`" @selectDatapoint =" selectDatapoint" @selectLegend =" selectLegend" >
240+ </VueDataUi >
241+ </template >
242+
243+ <template #knobs >
244+ <div
245+ style =" display : flex ; flex-direction : row ; flex-wrap :wrap ; align-items :center ; width : 100% ; color : #CCCCCC ; gap :24px ;" >
246+ <div v-for =" knob in model" >
247+ <label style =" font-size : 10px " >{{ knob.key }}</label >
248+ <div
249+ style =" display :flex ; flex-direction :row ; flex-wrap : wrap ; align-items :center ; gap :6px ; height : 40px " >
250+ <input v-if =" !['none', 'select'].includes(knob.type)" :step =" knob.step" :type =" knob.type" :min =" knob.min ?? 0"
251+ :max =" knob.max ?? 0" v-model =" knob.def" @change =" step += 1" >
252+ <select v-if =" knob.type === 'select'" v-model =" knob.def" @change =" step += 1" >
253+ <option v-for =" opt in knob.options" >{{ opt }}</option >
254+ </select >
255+ </div >
256+ </div >
257+ </div >
258+ </template >
259+
260+ <template #config >
261+ {{ config }}
262+ </template >
263+ </Box >
264+ </template >
0 commit comments