@dataloop-ai/components 0.13.19 → 0.14.4
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/.nvmrc +1 -0
- package/README.md +3 -1
- package/package.json +19 -17
- package/src/assets/globals.scss +38 -3
- package/src/assets/grid.scss +9 -0
- package/src/components/DlAccordion/DlAccordion.vue +4 -4
- package/src/components/DlAlert.vue +6 -6
- package/src/components/DlChart/BrushThumb.vue +83 -0
- package/src/components/DlChart/DlBarChart.vue +545 -0
- package/src/components/DlChart/DlBrush.vue +475 -0
- package/src/components/DlChart/DlChartLabels.vue +279 -0
- package/src/components/DlChart/DlChartLegend.vue +141 -0
- package/src/components/DlChart/DlColumnChart.vue +555 -0
- package/src/components/DlChart/DlLineChart.vue +644 -0
- package/src/components/DlChart/DlScrollBar.vue +147 -0
- package/src/components/DlChart/Doughnut/DlDoughnutChart.vue +448 -0
- package/src/components/DlChart/Doughnut/DlDoughnutChartLegend.vue +281 -0
- package/src/components/DlChart/Doughnut/DlDoughnutChartWidget.vue +64 -0
- package/src/components/DlChart/Doughnut/types/TDoughnutChartAnimation.ts +4 -0
- package/src/components/DlChart/Doughnut/types/TDoughnutChartData.ts +16 -0
- package/src/components/DlChart/Doughnut/types/TDoughnutChartOptions.ts +11 -0
- package/src/components/DlChart/Doughnut/types/TDoughnutChartProps.ts +8 -0
- package/src/components/DlChart/Doughnut/types/TDoughnutWithOriginalColor.ts +13 -0
- package/src/components/DlChart/chart.ts +122 -0
- package/src/components/DlChart/index.ts +36 -0
- package/src/components/DlChart/props.ts +348 -0
- package/src/components/DlChart/typedCharts.ts +88 -0
- package/src/components/DlChart/types.ts +63 -0
- package/src/components/DlChart/utils.ts +153 -0
- package/src/components/DlChip/DlChip.vue +40 -13
- package/src/components/DlCounters.vue +31 -7
- package/src/components/DlDatePicker/DlCalendar.vue +22 -10
- package/src/components/DlDatePicker/DlDatePicker.vue +8 -5
- package/src/components/DlDateTimeRange/types.ts +2 -2
- package/src/components/DlDropdownButton.vue +5 -3
- package/src/components/DlMenu/DlMenu.vue +4 -2
- package/src/components/DlPagination/RowsSelector.vue +15 -2
- package/src/components/DlPopup/DlPopup.vue +0 -1
- package/src/components/DlRange/DlRange.vue +3 -2
- package/src/components/DlSearch.vue +1 -1
- package/src/components/DlSelect/DlSelect.vue +3 -2
- package/src/components/DlSlider/sliderStyles.scss +4 -0
- package/src/components/DlSlider/useSlider.ts +39 -12
- package/src/components/DlSmartSearch/DlSuggestionsDropdown.vue +1 -1
- package/src/components/DlSpinner.vue +259 -0
- package/src/components/DlTable/DlTable.vue +4 -1
- package/src/components/DlTable/hooks/tablePagination.ts +8 -2
- package/src/components/DlTextArea.vue +9 -0
- package/src/components/DlTextInput.vue +4 -2
- package/src/components/DlThemeProvider.vue +22 -13
- package/src/components/DlToastMessage/api/useToast.ts +23 -0
- package/src/components/DlToastMessage/components/ToastComponent.vue +279 -0
- package/src/components/DlToastMessage/index.ts +5 -0
- package/src/components/DlToastMessage/types.ts +4 -0
- package/src/components/DlToastMessage/utils/config.ts +17 -0
- package/src/components/DlToastMessage/utils/render.ts +56 -0
- package/src/components/DlTypography.vue +1 -1
- package/src/components/DlWidget/DlGrid.vue +33 -0
- package/src/components/DlWidget/DlGridRow.vue +32 -0
- package/src/components/DlWidget/DlWidget.vue +202 -11
- package/src/components/DlWidget/index.ts +2 -2
- package/src/components/DlWidget/utils.ts +26 -19
- package/src/components/index.ts +8 -3
- package/src/demo/BarChartDemo.vue +77 -0
- package/src/demo/ColumnChartDemo.vue +230 -0
- package/src/demo/DlButtonDemo.vue +1 -1
- package/src/demo/DlChartDoughnutDemo.vue +229 -0
- package/src/demo/DlChipDemo.vue +42 -18
- package/src/demo/DlDialogBoxDemo.vue +4 -4
- package/src/demo/DlDropdownButtonDemo.vue +1 -1
- package/src/demo/DlLineChartDemo.vue +375 -0
- package/src/demo/DlMenuDemo.vue +1 -1
- package/src/demo/DlOptionGroupDemo.vue +1 -1
- package/src/demo/DlSelectDemo.vue +1 -1
- package/src/demo/DlSpinnerDemo.vue +20 -0
- package/src/demo/DlTableDemo.vue +13 -94
- package/src/demo/DlToastMessageDemo.vue +143 -0
- package/src/demo/DlWidgetDemo.vue +105 -143
- package/src/demo/index.ts +20 -2
- package/src/hooks/use-theme.ts +19 -0
- package/src/utils/abbreviate-to-string.ts +14 -0
- package/src/utils/colors.ts +47 -0
- package/src/utils/getRootStyles.ts +1 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/position-engine.ts +11 -2
- package/src/utils/swapNodes.ts +30 -0
- package/src/utils/update-key.ts +90 -0
- package/tsconfig.json +0 -1
- package/vite.config.ts +17 -0
- package/Dockerfile +0 -12
- package/jest.config.js +0 -16
- package/jest.setup.js +0 -59
- package/src/components/DlWidget/DlWidgetGrid.vue +0 -360
- package/storybook.js +0 -8
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { defineComponent } from 'vue-demi'
|
|
3
|
+
|
|
4
|
+
export default defineComponent({
|
|
5
|
+
name: 'DlScrollBar',
|
|
6
|
+
props: {
|
|
7
|
+
itemCount: {
|
|
8
|
+
type: Number,
|
|
9
|
+
default: 0
|
|
10
|
+
},
|
|
11
|
+
itemsInView: {
|
|
12
|
+
type: Number,
|
|
13
|
+
default: 0
|
|
14
|
+
},
|
|
15
|
+
position: {
|
|
16
|
+
type: Number,
|
|
17
|
+
default: 0
|
|
18
|
+
},
|
|
19
|
+
height: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: null
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
emits: ['position-update'],
|
|
25
|
+
data(): {
|
|
26
|
+
isDragging: boolean
|
|
27
|
+
mouseOffsetTop: number
|
|
28
|
+
maxHeight: number
|
|
29
|
+
previousMin: number
|
|
30
|
+
} {
|
|
31
|
+
return {
|
|
32
|
+
isDragging: false,
|
|
33
|
+
mouseOffsetTop: null,
|
|
34
|
+
maxHeight: null,
|
|
35
|
+
previousMin: 0
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
computed: {
|
|
39
|
+
heightNum(): number {
|
|
40
|
+
return parseInt(this.height)
|
|
41
|
+
},
|
|
42
|
+
scrollStep(): number {
|
|
43
|
+
return this.heightNum / this.itemCount
|
|
44
|
+
},
|
|
45
|
+
scrollTop(): number {
|
|
46
|
+
const top = this.position * this.scrollStep
|
|
47
|
+
const space =
|
|
48
|
+
this.maxHeight -
|
|
49
|
+
(this.$refs.scroll as HTMLElement)?.offsetHeight -
|
|
50
|
+
50
|
|
51
|
+
return top < space ? top : space
|
|
52
|
+
},
|
|
53
|
+
scrollClasses(): string {
|
|
54
|
+
return `scroll-bar ${this.isDragging ? 'scroll-bar__drag' : ''}`
|
|
55
|
+
},
|
|
56
|
+
scrollStyles(): Record<string, string> {
|
|
57
|
+
return {
|
|
58
|
+
marginTop: `${this.scrollTop}px`,
|
|
59
|
+
height: `${
|
|
60
|
+
(this.itemsInView * this.heightNum) / this.itemCount
|
|
61
|
+
}px`
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
maxScroll(): number {
|
|
65
|
+
return (this.$refs as any).wrapper.offsetHeight - 50 || 1
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
mounted() {
|
|
69
|
+
window.addEventListener('mouseup', this.stopDragging)
|
|
70
|
+
this.$nextTick(() => {
|
|
71
|
+
this.maxHeight = (this.$refs.wrapper as HTMLElement).offsetHeight
|
|
72
|
+
})
|
|
73
|
+
},
|
|
74
|
+
methods: {
|
|
75
|
+
startDragging(e: MouseEvent) {
|
|
76
|
+
this.isDragging = true
|
|
77
|
+
this.mouseOffsetTop =
|
|
78
|
+
e.clientY - (this.$refs.scroll as HTMLElement).offsetTop
|
|
79
|
+
window.addEventListener('mousemove', this.moveScrollBar)
|
|
80
|
+
},
|
|
81
|
+
stopDragging() {
|
|
82
|
+
this.isDragging = false
|
|
83
|
+
window.removeEventListener('mousemove', this.moveScrollBar)
|
|
84
|
+
},
|
|
85
|
+
moveScrollBar(e: MouseEvent) {
|
|
86
|
+
if (!this.isDragging) return
|
|
87
|
+
const marginTop =
|
|
88
|
+
e.clientY -
|
|
89
|
+
(this.$refs.wrapper as HTMLElement).offsetTop -
|
|
90
|
+
this.mouseOffsetTop
|
|
91
|
+
if (
|
|
92
|
+
marginTop < 0 ||
|
|
93
|
+
marginTop >
|
|
94
|
+
this.maxHeight -
|
|
95
|
+
(this.$refs.scroll as HTMLElement).offsetHeight -
|
|
96
|
+
50
|
|
97
|
+
)
|
|
98
|
+
return
|
|
99
|
+
;(
|
|
100
|
+
this.$refs.scroll as HTMLElement
|
|
101
|
+
).style.marginTop = `${marginTop}px`
|
|
102
|
+
this.updatePosition(marginTop)
|
|
103
|
+
},
|
|
104
|
+
updatePosition(top: number) {
|
|
105
|
+
const newMin = Math.trunc((this.itemCount * top) / this.maxScroll)
|
|
106
|
+
if (newMin !== this.previousMin + 1) {
|
|
107
|
+
this.$emit('position-update', newMin)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
</script>
|
|
113
|
+
|
|
114
|
+
<template>
|
|
115
|
+
<div
|
|
116
|
+
ref="wrapper"
|
|
117
|
+
class="scroll-bar-wrapper"
|
|
118
|
+
>
|
|
119
|
+
<div
|
|
120
|
+
ref="scroll"
|
|
121
|
+
:style="scrollStyles"
|
|
122
|
+
:class="scrollClasses"
|
|
123
|
+
@mousedown="startDragging"
|
|
124
|
+
/>
|
|
125
|
+
</div>
|
|
126
|
+
</template>
|
|
127
|
+
|
|
128
|
+
<style scoped lang="scss">
|
|
129
|
+
.scroll-bar-wrapper {
|
|
130
|
+
margin-top: 10px;
|
|
131
|
+
width: 1%;
|
|
132
|
+
}
|
|
133
|
+
.scroll-bar {
|
|
134
|
+
background: #d9d9d9;
|
|
135
|
+
width: 100%;
|
|
136
|
+
opacity: 0.8;
|
|
137
|
+
border-radius: 5px;
|
|
138
|
+
transition: margin-top 0.5s;
|
|
139
|
+
cursor: pointer;
|
|
140
|
+
&:hover {
|
|
141
|
+
background-color: #949494;
|
|
142
|
+
}
|
|
143
|
+
&__drag {
|
|
144
|
+
transition: margin-top 0s;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
</style>
|
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
ref="dlDoughnutChartWidgetRef"
|
|
4
|
+
class="dl_doughnut"
|
|
5
|
+
>
|
|
6
|
+
<div
|
|
7
|
+
v-if="itemsCount"
|
|
8
|
+
class="dl_doughnut__wrapper"
|
|
9
|
+
:class="classFlexLg"
|
|
10
|
+
>
|
|
11
|
+
<div
|
|
12
|
+
v-if="doughnutData"
|
|
13
|
+
class="dl_doughnut__wrapper__container"
|
|
14
|
+
:class="classFlexDirection"
|
|
15
|
+
>
|
|
16
|
+
<div
|
|
17
|
+
class="dl_doughnut__wrapper__container__chart"
|
|
18
|
+
:style="styleDoughnutWidth"
|
|
19
|
+
@mouseover="setHoverLight"
|
|
20
|
+
@mouseleave="resetColors"
|
|
21
|
+
>
|
|
22
|
+
<Doughnut
|
|
23
|
+
ref="doughnutChartRef"
|
|
24
|
+
:data="doughnutData"
|
|
25
|
+
:options="doughnutOptions"
|
|
26
|
+
:plugins="doughnutPlugins"
|
|
27
|
+
/>
|
|
28
|
+
<div
|
|
29
|
+
v-if="hasSummary"
|
|
30
|
+
ref="dlDoughnutChartSummaryRef"
|
|
31
|
+
class="dl_doughnut__wrapper__container__chart__summary text-center"
|
|
32
|
+
>
|
|
33
|
+
<div :class="classSummaryLabel">
|
|
34
|
+
Total items
|
|
35
|
+
</div>
|
|
36
|
+
<div :class="classSummaryCount">
|
|
37
|
+
{{ itemsCount }}
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
<div class="dl_doughnut__wrapper__legend">
|
|
42
|
+
<div class="dl_doughnut__wrapper__legend__row">
|
|
43
|
+
<dl-doughnut-chart-legend
|
|
44
|
+
:data="doughnutData"
|
|
45
|
+
:hidden-indexes="hiddenIndexes"
|
|
46
|
+
:is-small="isSmall"
|
|
47
|
+
@hide="hideData"
|
|
48
|
+
@mouseOverLegend="darkHighlight"
|
|
49
|
+
@mouseLeaveLegend="resetColors"
|
|
50
|
+
/>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
<div v-else>
|
|
56
|
+
No data
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</template>
|
|
60
|
+
|
|
61
|
+
<script lang="ts">
|
|
62
|
+
import {
|
|
63
|
+
computed,
|
|
64
|
+
defineComponent,
|
|
65
|
+
ref,
|
|
66
|
+
reactive,
|
|
67
|
+
PropType,
|
|
68
|
+
onMounted
|
|
69
|
+
} from 'vue-demi'
|
|
70
|
+
|
|
71
|
+
import {
|
|
72
|
+
Chart as ChartJS,
|
|
73
|
+
Tooltip,
|
|
74
|
+
Legend,
|
|
75
|
+
DoughnutController,
|
|
76
|
+
ArcElement,
|
|
77
|
+
ChartData,
|
|
78
|
+
DoughnutControllerChartOptions
|
|
79
|
+
} from 'chart.js'
|
|
80
|
+
|
|
81
|
+
ChartJS.register(Tooltip, Legend, DoughnutController, ArcElement)
|
|
82
|
+
|
|
83
|
+
import { cloneDeep, merge } from 'lodash'
|
|
84
|
+
import { Doughnut } from '../index'
|
|
85
|
+
import { useThemeVariables } from '../../../hooks/use-theme'
|
|
86
|
+
import { updateNestedArrayValues } from '../../../utils/update-key'
|
|
87
|
+
import DlDoughnutChartLegend from './DlDoughnutChartLegend.vue'
|
|
88
|
+
import { defaultDoughnutChartProps } from '../props'
|
|
89
|
+
import { TDoughnutWithOriginalColor } from './types/TDoughnutWithOriginalColor'
|
|
90
|
+
|
|
91
|
+
export default defineComponent({
|
|
92
|
+
name: 'DlDoughnutChart',
|
|
93
|
+
components: {
|
|
94
|
+
Doughnut,
|
|
95
|
+
DlDoughnutChartLegend
|
|
96
|
+
},
|
|
97
|
+
props: {
|
|
98
|
+
data: {
|
|
99
|
+
type: Object as PropType<ChartData<'doughnut'>>,
|
|
100
|
+
required: true
|
|
101
|
+
},
|
|
102
|
+
isSmall: {
|
|
103
|
+
type: Boolean,
|
|
104
|
+
default: false
|
|
105
|
+
},
|
|
106
|
+
hasSummary: {
|
|
107
|
+
type: Boolean,
|
|
108
|
+
default: false
|
|
109
|
+
},
|
|
110
|
+
animation: {
|
|
111
|
+
type: Object as PropType<
|
|
112
|
+
DoughnutControllerChartOptions['animation']
|
|
113
|
+
>,
|
|
114
|
+
required: false
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
setup(props) {
|
|
118
|
+
/** Data */
|
|
119
|
+
const doughnutChartRef = ref(null)
|
|
120
|
+
const dlDoughnutChartWidgetRef = ref(null)
|
|
121
|
+
const doughnutChartWidgetWidth = ref()
|
|
122
|
+
const doughnutChartWidgetHeight = ref()
|
|
123
|
+
const dlDoughnutChartSummaryRef = ref<HTMLDivElement>(null)
|
|
124
|
+
const defaultOptions = cloneDeep(defaultDoughnutChartProps.options)
|
|
125
|
+
|
|
126
|
+
const sizePercents = 70
|
|
127
|
+
|
|
128
|
+
const chartRefValue = computed(() => {
|
|
129
|
+
return doughnutChartRef.value?.chart?.value || {}
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
const hiddenIndexes = ref([])
|
|
133
|
+
|
|
134
|
+
const { variables } = useThemeVariables()
|
|
135
|
+
const replaceColor = (key: keyof typeof variables) =>
|
|
136
|
+
variables[key] || key
|
|
137
|
+
|
|
138
|
+
const setDoughnutData = () => {
|
|
139
|
+
let dumpPropsData: TDoughnutWithOriginalColor =
|
|
140
|
+
{} as TDoughnutWithOriginalColor
|
|
141
|
+
|
|
142
|
+
if (
|
|
143
|
+
props.data?.datasets?.length &&
|
|
144
|
+
(props.data.datasets[0]?.backgroundColor as any)?.length
|
|
145
|
+
) {
|
|
146
|
+
dumpPropsData = cloneDeep(
|
|
147
|
+
props.data
|
|
148
|
+
) as TDoughnutWithOriginalColor
|
|
149
|
+
dumpPropsData.datasets[0] = updateNestedArrayValues(
|
|
150
|
+
cloneDeep(props.data.datasets[0]),
|
|
151
|
+
['backgroundColor', 'hoverBackgroundColor', 'lightColor'],
|
|
152
|
+
replaceColor
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
dumpPropsData.datasets[0].originalBackgroundColor = cloneDeep(
|
|
156
|
+
dumpPropsData?.datasets[0]?.backgroundColor
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return dumpPropsData
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const doughnutData = ref(setDoughnutData())
|
|
164
|
+
|
|
165
|
+
const doughnutPlugins = reactive([
|
|
166
|
+
{
|
|
167
|
+
id: 'centerSummary',
|
|
168
|
+
afterDraw(chart: any, args: any, options: any) {
|
|
169
|
+
const {
|
|
170
|
+
ctx,
|
|
171
|
+
chartArea: { top, width, height }
|
|
172
|
+
} = chart
|
|
173
|
+
ctx.save()
|
|
174
|
+
|
|
175
|
+
const slotDiv: HTMLDivElement =
|
|
176
|
+
dlDoughnutChartSummaryRef.value
|
|
177
|
+
|
|
178
|
+
if (!slotDiv) {
|
|
179
|
+
return
|
|
180
|
+
}
|
|
181
|
+
const summaryHeight = height / 2
|
|
182
|
+
const divHeight = summaryHeight / 8
|
|
183
|
+
const summaryTop = (summaryHeight + divHeight) * -1
|
|
184
|
+
|
|
185
|
+
slotDiv.style.position = 'relative'
|
|
186
|
+
slotDiv.style.top = `${summaryTop}px`
|
|
187
|
+
slotDiv.style.textAlign = 'center'
|
|
188
|
+
|
|
189
|
+
ctx.restore()
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
])
|
|
193
|
+
/** Computed */
|
|
194
|
+
const itemsCount = computed(() =>
|
|
195
|
+
props.data?.datasets?.length &&
|
|
196
|
+
props.data?.datasets[0]?.data?.length
|
|
197
|
+
? props.data?.datasets[0]?.data?.length
|
|
198
|
+
: 0
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
onMounted(() => {
|
|
202
|
+
const resizeObserver = new ResizeObserver(getDimensions)
|
|
203
|
+
resizeObserver.observe(dlDoughnutChartWidgetRef.value)
|
|
204
|
+
getDimensions()
|
|
205
|
+
})
|
|
206
|
+
const classFlexLg = computed(() => (props.isSmall ? 'flex' : ''))
|
|
207
|
+
const classFlexDirection = computed(() =>
|
|
208
|
+
props.isSmall
|
|
209
|
+
? 'flex-column dl_doughnut__wrapper__container__gap__sm'
|
|
210
|
+
: 'flex-row dl_doughnut__wrapper__container__gap__lg'
|
|
211
|
+
)
|
|
212
|
+
const styleDoughnutWidth = computed(() =>
|
|
213
|
+
props.isSmall
|
|
214
|
+
? {
|
|
215
|
+
'justify-content': 'end',
|
|
216
|
+
width: getPixelsFromPercents(
|
|
217
|
+
doughnutChartWidgetWidth.value,
|
|
218
|
+
sizePercents,
|
|
219
|
+
'px'
|
|
220
|
+
),
|
|
221
|
+
height: getPixelsFromPercents(
|
|
222
|
+
doughnutChartWidgetHeight.value,
|
|
223
|
+
sizePercents / 1.8,
|
|
224
|
+
'px'
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
: {
|
|
228
|
+
height: getPixelsFromPercents(
|
|
229
|
+
doughnutChartWidgetHeight.value,
|
|
230
|
+
sizePercents,
|
|
231
|
+
'px'
|
|
232
|
+
),
|
|
233
|
+
width: getPixelsFromPercents(
|
|
234
|
+
doughnutChartWidgetHeight.value,
|
|
235
|
+
sizePercents,
|
|
236
|
+
'px'
|
|
237
|
+
)
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
const classSummaryLabel = computed(
|
|
242
|
+
() =>
|
|
243
|
+
`dl_doughnut__wrapper__container__chart__summary__label_${
|
|
244
|
+
props.isSmall ? 'sm' : 'lg'
|
|
245
|
+
}`
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
const classSummaryCount = computed(
|
|
249
|
+
() =>
|
|
250
|
+
`dl_doughnut__wrapper__container__chart__summary__count__${
|
|
251
|
+
props.isSmall ? 'sm' : 'lg'
|
|
252
|
+
}`
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
const mergedAnimation = computed(() =>
|
|
256
|
+
merge(defaultOptions.animation, props.animation)
|
|
257
|
+
)
|
|
258
|
+
defaultOptions.animation = mergedAnimation.value
|
|
259
|
+
|
|
260
|
+
const doughnutOptions = computed(() =>
|
|
261
|
+
merge(
|
|
262
|
+
{
|
|
263
|
+
plugins: {
|
|
264
|
+
legend: {
|
|
265
|
+
display: false
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
defaultOptions
|
|
270
|
+
)
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
/** Methods */
|
|
274
|
+
const hideData = (item: { index: number; hidden: boolean }) => {
|
|
275
|
+
chartRefValue.value._metasets[0].data[item.index].hidden =
|
|
276
|
+
item.hidden
|
|
277
|
+
chartRefValue.value.update()
|
|
278
|
+
|
|
279
|
+
if (item.hidden) {
|
|
280
|
+
hiddenIndexes.value.push(item.index)
|
|
281
|
+
return
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const indexOfItem = hiddenIndexes.value.indexOf(item.index)
|
|
285
|
+
if (indexOfItem > -1) {
|
|
286
|
+
hiddenIndexes.value.splice(indexOfItem, 1)
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const setHoverLight = () => {
|
|
291
|
+
chartRefValue.value.data.datasets[0].backgroundColor = cloneDeep(
|
|
292
|
+
(doughnutData.value.datasets[0] as any)?.lightColor
|
|
293
|
+
)
|
|
294
|
+
chartRefValue.value.update()
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const resetColors = () => {
|
|
298
|
+
const originalBackgroundColor = (
|
|
299
|
+
doughnutData.value.datasets[0] as any
|
|
300
|
+
)?.originalBackgroundColor
|
|
301
|
+
chartRefValue.value.data.datasets[0].backgroundColor = cloneDeep(
|
|
302
|
+
originalBackgroundColor
|
|
303
|
+
)
|
|
304
|
+
chartRefValue.value.update()
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const darkHighlight = (backgroundColorIndex: number): void => {
|
|
308
|
+
resetColors()
|
|
309
|
+
setHoverLight()
|
|
310
|
+
chartRefValue.value.data.datasets[0].backgroundColor[
|
|
311
|
+
backgroundColorIndex
|
|
312
|
+
] = cloneDeep(
|
|
313
|
+
(doughnutData.value?.datasets[0] as any)?.hoverBackgroundColor[
|
|
314
|
+
backgroundColorIndex
|
|
315
|
+
]
|
|
316
|
+
)
|
|
317
|
+
chartRefValue.value.update()
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const getDimensions = () => {
|
|
321
|
+
doughnutChartWidgetWidth.value =
|
|
322
|
+
dlDoughnutChartWidgetRef.value?.clientWidth
|
|
323
|
+
doughnutChartWidgetHeight.value =
|
|
324
|
+
dlDoughnutChartWidgetRef.value?.clientHeight
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const getPixelsFromPercents = (
|
|
328
|
+
totalPixels: number,
|
|
329
|
+
percents: number,
|
|
330
|
+
unit: string
|
|
331
|
+
): string => {
|
|
332
|
+
if (!totalPixels || !percents) {
|
|
333
|
+
return
|
|
334
|
+
}
|
|
335
|
+
const result = (percents / 100) * totalPixels
|
|
336
|
+
return `${result.toFixed(0)}${unit}`
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return {
|
|
340
|
+
doughnutChartRef,
|
|
341
|
+
dlDoughnutChartWidgetRef,
|
|
342
|
+
doughnutChartWidgetWidth,
|
|
343
|
+
doughnutChartWidgetHeight,
|
|
344
|
+
doughnutData,
|
|
345
|
+
doughnutOptions,
|
|
346
|
+
dlDoughnutChartSummaryRef,
|
|
347
|
+
itemsCount,
|
|
348
|
+
hiddenIndexes,
|
|
349
|
+
classFlexLg,
|
|
350
|
+
classFlexDirection,
|
|
351
|
+
styleDoughnutWidth,
|
|
352
|
+
classSummaryLabel,
|
|
353
|
+
classSummaryCount,
|
|
354
|
+
hideData,
|
|
355
|
+
darkHighlight,
|
|
356
|
+
resetColors,
|
|
357
|
+
setHoverLight,
|
|
358
|
+
doughnutPlugins
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
})
|
|
362
|
+
</script>
|
|
363
|
+
|
|
364
|
+
<style scoped lang="scss">
|
|
365
|
+
.dl_doughnut {
|
|
366
|
+
border: 1px solid #cccccc;
|
|
367
|
+
border-radius: 3px;
|
|
368
|
+
text-align: center;
|
|
369
|
+
align-items: center;
|
|
370
|
+
padding: 25px;
|
|
371
|
+
|
|
372
|
+
&__wrapper {
|
|
373
|
+
display: flex;
|
|
374
|
+
height: 510px;
|
|
375
|
+
text-align: center;
|
|
376
|
+
justify-content: center;
|
|
377
|
+
overflow: hidden;
|
|
378
|
+
|
|
379
|
+
&__container {
|
|
380
|
+
display: flex;
|
|
381
|
+
text-align: center;
|
|
382
|
+
align-items: center;
|
|
383
|
+
justify-content: center;
|
|
384
|
+
|
|
385
|
+
&__gap {
|
|
386
|
+
&__lg {
|
|
387
|
+
gap: 0 70px;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
&__sm {
|
|
391
|
+
gap: 25px 0;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
&__chart {
|
|
396
|
+
display: flex;
|
|
397
|
+
flex-direction: column;
|
|
398
|
+
justify-content: center;
|
|
399
|
+
align-items: center;
|
|
400
|
+
position: relative;
|
|
401
|
+
text-align: center;
|
|
402
|
+
|
|
403
|
+
&__summary {
|
|
404
|
+
height: 1px;
|
|
405
|
+
|
|
406
|
+
&__label_lg {
|
|
407
|
+
font-weight: normal;
|
|
408
|
+
color: var(--dl-color-medium);
|
|
409
|
+
font-size: var(--dl-font-size-h3);
|
|
410
|
+
line-height: 18.75px;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
&__label_sm {
|
|
414
|
+
font-weight: normal;
|
|
415
|
+
color: var(--dl-color-medium);
|
|
416
|
+
font-size: var(--dl-font-size-small);
|
|
417
|
+
line-height: 12px;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
&__count {
|
|
421
|
+
font-weight: normal;
|
|
422
|
+
color: var(--dl-color-darker);
|
|
423
|
+
|
|
424
|
+
&__lg {
|
|
425
|
+
font-size: var(--dl-font-size-h1);
|
|
426
|
+
line-height: 35px;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
&__sm {
|
|
430
|
+
font-size: var(--dl-font-size-h4);
|
|
431
|
+
line-height: 16px;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
&__legend {
|
|
439
|
+
text-align: initial;
|
|
440
|
+
|
|
441
|
+
&__row {
|
|
442
|
+
display: flex;
|
|
443
|
+
max-width: 350px;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
</style>
|