@dataloop-ai/components 0.19.220 → 0.19.221
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
|
@@ -98,6 +98,11 @@ import { TDoughnutWithOriginalColor } from './types/TDoughnutWithOriginalColor'
|
|
|
98
98
|
import DlEmptyState from '../../../../basic/DlEmptyState/DlEmptyState.vue'
|
|
99
99
|
import { DlEmptyStateProps } from '../../../../basic/DlEmptyState/types'
|
|
100
100
|
|
|
101
|
+
type SetupParams = {
|
|
102
|
+
attrs: { onItemClick?: (index: number) => void }
|
|
103
|
+
listeners?: { itemClick?: (index: number) => void }
|
|
104
|
+
}
|
|
105
|
+
|
|
101
106
|
export default defineComponent({
|
|
102
107
|
name: 'DlDoughnutChart',
|
|
103
108
|
components: {
|
|
@@ -132,7 +137,7 @@ export default defineComponent({
|
|
|
132
137
|
default: () => doughnutChartEmptyStateProps
|
|
133
138
|
}
|
|
134
139
|
},
|
|
135
|
-
setup(props,
|
|
140
|
+
setup(props, params: SetupParams) {
|
|
136
141
|
/** Data */
|
|
137
142
|
const doughnutChartRef = ref(null)
|
|
138
143
|
const dlDoughnutChartWidgetRef = ref(null)
|
|
@@ -280,8 +285,6 @@ export default defineComponent({
|
|
|
280
285
|
)
|
|
281
286
|
defaultOptions.animation = mergedAnimation.value
|
|
282
287
|
|
|
283
|
-
type ItemClickHandler = (index: number) => void
|
|
284
|
-
|
|
285
288
|
const doughnutOptions = computed(() =>
|
|
286
289
|
merge(
|
|
287
290
|
{
|
|
@@ -308,7 +311,10 @@ export default defineComponent({
|
|
|
308
311
|
}
|
|
309
312
|
},
|
|
310
313
|
onClick: (e: Event & { chart: ChartJS }) => {
|
|
311
|
-
|
|
314
|
+
const itemClick =
|
|
315
|
+
params.attrs.onItemClick ??
|
|
316
|
+
params.listeners?.itemClick
|
|
317
|
+
if (itemClick) {
|
|
312
318
|
const intersects =
|
|
313
319
|
e.chart.getElementsAtEventForMode(
|
|
314
320
|
e,
|
|
@@ -317,9 +323,7 @@ export default defineComponent({
|
|
|
317
323
|
false
|
|
318
324
|
)
|
|
319
325
|
if (intersects.length > 0) {
|
|
320
|
-
|
|
321
|
-
intersects[0].index
|
|
322
|
-
)
|
|
326
|
+
itemClick(intersects[0].index)
|
|
323
327
|
}
|
|
324
328
|
}
|
|
325
329
|
}
|