Browse Source

feat: add name in word cloud

main
nicolas.marsal 4 years ago
parent
commit
ad7fffa448
No known key found for this signature in database
GPG Key ID: 268AB819B6453541
  1. 1
      src/App.vue
  2. 17
      src/components/common/WordCloud.vue

1
src/App.vue

@ -12,7 +12,6 @@ import WordCloud from "@/components/common/WordCloud.vue";
<template>
<div class="main">
<div class="left">
<FirstNameAndLastName />
<div
style="
display: flex;

17
src/components/common/WordCloud.vue

@ -45,7 +45,7 @@ export default defineComponent({
},
computeWords() {
this.loading = true;
const words = Object.keys(skills)
let words: (cloud.Word & { size: number })[] = Object.keys(skills)
.map((p) => skills[p])
.map((s) => ({ text: s.name, size: s.score }));
@ -65,11 +65,22 @@ export default defineComponent({
const range = 120 * (1 - ((s - min) / (max - min)) * 0.7);
return Math.random() * range - range / 2;
};
words = [
{
size: max * 1.6,
text: "Nicolas Marsal",
rotate: -30,
padding: 6,
x: 0,
y: 0,
},
...words,
];
cloud<{ size: number } & cloud.Word>()
.size([this.width!, this.height!])
.words(words)
.padding(1)
.rotate((w) => randomRotate(w.size))
.padding((w) => w.padding ?? 1)
.rotate((w) => w.rotate ?? randomRotate(w.size))
.spiral("archimedean")
.fontSize((d) => scaleFontSize(d.size))
.on("end", (d: cloud.Word[]) => {

Loading…
Cancel
Save