@dataloop-ai/components 0.17.66 → 0.17.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
<div class="dl-ellipsis">
|
|
3
|
+
<span
|
|
4
|
+
ref="dlEllipsisRef"
|
|
5
|
+
class="dl-ellipsis__left"
|
|
6
|
+
>
|
|
7
|
+
<slot
|
|
8
|
+
v-if="hasDefaultSlot"
|
|
9
|
+
name="default"
|
|
10
|
+
/>
|
|
11
|
+
<span v-else>{{ leftText }}</span>
|
|
8
12
|
</span>
|
|
9
13
|
<span
|
|
10
14
|
v-if="rightText"
|
|
@@ -12,8 +16,18 @@
|
|
|
12
16
|
>
|
|
13
17
|
{{ rightText }}
|
|
14
18
|
</span>
|
|
15
|
-
<dl-tooltip
|
|
16
|
-
|
|
19
|
+
<dl-tooltip
|
|
20
|
+
v-if="shouldShowTooltip"
|
|
21
|
+
:max-width="'max-content'"
|
|
22
|
+
:self="tooltipPosition"
|
|
23
|
+
:anchor="tooltipPosition"
|
|
24
|
+
:offset="tooltipOffset"
|
|
25
|
+
>
|
|
26
|
+
<slot
|
|
27
|
+
v-if="hasDefaultSlot"
|
|
28
|
+
name="default"
|
|
29
|
+
/>
|
|
30
|
+
<span v-else>{{ fullText }}</span>
|
|
17
31
|
</dl-tooltip>
|
|
18
32
|
</div>
|
|
19
33
|
</template>
|
|
@@ -34,63 +48,74 @@ export default defineComponent({
|
|
|
34
48
|
*/
|
|
35
49
|
text: {
|
|
36
50
|
type: String,
|
|
37
|
-
|
|
51
|
+
default: ''
|
|
38
52
|
},
|
|
39
53
|
/**
|
|
40
54
|
* Allows to split the text in two parts
|
|
41
55
|
*/
|
|
42
56
|
split: {
|
|
43
57
|
type: Boolean,
|
|
44
|
-
default: false
|
|
45
|
-
required: false
|
|
58
|
+
default: false
|
|
46
59
|
},
|
|
47
60
|
/**
|
|
48
61
|
* Position of the split in the text, % of the text length
|
|
49
62
|
*/
|
|
50
63
|
splitPosition: {
|
|
51
64
|
type: Number,
|
|
52
|
-
required: false,
|
|
53
65
|
default: 0.5,
|
|
54
|
-
validator: (value
|
|
66
|
+
validator: (value) => value >= 0 && value <= 1
|
|
55
67
|
},
|
|
56
68
|
/**
|
|
57
69
|
* Tooltip to be displayed when the text is truncated
|
|
58
70
|
*/
|
|
59
71
|
tooltip: {
|
|
60
72
|
type: Boolean,
|
|
61
|
-
default: true
|
|
62
|
-
|
|
73
|
+
default: true
|
|
74
|
+
},
|
|
75
|
+
tooltipPosition: {
|
|
76
|
+
type: String,
|
|
77
|
+
default: 'top middle'
|
|
78
|
+
},
|
|
79
|
+
tooltipOffset: {
|
|
80
|
+
type: Array,
|
|
81
|
+
default: () => [0, 25]
|
|
63
82
|
}
|
|
64
83
|
},
|
|
65
|
-
setup(props) {
|
|
66
|
-
const
|
|
84
|
+
setup(props, ctx) {
|
|
85
|
+
const dlEllipsisRef = ref(null)
|
|
86
|
+
const { hasEllipsis } = useSizeObserver(dlEllipsisRef)
|
|
67
87
|
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
88
|
+
const hasDefaultSlot = computed(() => !!ctx.slots.default)
|
|
89
|
+
const splitIndex = computed(() => {
|
|
90
|
+
if (!props.text.length) return null
|
|
91
|
+
return props.split
|
|
92
|
+
? Math.round(props.text.length * props.splitPosition)
|
|
93
|
+
: props.text.length
|
|
73
94
|
})
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
95
|
+
const leftText = computed(() => {
|
|
96
|
+
if (splitIndex.value !== null) {
|
|
97
|
+
return props.text.slice(0, splitIndex.value)
|
|
98
|
+
}
|
|
99
|
+
return ''
|
|
100
|
+
})
|
|
101
|
+
const rightText = computed(() => {
|
|
102
|
+
if (splitIndex.value !== null) {
|
|
103
|
+
return props.text.slice(splitIndex.value)
|
|
104
|
+
}
|
|
105
|
+
return ''
|
|
106
|
+
})
|
|
107
|
+
const shouldShowTooltip = computed(
|
|
108
|
+
() => hasEllipsis.value && props.tooltip
|
|
80
109
|
)
|
|
81
|
-
|
|
82
|
-
const leftText = computed(() => text.slice(0, splitIndex.value))
|
|
83
|
-
const rightText = computed(() => text.slice(splitIndex.value))
|
|
84
|
-
|
|
85
|
-
const { hasEllipsis } = useSizeObserver(dlEllipsisRef)
|
|
86
|
-
const fullText = computed(() => text)
|
|
110
|
+
const fullText = computed(() => props.text)
|
|
87
111
|
|
|
88
112
|
return {
|
|
113
|
+
hasDefaultSlot,
|
|
89
114
|
leftText,
|
|
90
115
|
rightText,
|
|
116
|
+
shouldShowTooltip,
|
|
91
117
|
fullText,
|
|
92
|
-
dlEllipsisRef
|
|
93
|
-
hasEllipsis
|
|
118
|
+
dlEllipsisRef
|
|
94
119
|
}
|
|
95
120
|
}
|
|
96
121
|
})
|
|
@@ -269,6 +269,23 @@ export default defineComponent({
|
|
|
269
269
|
plugins: {
|
|
270
270
|
legend: {
|
|
271
271
|
display: false
|
|
272
|
+
},
|
|
273
|
+
tooltip: {
|
|
274
|
+
yAlign: 'none',
|
|
275
|
+
callbacks: {
|
|
276
|
+
labelColor (
|
|
277
|
+
tooltipItem: { dataIndex: string | number },
|
|
278
|
+
chart: any
|
|
279
|
+
) {
|
|
280
|
+
return {
|
|
281
|
+
backgroundColor:
|
|
282
|
+
chartRefValue.value.data.datasets[0]
|
|
283
|
+
.hoverBackgroundColor[
|
|
284
|
+
tooltipItem.dataIndex
|
|
285
|
+
]
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
272
289
|
}
|
|
273
290
|
}
|
|
274
291
|
},
|
package/src/components/compound/DlCharts/charts/DlDoughnutChart/components/DlDoughnutChartLegend.vue
CHANGED
|
@@ -15,12 +15,6 @@
|
|
|
15
15
|
@mouseenter="emitMouseOverLegend(index)"
|
|
16
16
|
@mouseleave="emitMouseLeaveLegend(index)"
|
|
17
17
|
>
|
|
18
|
-
<dl-tooltip
|
|
19
|
-
self="top middle"
|
|
20
|
-
anchor="top middle"
|
|
21
|
-
>
|
|
22
|
-
{{ data.labels[index] }}
|
|
23
|
-
</dl-tooltip>
|
|
24
18
|
<div class="wrapper__legend__item__label">
|
|
25
19
|
<div>
|
|
26
20
|
<div
|
|
@@ -28,14 +22,12 @@
|
|
|
28
22
|
:style="{ backgroundColor: getColor(index, badge) }"
|
|
29
23
|
/>
|
|
30
24
|
</div>
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
</div>
|
|
38
|
-
</dl-typography>
|
|
25
|
+
<div
|
|
26
|
+
:class="legendLabelClass"
|
|
27
|
+
:style="{ color: getColor(index, text) }"
|
|
28
|
+
>
|
|
29
|
+
<dl-ellipsis :text="data.labels[index]" />
|
|
30
|
+
</div>
|
|
39
31
|
</div>
|
|
40
32
|
<div
|
|
41
33
|
class="wrapper__legend__item__counter truncate"
|
|
@@ -50,7 +42,7 @@
|
|
|
50
42
|
|
|
51
43
|
<script lang="ts">
|
|
52
44
|
import { defineComponent, PropType } from 'vue-demi'
|
|
53
|
-
import
|
|
45
|
+
import DlEllipsis from '../../../../../basic/DlEllipsis/DlEllipsis.vue'
|
|
54
46
|
import { TDoughnutChartData } from '../types/TDoughnutChartData'
|
|
55
47
|
|
|
56
48
|
enum EBadgeText {
|
|
@@ -62,8 +54,7 @@ type TBadgeText = EBadgeText.badge | EBadgeText.text
|
|
|
62
54
|
export default defineComponent({
|
|
63
55
|
name: 'DlDoughnutChartLegend',
|
|
64
56
|
components: {
|
|
65
|
-
|
|
66
|
-
DlTooltip
|
|
57
|
+
DlEllipsis
|
|
67
58
|
},
|
|
68
59
|
props: {
|
|
69
60
|
data: {
|