1+ <script setup>
2+ import { ref , computed , onMounted } from " vue" ;
3+ import LocalVueUiDag from " ../src/components/vue-ui-dag.vue" ;
4+ import LocalVueDataUi from ' ../src/components/vue-data-ui.vue' ;
5+ import Box from " ./Box.vue" ;
6+ import convertArrayToObject from " ./convertModel" ;
7+ import ConfigKnobs from " ./ConfigKnobs.vue" ;
8+ import { useConfigurationControls } from " ./createConfigModel" ;
9+ import { useConfig } from " ../src/useConfig"
10+ import { useArena } from " ../src/useArena" ;
11+ import { VueUiDag } from " vue-data-ui" ;
12+ import {VueUiDag as VueUiDagTreeshaken } from " vue-data-ui/vue-ui-dag" ;
13+
14+ const { local , build , vduiLocal , vduiBuild } = useArena ();
15+ const { vue_ui_dag: DEFAULT_CONFIG } = useConfig ();
16+
17+ const {
18+ CHECKBOX ,
19+ NUMBER ,
20+ RANGE ,
21+ TEXT ,
22+ COLOR ,
23+ SELECT ,
24+ createModel
25+ } = useConfigurationControls (DEFAULT_CONFIG );
26+
27+ const dataset = ref ({
28+ nodes: [
29+ { id: " A" , label: " AAA\n aaa" , backgroundColor: ' #FF0000' , color: ' white' },
30+ { id: " B" , label: " BBB" ,},
31+ { id: " C" , label: " CCC" , color: ' #FF0000' },
32+ { id: " D" , label: " DDD" },
33+ ],
34+ edges: [
35+ { from: " A" , to: " B" , color: ' #FF0000' },
36+ { from: " B" , to: " A" },
37+ { from: " B" , to: " A" },
38+ { from: " C" , to: " A" },
39+ { from: " B" , to: " D" },
40+ { from: " C" , to: " D" },
41+ { from: " D" , to: " A" },
42+ ]
43+ });
44+
45+ // const dataset = ref(undefined);
46+
47+ // onMounted(() => {
48+ // setTimeout(() => {
49+ // dataset.value = {
50+ // nodes: [
51+ // { id: "A", label: "AAA", backgroundColor: '#FF0000', color: 'white'},
52+ // { id: "B", label: "BBB",},
53+ // { id: "C", label: "CCC", color: '#FF0000'},
54+ // { id: "D", label: "DDD" },
55+ // ],
56+ // edges: [
57+ // { from: "A", to: "B" },
58+ // { from: "B", to: "A" },
59+ // { from: "B", to: "A" },
60+ // { from: "C", to: "A" },
61+ // { from: "B", to: "D" },
62+ // { from: "C", to: "D" },
63+ // { from: "D", to: "A" },
64+ // ]
65+ // }
66+ // }, 2000)
67+ // })
68+
69+ const model = createModel ([
70+ CHECKBOX (' loading' , { def: false }),
71+ CHECKBOX (' debug' , { def: true }),
72+ CHECKBOX (' userOptions.buttons.pdf' , { def: true }),
73+ CHECKBOX (' userOptions.buttons.img' , { def: true }),
74+ CHECKBOX (' userOptions.buttons.svg' , { def: true }),
75+ CHECKBOX (' userOptions.buttons.fullscreen' , { def: true }),
76+ CHECKBOX (' userOptions.buttons.zoom' , { def: true }),
77+
78+ TEXT (' style.fontFamily' , { def: ' inherit' }),
79+
80+ COLOR (' style.chart.backgroundColor' , { def: ' #FFFFFF' }),
81+ COLOR (' style.chart.color' , { def: ' #1A1A1A' }),
82+
83+ SELECT (' style.chart.layout.rankDirection' , [' TB' , ' RL' , ' BT' , ' LR' ], { def: ' TB' }),
84+ SELECT (' style.chart.layout.rankSeparation' , [100 , 80 , 60 , 40 , 20 , 0 ], { def: 60 } ),
85+ SELECT (' style.chart.layout.nodeSeparation' , [100 , 75 , 50 , 25 , 0 ], { def: 50 }),
86+ SELECT (' style.chart.layout.edgeSeparation' , [60 , 50 , 40 , 30 , 20 , 10 , 0 ], { def: 30 }),
87+ RANGE (' style.chart.layout.nodeWidth' , {def: 100 , min: 40 , max: 200 }),
88+ RANGE (' style.chart.layout.nodeHeight' , {def: 40 , min: 20 , max: 200 }),
89+ CHECKBOX (' style.chart.layout.curvedEdges' , { def: true }),
90+ SELECT (' style.chart.layout.align' , [' UL' , ' UR' , ' DL' , ' DR' , ' ' ], { def: undefined }),
91+ SELECT (' style.chart.layout.arrowShape' , [' undirected' , ' normal' , ' vee' ], { def: ' vee' }),
92+
93+ COLOR (' style.chart.nodes.stroke' , { def: ' #E1E5E8' }),
94+ RANGE (' style.chart.nodes.strokeWidth' , { def: 1 , min: 0 , max: 12 }),
95+ RANGE (' style.chart.nodes.borderRadius' , { def: 3 , min: 0 , max: 24 }),
96+ COLOR (' style.chart.nodes.backgroundColor' , { def: ' #FFFFFF' }),
97+ COLOR (' style.chart.nodes.labels.color' , { def: ' #1A1A1A' }),
98+ RANGE (' style.chart.nodes.labels.fontSize' , { def: 12 , min: 8 , max: 42 }),
99+ CHECKBOX (' style.chart.nodes.labels.bold' , { def: false }),
100+ CHECKBOX (' style.chart.nodes.tooltip.showOnClick' , { def: true }),
101+ COLOR (' style.chart.nodes.tooltip.backgroundColor' , { def: ' #E1E5E8' }),
102+ COLOR (' style.chart.nodes.tooltip.color' , { def: ' #1A1A1A' }),
103+ TEXT (' style.chart.nodes.tooltip.maxWidth' , { def: ' 300px' }),
104+
105+ COLOR (' style.chart.edges.stroke' , { def: ' #CCCCCC' }),
106+ RANGE (' style.chart.edges.strokeWidth' , { def: 1 , min: 0.5 , max: 6 , step: 0.1 }),
107+
108+ CHECKBOX (' style.chart.midpoints.show' , { def: true }),
109+ RANGE (' style.chart.midpoints.radius' , { def: 4 , min: 2 , max: 8 , step: 0.5 }),
110+ COLOR (' style.chart.midpoints.stroke' , { def: ' #CCCCCC' }),
111+ COLOR (' style.chart.midpoints.fill' , { def: ' #FFFFFF' }),
112+ RANGE (' style.chart.midpoints.strokeWidth' , { def: 1 , min: 0.5 , max: 6 , step: 0.1 }),
113+ TEXT (' style.chart.midpoints.tooltip.maxWidth' , { def: ' 300px' }),
114+ COLOR (' style.chart.midpoints.tooltip.backgroundColor' , { def: ' #E1E5E8' }),
115+ COLOR (' style.chart.midpoints.tooltip.color' , { def: ' #1A1A1A' }),
116+
117+ CHECKBOX (' style.chart.controls.show' , { def: true }),
118+ SELECT (' style.chart.controls.position' , [' top' , ' bottom' ], { def: ' bottom' }),
119+ COLOR (' style.chart.controls.backgroundColor' , { def: ' #E1E5E8' }),
120+ COLOR (' style.chart.controls.buttonColor' , { def: ' #E1E5E8' }),
121+ COLOR (' style.chart.controls.color' , { def: ' #1A1A1A' }),
122+ NUMBER (' style.chart.controls.fontSize' , { def: 14 , min: 8 , max: 36 }),
123+ TEXT (' style.chart.controls.border' , { def: ' 1px solid #CCCCCC' }),
124+ TEXT (' style.chart.controls.padding' , { def: ' 0.5rem' }),
125+ TEXT (' style.chart.controls.borderRadius' , { def: ' 0.25rem' }),
126+
127+ CHECKBOX (' style.chart.zoom.active' , { def: true }),
128+
129+ TEXT (' style.chart.title.text' , { def: ' Title' }),
130+ COLOR (' style.chart.title.color' , { def: ' #1A1A1A' }),
131+ NUMBER (' style.chart.title.fontSize' , { def: 20 , min: 12 , max: 36 }),
132+ CHECKBOX (' style.chart.title.bold' , { def: true }),
133+ SELECT (' style.chart.title.textAlign' , [' left' , ' center' , ' right' ], { def: ' center' }),
134+ NUMBER (' style.chart.title.paddingLeft' , { def: 0 , min: - 100 , max: 100 }),
135+ NUMBER (' style.chart.title.paddingRight' , { def: 0 , min: - 100 , max: 100 }),
136+ COLOR (' style.chart.title.subtitle.color' , { def: ' #A1A1A1' }),
137+ TEXT (' style.chart.title.subtitle.text' , { def: ' Subtitle' }),
138+ NUMBER (' style.chart.title.subtitle.fontSize' , { def: 16 , min: 8 , max: 36 }),
139+ CHECKBOX (' style.chart.title.subtitle.bold' , { def: false })
140+ ]);
141+
142+ const config = computed (() => {
143+ const c = convertArrayToObject (model .value );
144+
145+ return {
146+ ... c,
147+ // loading: true
148+ }
149+ });
150+
151+ // onMounted(() => {
152+ // if (local.value) {
153+ // console.log(local.value.getData())
154+ // }
155+ // })
156+
157+ const themeOptions = ref ([
158+ " " ,
159+ " dark" ,
160+ " hack" ,
161+ " zen" ,
162+ " concrete" ,
163+ " default" ,
164+ " celebration" ,
165+ " celebrationNight"
166+ ])
167+
168+ const currentTheme = ref (themeOptions .value [4 ]);
169+
170+ const configTheme = computed (() => ({
171+ theme: currentTheme .value ,
172+ style: {
173+ chart: {
174+ nodes: {
175+ tooltip: { showOnClick: true }
176+ },
177+ midpoints: { show: true },
178+ title: {
179+ text: ' Title' ,
180+ subtitle: {
181+ text: ' Subtitle'
182+ }
183+ }
184+ }
185+ }
186+ }));
187+
188+ </script >
189+
190+ <template >
191+ <div style =" margin : 12px 0 ; color : white " >
192+ Theme:
193+ <select v-model =" currentTheme" @change =" step += 1" >
194+ <option v-for =" opt in themeOptions" >{{ opt }}</option >
195+ </select >
196+ </div >
197+
198+ <Box comp =" VueUiDag" :dataset =" dataset" :config =" config" >
199+ <template #title >VueUiDag</template >
200+
201+ <template #local >
202+ <LocalVueUiDag :dataset =" dataset" :config =" config" ref =" local" >
203+ <!-- <template #node-label="{ node }">
204+ {{ node.label }}
205+ </template>
206+ <template #node="{ node }">
207+ <div style="width: 100%; height: 100%; border: 1px solid red; color: black">
208+ {{ node.label }}
209+ </div>
210+ </template> -->
211+ <!-- <template #tooltip-midpoint="{ edge }">
212+ {{ edge }}
213+ </template>
214+ <template #tooltip-node="{ node }">
215+ {{ node }}
216+ </template> -->
217+ </LocalVueUiDag >
218+ </template >
219+
220+ <template #theme >
221+ <LocalVueUiDag :dataset =" dataset" :config =" configTheme" />
222+ </template >
223+
224+ <template #VDUI-local >
225+ <LocalVueDataUi component =" VueUiDag" :dataset =" dataset" :config =" config" />
226+ </template >
227+
228+ <template #build >
229+ <VueUiDag :dataset =" dataset" :config =" config" />
230+ </template >
231+
232+ <template #build-treesh >
233+ <VueUiDagTreeshaken :dataset =" dataset" :config =" config" />
234+ </template >
235+
236+ <template #VDUI-build >
237+ <VueDataUi component =" VueUiDag" :dataset =" dataset" :config =" config" />
238+ </template >
239+
240+ <template #knobs >
241+ <ConfigKnobs :model =" model" />
242+ </template >
243+ </Box >
244+ </template >
0 commit comments