@@ -104,11 +104,11 @@ watch(() => props.config, (_newCfg) => {
104104}, { deep: true });
105105
106106const chartSlicer = ref (null );
107- const slicer = ref (FINAL_CONFIG . value . style . chart . width );
107+ const slicer = ref (0 );
108108
109109const svg = ref ({
110- width: slicer .value ,
111- height: FINAL_CONFIG .value .style .chart .height / FINAL_CONFIG . value . style . chart . height * slicer . value ,
110+ width: FINAL_CONFIG .value . style . chart . width ,
111+ height: FINAL_CONFIG .value .style .chart .height ,
112112 maxFontSize: FINAL_CONFIG .value .style .chart .words .maxFontSize ,
113113 minFontSize: FINAL_CONFIG .value .style .chart .words .minFontSize
114114});
@@ -129,19 +129,18 @@ watch(() => slicer.value, () => {
129129});
130130
131131const debounceUpdateCloud = debounce (() => {
132- svg .value .width = Number (slicer .value )
133- svg .value .height = FINAL_CONFIG .value .style .chart .height / FINAL_CONFIG .value .style .chart .height * Number (slicer .value )
134132 generateWordCloud ()
135133}, 10 );
136134
137135function refreshSlicer () {
138- slicer .value = FINAL_CONFIG .value . style . chart . width ;
136+ slicer .value = wordMin .value ;
139137}
140138
141139const resizeObserver = ref (null );
142140
143141onMounted (() => {
144142 prepareChart ();
143+ refreshSlicer ();
145144});
146145
147146function prepareChart () {
@@ -246,12 +245,19 @@ const positionedWords = ref([]);
246245
247246watch (() => props .dataset , generateWordCloud, { immediate: true });
248247
248+ const wordMin = computed (() => {
249+ return Math .min (... drawableDataset .value .map (w => w .value ))
250+ })
251+ const wordMax = computed (() => {
252+ return Math .max (... drawableDataset .value .map (w => w .value ))
253+ })
254+
249255function generateWordCloud () {
250- const values = drawableDataset .value .map (d => d .value );
256+ const values = [ ... drawableDataset .value ]. filter ( w => w . value >= slicer . value ) .map (d => d .value );
251257 const maxValue = Math .max (... values);
252258 const minValue = Math .min (... values);
253259
254- const scaledWords = drawableDataset .value .map ((word , i ) => {
260+ const scaledWords = [ ... drawableDataset .value ]. filter ( w => w . value >= slicer . value ) .map ((word , i ) => {
255261 const fontSize = ((word .value - minValue) / (maxValue - minValue)) * (svg .value .maxFontSize - svg .value .minFontSize ) + svg .value .minFontSize ;
256262 const size = measureTextSize (word .name , fontSize);
257263 return {
@@ -522,8 +528,8 @@ function useTooltip(word) {
522528 <MonoSlicer
523529 v-if =" FINAL_CONFIG.style.chart.zoom.show"
524530 v-model:value =" slicer"
525- :min =" 100 "
526- :max =" FINAL_CONFIG.style.chart.width * 3 "
531+ :min =" wordMin "
532+ :max =" wordMax "
527533 :textColor =" FINAL_CONFIG.style.chart.color"
528534 :inputColor =" FINAL_CONFIG.style.chart.zoom.color"
529535 :selectColor =" FINAL_CONFIG.style.chart.zoom.highlightColor"
0 commit comments