Skip to content

Commit ef52b7c

Browse files
committed
Improvement - VueUiWordCloud - Add config option to use strictPixelPadding or not
1 parent b42356c commit ef52b7c

File tree

5 files changed

+8
-2
lines changed

5 files changed

+8
-2
lines changed

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ const components = ref([ //------|
125125
* Modify the index to display a component
126126
* [0] = VueUiXy
127127
*/
128-
const selectedComponent = ref(components.value[54]);
128+
const selectedComponent = ref(components.value[37]);
129129
130130
/**
131131
* Legacy testing arena where some non chart components can be tested

src/components/vue-ui-word-cloud.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ function generateWordCloud() {
237237
words: scaledWords,
238238
svg: svg.value,
239239
proximity: FINAL_CONFIG.value.style.chart.words.proximity,
240+
strictPixelPadding: FINAL_CONFIG.value.strictPixelPadding
240241
});
241242
}
242243

src/useConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3645,6 +3645,7 @@ export function useConfig() {
36453645
customPalette: [],
36463646
useCssAnimation: true,
36473647
animationDelayMs: 20,
3648+
strictPixelPadding: false, // If true, strict per-pixel padding is used (dilateWordMask); if false, just rectangular bounding box (or pad).
36483649
userOptions: USER_OPTIONS({
36493650
tooltip: true,
36503651
pdf: true,

src/wordcloud.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ export function positionWords({
135135
words,
136136
proximity = 0,
137137
svg,
138+
strictPixelPadding
138139
}) {
139140
const { width, height } = svg;
140141
const maskW = Math.round(width);
@@ -178,7 +179,9 @@ export function positionWords({
178179
svg
179180
});
180181

181-
wordMask = dilateWordMask({ wordMask, w, h, dilation: 2 });
182+
if (strictPixelPadding) {
183+
wordMask = dilateWordMask({ wordMask, w, h, dilation: 1 });
184+
}
182185

183186
let r = 0;
184187
let attempts = 0;

types/vue-data-ui.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5480,6 +5480,7 @@ declare module "vue-data-ui" {
54805480
userOptions?: ChartUserOptions;
54815481
useCssAnimation?: boolean;
54825482
animationDelayMs?: number;
5483+
strictPixelPadding?: boolean;
54835484
style?: {
54845485
fontFamily?: string;
54855486
chart?: {

0 commit comments

Comments
 (0)