@@ -15,6 +15,7 @@ import UserOptions from "../atoms/UserOptions.vue";
1515import { usePrinter } from " ../usePrinter" ;
1616import PackageVersion from " ../atoms/PackageVersion.vue" ;
1717import PenAndPaper from " ../atoms/PenAndPaper.vue" ;
18+ import Skeleton from " ./vue-ui-skeleton.vue" ;
1819
1920const { vue_ui_bullet: DEFAULT_CONFIG } = useConfig ();
2021
@@ -41,15 +42,29 @@ const step = ref(0);
4142
4243const isDataset = computed ({
4344 get : () => {
44- return true // TODO
45+ return props . dataset . hasOwnProperty ( ' value ' )
4546 },
4647 set : (bool ) => {
4748 return bool
4849 }
4950})
5051
5152const hasSegments = computed (() => {
52- if (! props .dataset .segments ) return false ;
53+ if (! props .dataset .segments ) {
54+ console .warn (` VueUiBullet: dataset segments is empty. Provide segments with this datastructure:\n
55+ segments: [
56+ {
57+ name: string;
58+ from: number;
59+ to: number;
60+ color?: string;
61+ },
62+ {...}
63+ ]
64+ ` )
65+ isDataset .value = false ;
66+ return false ;
67+ }
5368 if (! Array .isArray (props .dataset .segments )) {
5469 console .warn (` VueUiBullet: dataset segments must be an array of objects with this datastructure:\n
5570segments: [
@@ -62,6 +77,7 @@ segments: [
6277 {...}
6378]
6479 ` );
80+ isDataset .value = false ;
6581 return false ;
6682 }
6783 if (! props .dataset .segments .length ) {
@@ -75,7 +91,8 @@ segments: [
7591 },
7692 {...}
7793]
78- ` )
94+ ` );
95+ isDataset .value = false ;
7996 return false
8097 };
8198 return true ;
@@ -105,6 +122,8 @@ function prepareChart() {
105122 })
106123 })
107124 })
125+ } else {
126+ isDataset .value = false ;
108127 }
109128 }
110129
@@ -261,6 +280,9 @@ const segments = computed(() => {
261280})
262281
263282const legendSet = computed (() => {
283+ if (! segments .value || ! segments .value .chunks || ! segments .value .chunks .length ) {
284+ return []
285+ }
264286 return segments .value .chunks .map (segment => {
265287 const formattedFrom = applyDataLabel (
266288 FINAL_CONFIG .value .style .chart .segments .dataLabels .formatter ,
@@ -527,6 +549,19 @@ defineExpose({
527549 <slot name =" watermark" v-bind =" { isPrinting: isPrinting || isImaging }" />
528550 </div >
529551
552+ <Skeleton
553+ v-if =" !isDataset"
554+ :config =" {
555+ type: 'bullet',
556+ style: {
557+ backgroundColor: FINAL_CONFIG.style.chart.backgroundColor,
558+ bullet: {
559+ color: '#CCCCCC',
560+ }
561+ }
562+ }"
563+ />
564+
530565 <div ref =" chartLegend" >
531566 <Legend
532567 v-if =" FINAL_CONFIG.style.chart.legend.show"
@@ -543,6 +578,10 @@ defineExpose({
543578 </Legend >
544579 <slot name =" legend" v-bind:legend =" legendSet" />
545580 </div >
581+
582+ <div v-if =" $slots.source" ref =" source" dir =" auto" >
583+ <slot name =" source" />
584+ </div >
546585 </div >
547586</template >
548587
0 commit comments