@@ -4,6 +4,7 @@ import themes from "../themes.json";
44import Title from ' ../atoms/Title.vue' ;
55import UserOptions from ' ../atoms/UserOptions.vue' ;
66import { createUid , createWordCloudDatasetFromPlainText } from ' ../lib' ;
7+ import { debounce } from ' ../canvas-lib' ;
78import {
89 downloadCsv ,
910 error ,
@@ -18,6 +19,7 @@ import {
1819import { throttle } from ' ../canvas-lib' ;
1920import Accordion from " ./vue-ui-accordion.vue" ;
2021import DataTable from ' ../atoms/DataTable.vue' ;
22+ import MonoSlicer from ' ../atoms/MonoSlicer.vue' ;
2123import { useNestedProp } from ' ../useNestedProp' ;
2224import { usePrinter } from ' ../usePrinter' ;
2325import { useResponsive } from ' ../useResponsive' ;
@@ -74,12 +76,40 @@ const FINAL_CONFIG = computed(() => {
7476 }
7577});
7678
79+ const chartSlicer = ref (null );
80+ const slicer = ref (FINAL_CONFIG .value .style .chart .width );
81+
7782const svg = ref ({
78- width: FINAL_CONFIG .value . style . chart . width ,
79- height: FINAL_CONFIG .value .style .chart .height ,
83+ width: slicer .value ,
84+ height: FINAL_CONFIG .value .style .chart .height / FINAL_CONFIG . value . style . chart . height * slicer . value ,
8085 maxFontSize: FINAL_CONFIG .value .style .chart .words .maxFontSize ,
8186 minFontSize: FINAL_CONFIG .value .style .chart .words .minFontSize
82- })
87+ });
88+
89+ const handleResize = throttle (() => {
90+ const { width , height } = useResponsive ({
91+ chart: wordCloudChart .value ,
92+ title: FINAL_CONFIG .value .style .chart .title .text ? chartTitle .value : null ,
93+ slicer: FINAL_CONFIG .value .style .chart .zoom .show && chartSlicer .value
94+ });
95+ svg .value .width = width;
96+ svg .value .height = height;
97+ nextTick (generateWordCloud)
98+ });
99+
100+ watch (() => slicer .value , () => {
101+ debounceUpdateCloud ()
102+ });
103+
104+ const debounceUpdateCloud = debounce (() => {
105+ svg .value .width = Number (slicer .value )
106+ svg .value .height = FINAL_CONFIG .value .style .chart .height / FINAL_CONFIG .value .style .chart .height * Number (slicer .value )
107+ generateWordCloud ()
108+ }, 10 );
109+
110+ function refreshSlicer () {
111+ slicer .value = FINAL_CONFIG .value .style .chart .width ;
112+ }
83113
84114const resizeObserver = ref (null );
85115
@@ -88,7 +118,7 @@ onMounted(() => {
88118 error ({
89119 componentName: ' VueUiWordCloud' ,
90120 type: ' dataset'
91- })
121+ });
92122 } else {
93123 drawableDataset .value .forEach ((w , i ) => {
94124 getMissingDatasetAttributes ({
@@ -101,21 +131,11 @@ onMounted(() => {
101131 type: ' datasetSerieAttribute' ,
102132 property: attr,
103133 index: i
104- })
105- })
106- })
107- }
108- if (FINAL_CONFIG .value .responsive ) {
109- const handleResize = throttle (() => {
110- const { width , height } = useResponsive ({
111- chart: wordCloudChart .value ,
112- title: FINAL_CONFIG .value .style .chart .title .text ? chartTitle .value : null ,
134+ });
113135 });
114- svg .value .width = width;
115- svg .value .height = height;
116- nextTick (generateWordCloud)
117136 });
118-
137+ }
138+ if (FINAL_CONFIG .value .responsive ) {
119139 resizeObserver .value = new ResizeObserver (handleResize);
120140 resizeObserver .value .observe (wordCloudChart .value .parentNode );
121141 }
@@ -311,6 +331,7 @@ defineExpose({
311331<template >
312332 <div class =" vue-ui-word-cloud" ref =" wordCloudChart" :id =" `wordCloud_${uid}`"
313333 :style =" `width: 100%; font-family:${FINAL_CONFIG.style.fontFamily};background:${FINAL_CONFIG.style.chart.backgroundColor};${FINAL_CONFIG.responsive ? 'height:100%' : ''}`" >
334+
314335 <div ref =" chartTitle" v-if =" FINAL_CONFIG.style.chart.title.text" :style =" `width:100%;background:${FINAL_CONFIG.style.chart.backgroundColor};padding-bottom:24px`" >
315336 <Title :config =" {
316337 title: {
@@ -389,6 +410,27 @@ defineExpose({
389410 <slot name =" watermark" v-bind =" { isPrinting: isPrinting || isImaging }" />
390411 </div >
391412
413+ <div ref =" chartSlicer" :style =" `width:100%;background:${FINAL_CONFIG.style.chart.backgroundColor}`" data-html2canvas-ignore >
414+ <MonoSlicer
415+ v-if =" FINAL_CONFIG.style.chart.zoom.show"
416+ v-model:value =" slicer"
417+ :min =" 100"
418+ :max =" FINAL_CONFIG.style.chart.width * 3"
419+ :textColor =" FINAL_CONFIG.style.chart.color"
420+ :inputColor =" FINAL_CONFIG.style.chart.zoom.color"
421+ :selectColor =" FINAL_CONFIG.style.chart.zoom.highlightColor"
422+ :useResetSlot =" FINAL_CONFIG.style.chart.zoom.useResetSlot"
423+ :background =" FINAL_CONFIG.style.chart.zoom.color"
424+ :borderColor =" FINAL_CONFIG.style.chart.backgroundColor"
425+ :source =" FINAL_CONFIG.style.chart.width"
426+ @reset =" refreshSlicer"
427+ >
428+ <template #reset-action =" { reset } " >
429+ <slot name =" reset-action" v-bind =" { reset }" />
430+ </template >
431+ </MonoSlicer >
432+ </div >
433+
392434 <Accordion hideDetails v-if =" isDataset" :config =" {
393435 open: mutableConfig.showTable,
394436 maxHeight: 10000,
0 commit comments