Skip to content

Commit 4a4b068

Browse files
committed
Dev environment - Added VueUiAgePyramid testing arena
1 parent 3461366 commit 4a4b068

File tree

2 files changed

+237
-2
lines changed

2 files changed

+237
-2
lines changed
Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
<script setup>
2+
import { ref, computed } from "vue";
3+
import LocalVueUiAgePyramid from '../src/components/vue-ui-age-pyramid.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+
['2017', 5, 366538, 382762],
10+
['2018', 4, 356873, 376705],
11+
['2019', 3, 351707, 368670],
12+
['2020', 2, 341042, 356678],
13+
['2021', 1, 343026, 357351],
14+
['2022', 0, 330929, 345538]
15+
]);
16+
17+
const model = ref([
18+
{ key: 'style.backgroundColor', def: '#FFFFFF', type: 'color'},
19+
{ key: 'style.color', def: '#1A1A1A', type: 'color'},
20+
{ key: 'style.fontFamily', def: 'inherit', type: 'text'},
21+
{ key: 'style.height', def: 200, type: 'number', min: 200, max: 1000},
22+
{ key: 'style.width', def: 500, type: 'number', min: 200, max: 1000},
23+
{ key: 'style.layout.useDiv', def: true, type: 'checkbox'}, // DEPRECATED
24+
{ key: 'style.layout.padding.top', def: 36, type: 'number', min: 0, max: 100},
25+
{ key: 'style.layout.padding.right', def: 24, type: 'number', min: 0, max: 100},
26+
{ key: 'style.layout.padding.bottom', def: 48, type: 'number', min: 0, max: 100},
27+
{ key: 'style.layout.padding.left', def: 24, type: 'number', min: 0, max: 100},
28+
{ key: 'style.layout.grid.show', def: true, type: 'checkbox'},
29+
{ key: 'style.layout.grid.stroke', def: '#e1e5e8', type: 'color'},
30+
{ key: 'style.layout.grid.strokeWidth', def: 1, type: 'number', min: 0, max: 12},
31+
{ key: 'style.layout.dataLabels.sideTitles.show', def: true, type: 'checckbox'},
32+
{ key: 'style.layout.dataLabels.sideTitles.fontSize', def: 18, type: 'number', min: 8, max: 48},
33+
{ key: 'style.layout.dataLabels.sideTitles.color', def: '#1A1A1A', type: 'color'},
34+
{ key: 'style.layout.dataLabels.sideTitles.useSideColor', def: true, type: 'checkbox'},
35+
{ key: 'style.layout.dataLabels.sideTitles.bold', def: true, type: 'checkbox'},
36+
{ key: 'style.layout.dataLabels.sideTitles.offsetY', def: 0, type: 'number', min: -100, max: 100},
37+
{ key: 'style.layout.dataLabels.xAxis.show', def: true, type:'checkbox'},
38+
{ key: 'style.layout.dataLabels.xAxis.fontSize', def: 12, type: 'number', min: 8, max: 48},
39+
{ key: 'style.layout.dataLabels.xAxis.color', def: '#1A1A1A', type: 'color'},
40+
{ key: 'style.layout.dataLabels.xAxis.bold', def: false, type: 'checkbox'},
41+
{ key: 'style.layout.dataLabels.xAxis.scale', def: 1000, type: 'range', min: 100, max: 10000},
42+
{ key: 'style.layout.dataLabels.xAxis.translation', def: 'in thousands', type: 'text'},
43+
{ key: 'style.layout.dataLabels.yAxis.show', def: true, type: 'checkbox'},
44+
{ key: 'style.layout.dataLabels.yAxis.display', def: 'age', type: 'select', options: ['age', 'year']},
45+
{ key: 'style.layout.dataLabels.yAxis.fontSize', def: 12, type: 'number', min: 8, max: 48},
46+
{ key: 'style.layout.dataLabels.yAxis.color', def: '#1A1A1A', type: 'color'},
47+
{ key: 'style.layout.dataLabels.yAxis.bold', def: false, type: 'checkbox'},
48+
{ key: 'style.layout.dataLabels.yAxis.showEvery', def: 5, type: 'range', min: 1, max: 100},
49+
{ key: 'style.layout.centerSlit.width', def: 20, type: 'number', min: 0, max: 100},
50+
{ key: 'style.layout.bars.gap', def: 2, type: 'number', min: 0, max: 24},
51+
{ key: 'style.layout.bars.borderRadius', def: 2, type: 'number', min: 0, max: 24},
52+
{ key: 'style.layout.bars.left.color', def: '#DC3912', type: 'color'},
53+
{ key: 'style.layout.bars.right.color', def: '#3366CC', type: 'color'},
54+
{ key: 'style.layout.bars.gradient.show', def: true, type: 'checkbox'},
55+
{ key: 'style.layout.bars.gradient.underlayer', def: '#FFFFFF', type: 'color'},
56+
{ key: 'style.layout.bars.gradient.intensity', def: 60, type: 'range', min: 0, max: 100},
57+
{ key: 'style.layout.bars.gradient.shiftHue', def: 0.05, type: 'number', min:0, max: 1, step: 0.01},
58+
{ key: 'style.highlighter.color', def: '#1A1A1A', type: 'color'},
59+
{ key: 'style.highlighter.opacity', def: 5, type: 'range', min: 0, max: 100},
60+
{ key: 'style.title.text', def: 'Lorem ipsum dolor sit amet', type: 'text'},
61+
{ key: 'style.title.color', def: '#1A1A1A', type: 'color'},
62+
{ key: 'style.title.fontSize', def: 20, type: 'number', min: 8, max: 48},
63+
{ key: 'style.title.bold', def: true, type: 'checkbox'},
64+
{ key: 'style.title.subtitle.color', def: '#CCCCCC', type: 'color'},
65+
{ key: 'style.title.subtitle.text', def: 'Lorem ipsum sit amet', type: 'text' },
66+
{ key: 'style.title.subtitle.fontSize', def: 16, type: 'number', min: 8, max: 48},
67+
{ key: 'style.title.subtitle.bold', def: false, type: 'checkbox'},
68+
{ key: 'style.tooltip.show', def: true, type: 'checkbox'},
69+
{ key: 'style.tooltip.backgroundColor', def:'#FFFFFF', type: 'color'},
70+
{ key: 'style.tooltip.color', def: '#1A1A1A', type: 'color'},
71+
{ key: 'style.tooltip.fontSize', def: 14, type: 'number', min: 8, max: 48},
72+
{ key: 'style.tooltip.roundingValue', def: 2, type: 'number', min: 0, max: 12},
73+
{ key: 'translations.age', def: 'age', type: 'text'},
74+
{ key: 'translations.male', def: 'male', type: 'text'},
75+
{ key: 'translations.female', def: 'female', type: 'text'},
76+
{ key: 'translations.total', def: 'total', type: 'text'},
77+
{ key: 'translations.year', def: 'year', type: 'text'},
78+
{ key: 'userOptions.show', def: true, type: 'checkbox'},
79+
{ key: 'table.show', def: false, type: 'checkbox'},
80+
{ key: 'table.responsiveBreakpoint', def: 400, type: 'number', min: 300, max: 800},
81+
{ key: 'table.th.backgroundColor', def: '#FFFFFF', type: 'color'},
82+
{ key: 'table.th.color', def: '#1A1A1A', type: 'color'},
83+
{ key: 'table.th.outline', def: 'none', type: 'text'},
84+
{ key: 'table.td.backgroundColor', def: '#FFFFFF', type: 'color'},
85+
{ key: 'table.td.color', def: '#1A1A1A', type: 'color'},
86+
{ key: 'table.td.outline', def: 'none', type: 'text'}
87+
])
88+
89+
const testCustomTooltip = ref(false);
90+
91+
const config = computed(() => {
92+
const c = convertArrayToObject(model.value)
93+
if(testCustomTooltip.value) {
94+
return {
95+
...c,
96+
style: {
97+
...c.style,
98+
tooltip: {
99+
...c.style.tooltip,
100+
customFormat: ({ datapoint }) => {
101+
console.log({datapoint})
102+
return 'test'
103+
}
104+
}
105+
}
106+
}
107+
} else {
108+
return c
109+
}
110+
});
111+
112+
const step = ref(0);
113+
114+
</script>
115+
116+
<template>
117+
<div style="margin: 12px 0">
118+
<input type="checkbox" v-model="testCustomTooltip" id="custom-tooltip" />
119+
<label for="custom-tooltip" style="color:#CCCCCC">Test custom tooltip</label>
120+
</div>
121+
122+
<Box>
123+
<template #title>VueUiAgePyramid</template>
124+
125+
<template #local>
126+
<LocalVueUiAgePyramid :dataset="dataset" :config="config" :key="`local_${step}`">
127+
<template #svg="{ svg }">
128+
<circle :cx="svg.width / 2" :cy="svg.height / 2" :r="30" fill="#42d392" />
129+
<text :x="svg.width / 2" :y="svg.height / 2" text-anchor="middle">#SVG</text>
130+
</template>
131+
<template #legend="{ legend }">
132+
#LEGEND
133+
<div style="font-size: 8px">
134+
{{ legend }}
135+
</div>
136+
</template>
137+
<template #tooltip-before="{ datapoint, seriesIndex, series, config, bars, lines, plots }">
138+
#BEFORE {{ series.name }}
139+
</template>
140+
<template #tooltip-after="{ datapoint, seriesIndex, series, config, bars, lines, plots }">
141+
#AFTER {{ series.name }}
142+
</template>
143+
</LocalVueUiAgePyramid>
144+
</template>
145+
146+
<template #VDUI-local>
147+
<LocalVueDataUi component="VueUiAgePyramid" :dataset="dataset" :config="config" :key="`VDUI-lodal_${step}`">
148+
<template #svg="{ svg }">
149+
<circle :cx="svg.width / 2" :cy="svg.height / 2" :r="30" fill="#42d392" />
150+
<text :x="svg.width / 2" :y="svg.height / 2" text-anchor="middle">#SVG</text>
151+
</template>
152+
<template #legend="{ legend }">
153+
#LEGEND
154+
<div style="font-size: 8px">
155+
{{ legend }}
156+
</div>
157+
</template>
158+
<template #tooltip-before="{ datapoint, seriesIndex, series, config, bars, lines, plots }">
159+
#BEFORE {{ series.name }}
160+
</template>
161+
<template #tooltip-after="{ datapoint, seriesIndex, series, config, bars, lines, plots }">
162+
#AFTER {{ series.name }}
163+
</template>
164+
</LocalVueDataUi>
165+
</template>
166+
167+
<template #build>
168+
<VueUiAgePyramid :dataset="dataset" :config="config" :key="`build_${step}`">
169+
<template #svg="{ svg }">
170+
<circle :cx="svg.width / 2" :cy="svg.height / 2" :r="30" fill="#42d392" />
171+
<text :x="svg.width / 2" :y="svg.height / 2" text-anchor="middle">#SVG</text>
172+
</template>
173+
<template #legend="{ legend }">
174+
#LEGEND
175+
<div style="font-size: 8px">
176+
{{ legend }}
177+
</div>
178+
</template>
179+
<template #tooltip-before="{ datapoint, seriesIndex, series, config, bars, lines, plots }">
180+
#BEFORE {{ series.name }}
181+
</template>
182+
<template #tooltip-after="{ datapoint, seriesIndex, series, config, bars, lines, plots }">
183+
#AFTER {{ series.name }}
184+
</template>
185+
</VueUiAgePyramid>
186+
</template>
187+
188+
<template #VDUI-build>
189+
<VueDataUi component="VueUiAgePyramid" :dataset="dataset" :config="config" :key="`VDUI-build_${step}`">
190+
<template #svg="{ svg }">
191+
<circle :cx="svg.width / 2" :cy="svg.height / 2" :r="30" fill="#42d392" />
192+
<text :x="svg.width / 2" :y="svg.height / 2" text-anchor="middle">#SVG</text>
193+
</template>
194+
<template #legend="{ legend }">
195+
#LEGEND
196+
<div style="font-size: 8px">
197+
{{ legend }}
198+
</div>
199+
</template>
200+
<template #tooltip-before="{ datapoint, seriesIndex, series, config, bars, lines, plots }">
201+
#BEFORE {{ series.name }}
202+
</template>
203+
<template #tooltip-after="{ datapoint, seriesIndex, series, config, bars, lines, plots }">
204+
#AFTER {{ series.name }}
205+
</template>
206+
</VueDataUi>
207+
</template>
208+
209+
<template #knobs>
210+
<div
211+
style="display: flex; flex-direction: row; flex-wrap:wrap; align-items:center; width: 100%; color: #CCCCCC; gap:24px;">
212+
<div v-for="knob in model">
213+
<label style="font-size: 10px">{{ knob.key }}</label>
214+
<div
215+
style="display:flex; flex-direction:row; flex-wrap: wrap; align-items:center; gap:6px; height: 40px">
216+
<input v-if="!['none', 'select'].includes(knob.type)" :step="knob.step" :type="knob.type" :min="knob.min ?? 0"
217+
:max="knob.max ?? 0" v-model="knob.def" @change="step += 1">
218+
<select v-if="knob.type === 'select'" v-model="knob.def" @change="step += 1">
219+
<option v-for="opt in knob.options">{{ opt }}</option>
220+
</select>
221+
</div>
222+
</div>
223+
</div>
224+
</template>
225+
226+
<template #config>
227+
{{ config }}
228+
</template>
229+
</Box>
230+
</template>

src/App.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import ArenaVueUiSparkHistogram from "../TestingArena/ArenaVueUiSparkHistogram.v
2323
import ArenaVueUiSparkGauge from "../TestingArena/ArenaVueUiSparkGauge.vue";
2424
import ArenaVueUiSparkTrend from "../TestingArena/ArenaVueUiSparkTrend.vue";
2525
import ArenaVueUiQuickChart from "../TestingArena/ArenaVueUiQuickChart.vue";
26+
import ArenaVueUiAgePyramid from "../TestingArena/ArenaVueUiAgePyramid.vue";
2627
2728
const showOldArena = ref(false);
2829
@@ -48,10 +49,11 @@ const components = ref([
4849
"VueUiSparkHistogram",
4950
"VueUiSparkgauge",
5051
"VueUiSparkTrend",
51-
"VueUiQuickChart"
52+
"VueUiQuickChart",
53+
"VueUiAgePyramid"
5254
]);
5355
54-
const selectedComponent = ref(components.value[21]);
56+
const selectedComponent = ref(components.value[22]);
5557
5658
</script>
5759

@@ -130,4 +132,7 @@ const selectedComponent = ref(components.value[21]);
130132

131133
<!-- 21 -->
132134
<ArenaVueUiQuickChart v-if="selectedComponent === 'VueUiQuickChart'" />
135+
136+
<!-- 22 -->
137+
<ArenaVueUiAgePyramid v-if="selectedComponent === 'VueUiAgePyramid'" />
133138
</template>

0 commit comments

Comments
 (0)