1
1
<script setup>
2
2
import { ref , computed , onMounted } from " vue" ;
3
- import { calcMarkerOffsetX , calcMarkerOffsetY , calcNutArrowPath , makeDonut , palette , convertColorToHex , opacity , makeXls , createUid } from ' ../lib' ;
3
+ import { convertColorToHex , createUid } from ' ../lib' ;
4
4
import pdf from " ../pdf" ;
5
5
import img from " ../img" ;
6
6
import mainConfig from " ../default_configs.json" ;
7
7
import Title from " ../atoms/Title.vue" ;
8
8
import { useNestedProp } from " ../useNestedProp" ;
9
9
import UserOptions from " ../atoms/UserOptions.vue" ;
10
- import DataTable from " ../atoms/DataTable.vue" ;
11
- import Tooltip from " ../atoms/Tooltip.vue" ;
12
- import Legend from " ../atoms/Legend.vue" ;
13
10
14
11
const props = defineProps ({
15
12
config: {
@@ -32,11 +29,7 @@ const defaultConfig = ref(mainConfig.vue_ui_3d_bar);
32
29
33
30
const isPrinting = ref (false );
34
31
const isImaging = ref (false );
35
- const bar3dChart = ref (null );
36
32
const details = ref (null );
37
- const isTooltip = ref (false );
38
- const tooltipContent = ref (" " );
39
- const selectedSerie = ref (null );
40
33
41
34
const barConfig = computed (() => {
42
35
return useNestedProp ({
@@ -62,7 +55,11 @@ const box = computed(() => {
62
55
right: ` M${ svg .value .width / 2 } ,${ svg .value .top } ${ svg .value .width - svg .value .right } , ${ svg .value .top + svg .value .perspective } ${ svg .value .width - svg .value .right } ,${ svg .value .height - svg .value .bottom - svg .value .perspective } ${ svg .value .width / 2 } ,${ svg .value .height - svg .value .bottom } ` ,
63
56
left: ` M${ svg .value .width / 2 } ,${ svg .value .top } ${ svg .value .left } ,${ svg .value .top + svg .value .perspective } ${ svg .value .left } ,${ svg .value .height - svg .value .bottom - svg .value .perspective } ${ svg .value .width / 2 } ,${ svg .value .height - svg .value .bottom } ` ,
64
57
side: ` M${ svg .value .width / 2 } ,${ svg .value .height - svg .value .bottom } ${ svg .value .width / 2 } ,${ svg .value .top + (svg .value .perspective * 2 )} ` ,
65
- topSides: ` M${ svg .value .left } ,${ svg .value .top + svg .value .perspective } ${ svg .value .width / 2 } ,${ svg .value .top + (svg .value .perspective * 2 )} ${ svg .value .width - svg .value .right } ,${ svg .value .top + svg .value .perspective } `
58
+ topSides: ` M${ svg .value .left } ,${ svg .value .top + svg .value .perspective } ${ svg .value .width / 2 } ,${ svg .value .top + (svg .value .perspective * 2 )} ${ svg .value .width - svg .value .right } ,${ svg .value .top + svg .value .perspective } ` ,
59
+ tubeTop: ` M${ svg .value .left } ,${ svg .value .top + svg .value .perspective } C ${ svg .value .left } ,${ svg .value .top - (svg .value .perspective / 3 )} ${ svg .value .width - svg .value .right } ,${ svg .value .top - (svg .value .perspective / 3 )} ${ svg .value .width - svg .value .right } ,${ svg .value .top + svg .value .perspective } C ${ svg .value .width - svg .value .right } ,${ svg .value .top + (svg .value .perspective * 2.3 )} ${ svg .value .left } ,${ svg .value .top + (svg .value .perspective * 2.3 )} ${ svg .value .left } ,${ svg .value .top + svg .value .perspective } ` ,
60
+ tubeLeft: ` M${ svg .value .left } ,${ svg .value .top + svg .value .perspective } ${ svg .value .left } ,${ svg .value .height - svg .value .bottom - svg .value .perspective } ` ,
61
+ tubeRight: ` M${ svg .value .width - svg .value .right } ,${ svg .value .top + svg .value .perspective } ${ svg .value .width - svg .value .right } ,${ svg .value .height - svg .value .bottom - svg .value .perspective } ` ,
62
+ tubeBottom: ` M${ svg .value .width - svg .value .right } ,${ svg .value .height - svg .value .bottom - svg .value .perspective } C ${ svg .value .width - svg .value .right } ,${ svg .value .height } ${ svg .value .left } ,${ svg .value .height } ${ svg .value .left } ,${ svg .value .height - svg .value .bottom - svg .value .perspective } `
66
63
}
67
64
});
68
65
@@ -94,7 +91,18 @@ const fill = computed(() => {
94
91
return {
95
92
right: ` M${ svg .value .width / 2 } ,${ svg .value .height - svg .value .bottom } ${ svg .value .width / 2 } ,${ svg .value .height - svg .value .bottom - height * proportion} ${ svg .value .width - svg .value .right } ,${ svg .value .height - svg .value .bottom - svg .value .perspective - height * proportion} ${ svg .value .width - svg .value .right } ,${ svg .value .height - svg .value .bottom - svg .value .perspective } Z` ,
96
93
left: ` M${ svg .value .width / 2 } ,${ svg .value .height - svg .value .bottom } ${ svg .value .width / 2 } ,${ svg .value .height - svg .value .bottom - height * proportion} ${ svg .value .left } , ${ svg .value .height - svg .value .bottom - svg .value .perspective - height * proportion} ${ svg .value .left } ,${ svg .value .height - svg .value .bottom - svg .value .perspective } Z` ,
97
- top: ` M${ svg .value .width / 2 } ,${ svg .value .height - svg .value .bottom - height * proportion} ${ svg .value .left } ,${ svg .value .height - svg .value .bottom - svg .value .perspective - height * proportion} ${ svg .value .width / 2 } ,${ svg .value .height - svg .value .bottom - (svg .value .perspective * 2 ) - (height * proportion)} ${ svg .value .width - svg .value .right } ,${ svg .value .height - svg .value .bottom - svg .value .perspective - height * proportion} Z`
94
+ top: ` M${ svg .value .width / 2 } ,${ svg .value .height - svg .value .bottom - height * proportion} ${ svg .value .left } ,${ svg .value .height - svg .value .bottom - svg .value .perspective - height * proportion} ${ svg .value .width / 2 } ,${ svg .value .height - svg .value .bottom - (svg .value .perspective * 2 ) - (height * proportion)} ${ svg .value .width - svg .value .right } ,${ svg .value .height - svg .value .bottom - svg .value .perspective - height * proportion} Z` ,
95
+ tubeTop: ` M${ svg .value .left } ,${ svg .value .height - svg .value .bottom - height * proportion - svg .value .perspective } C ${ svg .value .left } ,${ svg .value .height - svg .value .bottom - height * proportion - (svg .value .perspective * 2.5 )} ${ svg .value .width - svg .value .right } ,${ svg .value .height - svg .value .bottom - height * proportion - (svg .value .perspective * 2.5 )} ${ svg .value .width - svg .value .right } ,${ svg .value .height - svg .value .bottom - height * proportion - svg .value .perspective } C ${ svg .value .width - svg .value .right } ,${ svg .value .height - svg .value .bottom - height * proportion + svg .value .perspective / 2 } ${ svg .value .left } ,${ svg .value .height - svg .value .bottom - height * proportion + svg .value .perspective / 2 } ${ svg .value .left } ,${ svg .value .height - svg .value .bottom - height * proportion - svg .value .perspective } ` ,
96
+ tubeBody: ` M
97
+ ${ svg .value .left } ,${ svg .value .height - svg .value .bottom - height * proportion - svg .value .perspective }
98
+ C ${ svg .value .left } ,${ svg .value .height - svg .value .bottom - height * proportion + svg .value .perspective / 2 }
99
+ ${ svg .value .width - svg .value .right } ,${ svg .value .height - svg .value .bottom - height * proportion + svg .value .perspective / 2 }
100
+ ${ svg .value .width - svg .value .right } ,${ svg .value .height - svg .value .bottom - height * proportion - svg .value .perspective }
101
+ L${ svg .value .width - svg .value .right } ,${ svg .value .height - svg .value .perspective * 1.5 }
102
+ C
103
+ ${ svg .value .width - svg .value .right } ,${ svg .value .height }
104
+ ${ svg .value .left } ,${ svg .value .height }
105
+ ${ svg .value .left } ,${ svg .value .height - svg .value .bottom - svg .value .perspective } Z`
98
106
}
99
107
})
100
108
@@ -201,6 +209,11 @@ defineExpose({
201
209
<stop offset =" 0%" :stop-color =" `${convertColorToHex(barConfig.style.chart.backgroundColor)}00`" />
202
210
<stop offset =" 100%" :stop-color =" `${barConfig.style.chart.bar.color}33`" />
203
211
</radialGradient >
212
+ <linearGradient :id =" `gradient_tube_body${uid}`" x1 =" 0%" y1 =" 0%" x2 =" 100%" y2 =" 0%" >
213
+ <stop offset =" 0%" :stop-color =" `${barConfig.style.chart.bar.color}`" />
214
+ <stop offset =" 75%" :stop-color =" `${convertColorToHex(barConfig.style.chart.backgroundColor)}00`" />
215
+ <stop offset =" 100%" :stop-color =" `${barConfig.style.chart.bar.color}66`" />
216
+ </linearGradient >
204
217
</defs >
205
218
206
219
<text
@@ -214,17 +227,31 @@ defineExpose({
214
227
>
215
228
{{Number((isNaN(activeValue) ? 0 : activeValue).toFixed(barConfig.style.chart.dataLabel.rounding)).toLocaleString() }} %
216
229
</text >
217
-
218
- <!-- BOX SKELETON -->
219
- <path :stroke-dasharray =" barConfig.style.chart.box.strokeDasharray" :d =" box.right" :stroke =" barConfig.style.chart.box.stroke" :stroke-width =" barConfig.style.chart.box.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" fill =" none" />
220
- <path :stroke-dasharray =" barConfig.style.chart.box.strokeDasharray" :d =" box.left" :stroke =" barConfig.style.chart.box.stroke" :stroke-width =" barConfig.style.chart.box.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" fill =" none" />
221
- <path :stroke-dasharray =" barConfig.style.chart.box.strokeDasharray" :d =" box.side" :stroke =" barConfig.style.chart.box.stroke" :stroke-width =" barConfig.style.chart.box.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" fill =" none" />
222
- <path :stroke-dasharray =" barConfig.style.chart.box.strokeDasharray" :d =" box.topSides" :stroke =" barConfig.style.chart.box.stroke" :stroke-width =" barConfig.style.chart.box.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" fill =" none" />
223
-
224
- <!-- FILL BOX -->
225
- <path :d =" fill.right" :stroke =" barConfig.style.chart.bar.stroke" :stroke-width =" barConfig.style.chart.bar.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" :fill =" `url(#gradient_right${uid})`" />
226
- <path :d =" fill.left" :stroke =" barConfig.style.chart.bar.stroke" :stroke-width =" barConfig.style.chart.bar.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" :fill =" `url(#gradient_left${uid})`" />
227
- <path :d =" fill.top" :stroke =" barConfig.style.chart.bar.stroke" :stroke-width =" barConfig.style.chart.bar.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" :fill =" `url(#gradient_top${uid})`" />
230
+
231
+
232
+ <g v-if =" !barConfig.style.shape || barConfig.style.shape === 'bar'" >
233
+ <!-- BOX SKELETON -->
234
+ <path :stroke-dasharray =" barConfig.style.chart.box.strokeDasharray" :d =" box.right" :stroke =" barConfig.style.chart.box.stroke" :stroke-width =" barConfig.style.chart.box.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" fill =" none" />
235
+ <path :stroke-dasharray =" barConfig.style.chart.box.strokeDasharray" :d =" box.left" :stroke =" barConfig.style.chart.box.stroke" :stroke-width =" barConfig.style.chart.box.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" fill =" none" />
236
+ <path :stroke-dasharray =" barConfig.style.chart.box.strokeDasharray" :d =" box.side" :stroke =" barConfig.style.chart.box.stroke" :stroke-width =" barConfig.style.chart.box.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" fill =" none" />
237
+ <path :stroke-dasharray =" barConfig.style.chart.box.strokeDasharray" :d =" box.topSides" :stroke =" barConfig.style.chart.box.stroke" :stroke-width =" barConfig.style.chart.box.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" fill =" none" />
238
+
239
+ <!-- FILL BOX -->
240
+ <path :d =" fill.right" :stroke =" barConfig.style.chart.bar.stroke" :stroke-width =" barConfig.style.chart.bar.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" :fill =" `url(#gradient_right${uid})`" />
241
+ <path :d =" fill.left" :stroke =" barConfig.style.chart.bar.stroke" :stroke-width =" barConfig.style.chart.bar.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" :fill =" `url(#gradient_left${uid})`" />
242
+ <path :d =" fill.top" :stroke =" barConfig.style.chart.bar.stroke" :stroke-width =" barConfig.style.chart.bar.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" :fill =" `url(#gradient_top${uid})`" />
243
+ </g >
244
+
245
+ <g v-if =" barConfig.style.shape === 'tube'" >
246
+ <!-- TUBE SKELETON -->
247
+ <path :stroke-dasharray =" barConfig.style.chart.box.strokeDasharray" :d =" box.tubeTop" :stroke =" barConfig.style.chart.box.stroke" :stroke-width =" barConfig.style.chart.box.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" fill =" none" />
248
+ <path :stroke-dasharray =" barConfig.style.chart.box.strokeDasharray" :d =" box.tubeLeft" :stroke =" barConfig.style.chart.box.stroke" :stroke-width =" barConfig.style.chart.box.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" fill =" none" />
249
+ <path :stroke-dasharray =" barConfig.style.chart.box.strokeDasharray" :d =" box.tubeRight" :stroke =" barConfig.style.chart.box.stroke" :stroke-width =" barConfig.style.chart.box.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" fill =" none" />
250
+ <path :stroke-dasharray =" barConfig.style.chart.box.strokeDasharray" :d =" box.tubeBottom" :stroke =" barConfig.style.chart.box.stroke" :stroke-width =" barConfig.style.chart.box.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" fill =" none" />
251
+ <!-- FILL TUBE -->
252
+ <path :d =" fill.tubeTop" :stroke =" barConfig.style.chart.bar.stroke" :stroke-width =" barConfig.style.chart.bar.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" :fill =" `url(#gradient_top${uid})`" />
253
+ <path :d =" fill.tubeBody" :stroke =" barConfig.style.chart.bar.stroke" :stroke-width =" barConfig.style.chart.bar.strokeWidth" stroke-linejoin =" round" stroke-linecap =" round" :fill =" `url(#gradient_tube_body${uid})`" />
254
+ </g >
228
255
229
256
<slot name =" svg" :svg =" svg" />
230
257
</svg >
0 commit comments